可视化 Julia 类型树

Visualize the Julia Type Tree

有没有方便的可视化Julia类型树的方法?我知道我可以为此编写一个函数...

function ttree(t::Type, indent = "    ")
    println(string(indent, t))
    indent *= "    "
    for st in subtypes(t)
        ttree(st, indent)
    end
end

ttree(Integer)

    Integer
        Bool
        Signed
            BigInt
            Int128
            Int16
            Int32
            Int64
            Int8
        Unsigned
            UInt128
            UInt16
            UInt32
            UInt64
            UInt8

...但是 Julia 对多重分派的强烈发音让我觉得一定有一些很酷的内置函数,对吧?

使用GraphRecipes:

using GraphRecipes, Plots
plot(Integer, method=:tree, fontsize=10, nodeshape=:rect)

这是一种 ASCII 方法

using AbstractTrees
AbstractTrees.children(d::DataType) = subtypes(d)

它正在运行

julia> print_tree(Integer)
Integer
├─ Bool
├─ Signed
│  ├─ BigInt
│  ├─ Int128
│  ├─ Int16
│  ├─ Int32
│  ├─ Int64
│  └─ Int8
└─ Unsigned
   ├─ UInt128
   ├─ UInt16
   ├─ UInt32
   ├─ UInt64
   └─ UInt8