
Tom Sydney Kerckhove
Dear GHC Devs,
Hi Tom,
Because of the unwieldy nature of the data that the GHC type checker outputs, I am trying to convert a GHC 'Type' [1] to a haskell-src-ext 'Type' [2].
The translation does not need to be perfect for now, but I would at least like to be able to translate function types and types that involve type-class constraints. (See my initial attempt in attachment)
Has this ever been done before?
I'm not aware of any implementations, but I can't claim to have seen every usage of haskell-src-exts.
Could you point me to some documentation on GHC's 'Type' [1] that could help me with writing this function? (The comments in code aren't nearly enough for me.)
I'm afraid the notes in TyCoRep are really all we have. Note that you should also familiarize yourself with the TyCon type (for reasons you'll see below).
In particular, I am having trouble finding type class constraints in the 'Type'.
During typechecking class constraints are turned into dictionary arguments. If I'm not mistaken you can pick these out by looking for AlgTyCons (a constructor of the TyCon type, see TyCon.hs) with a algTcParent matching (ClassTyCon cls _). cls will be the name of the associated class. I hope this helps. Cheers, - Ben