AlgebraicJulia / Catlab.jl

A framework for applied category theory in the Julia language
https://www.algebraicjulia.org
MIT License
619 stars 58 forks source link

Pretty-print for C-set transformations #408

Open epatters opened 3 years ago

epatters commented 3 years ago

The default show method dumps all the type information and is therefore very unreadable.

kris-brown commented 3 years ago

Would something like this be helpful to implement?


CSetTransformation with elements V = 3↦2, E = 2↦3

┌────┬──────┬───┐
│  V │ refl │ → │
├────┼──────┼───┤
│  1 │   1  │ 2 │
│  2 │   3  │ 2 │
│  3 │   2  │ 1 │
├────┼──────┼───┤
│  1 │   2  │ * │
│  2 │   3  │ * │
└────┴──────┴───┘

┌────┬─────┬─────┬───┐
│  E │ src │ tgt │ → │
├────┼─────┼─────┤───┤
│  1 │   1 │   1 │ 3 │
│  2 │   2 │   2 │ 2 │
│  3 │   3 │   3 │ 3 │
│  4 │   2 │   1 │ 1 │
├────┼─────┼─────┤───┤
│  1 │   1 │   2 │ * │
│  2 │   1 │   1 │ * │
│  3 │   2 │   2 │ * │
└────┴─────┴─────┴───┘
epatters commented 3 years ago

That's an interesting idea. I was thinking that for the default show method, we would have a short and simple display mirroring the constructor, something like

ACSetTransformation((V=[...], E=[...]), [dom], [codom])

where [dom] and [codom] are some abbreviated representations of the domain and codomain ACSets, perhaps just showing their sizes.

But then we could also have a show method for MIME type text/plain with a richer, tabular display, possibly along the lines you suggest.

This would agree with the conventions on the show method for ACSets themselves (see CSetDataStructures).

epatters commented 3 years ago

The PR above resolves the most immediate problem but I'll this issue open because I like the idea of having a show method for MIME type text/plain along the lines that Kris suggests.