Skip to content

Instantly share code, notes, and snippets.

@jbn
Created July 17, 2015 22:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jbn/b401d057646b1190bcc1 to your computer and use it in GitHub Desktop.
Save jbn/b401d057646b1190bcc1 to your computer and use it in GitHub Desktop.
Julia Type Hierarchy
# 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