Skip to content

Instantly share code, notes, and snippets.

@neomatrixcode
Forked from jbn/julia_type_hierarchy.jl
Last active August 29, 2015 14:25
Show Gist options
  • Save neomatrixcode/04d3c310d82bd2e40e8b to your computer and use it in GitHub Desktop.
Save neomatrixcode/04d3c310d82bd2e40e8b to your computer and use it in GitHub Desktop.
# Requested gist of code to produce:
# https://www.scribd.com/doc/271871142/Julia-Type-Hierarchy
#
# I just redirected the output to a dot file, then executed:
# dot -Tpdf julia.dot -o julia.pdf
function print_type_tree(t, parent=Any, seen=Set{DataType}())
# Avoid redundant edges.
t ∈ seen && return
push!(seen, t)
# Avoid self-edges.
t != Any && println(""" "$t" -> "$parent";""")
# Recurse, divine!
for s in subtypes(t)
print_type_tree(s, t, seen)
end
end
println("digraph {")
print_type_tree(Any)
println("}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment