Generate a graph of subtypes

Hello,

I find myself manually making (abstract) type diagrams to efficiently explain the hierarchy to collaborators. Supplying a type to a function which prints a nice textual network of types would be very useful.

This seems like something someone must have thought about and either done or abandoned because it’s impossible. My starting point is something like:

function printTypeHierarchy(T)
  print("$(T)\n");
  for Tprime in subtypes(T)
    printTypeHierarchy(Tprime)
  end
  print("\t")
end

which is obviously a long way from what is described above. Before I invest any more time in this, can someone point out why I should not or point me to an extant one?

1 Like
2 Likes

What you want is the transitive reduction of the set of types, which is a partially-ordered set (poset). A visualization of the transitive reduction of a poset is known as a Hasse diagram.

I think Graphs.jl has some transitive reduction functionality, and there’s also this package, although it doesn’t seem to be registered, @scheinerman:

Oh this is perfect – thanks!