Skip to content

Commit

Permalink
add better Thunk printing
Browse files Browse the repository at this point in the history
  • Loading branch information
shashi committed Aug 5, 2020
1 parent 5100fb5 commit 6aace8d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/thunk.jl
Expand Up @@ -100,8 +100,15 @@ cache_result!(t::Thunk) = (t.cache=true; t)
Base.hash(x::Thunk, h::UInt) = hash(x.id, hash(h, 0x7ad3bac49089a05f % UInt))
Base.isequal(x::Thunk, y::Thunk) = x.id==y.id

function Base.show(io::IO, p::Thunk)
write(io, "*$(p.id)*")
function Base.show(io::IO, z::Thunk)
lvl = get(io, :lazy_level, 1)
print(io, "Thunk($(z.f), ")
if lvl < 2
show(IOContext(io, :lazy_level => lvl+1), z.inputs)
else
print(io, "...")
end
print(io, ")")
end

inputs(x::Thunk) = x.inputs
Expand Down

0 comments on commit 6aace8d

Please sign in to comment.