vendredi 6 décembre 2019

How can I interrogate the current GHCi environment?

I want to produce revised, fresh versions of this diagram, which appears in the Haskell98 standard:

enter image description here

In 2019 I will do this by generating a description of the graph I want, and feeding it to Graphviz. A proof-of-concept implementation I did yesterday, told only that there is something called Monad, can automatically produce this diagram:

enter image description here

The proof-of-concept program is rather awful, because the way it traverses the graph is by sending :info commands to GHCi and attempting to parse the output. I am not interested in pushing this approach any further.

The right way to do this is to figure out how GHC represents the class and instance information internally, then use its API to interrogate those data structures directly.

I have spent quite some time looking around in the GHC API documents but I have not found the entry points I need.

I think I want to ask GHC for a list of the names of all the typeclass and instance information currently in scope, and for a description of the constraints for each one.

What are good ways to proceed with this? Where should I be looking?

Thanks.





Aucun commentaire:

Enregistrer un commentaire