Implement specialised composed function printing

This commit is contained in:
TEC 2024-04-08 19:06:23 +08:00
parent 19fe198ba4
commit 40f29a9bd0
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 17 additions and 0 deletions

View File

@ -20,6 +20,23 @@ function about(io::IO, fn::Function)
print(io, ".\n")
end
function about(io::IO, @nospecialize(cfn::ComposedFunction))
print(io, styled"{bold:Composed function:} ")
fnstack = Function[]
function decompose!(fnstk, c::ComposedFunction)
decompose!(fnstk, c.outer)
decompose!(fnstk, c.inner)
end
decompose!(fnstk, c::Function) = push!(fnstk, c)
decompose!(fnstack, cfn)
join(io, map(f -> styled"{julia_funcall:$f}", fnstack), styled" {julia_operator:∘} ")
println(io)
for fn in fnstack
print(io, styled" {emphasis:•} ")
about(io, fn)
end
end
function about(io::IO, method::Method)
fn, sig = first(method.sig.types).instance, Tuple{map(Base.unwrap_unionall, method.sig.types[2:end])...}
show(io, method)