Translation of GHC typechecker output to haskell-src-exts's 'Type'
ben at smart-cactus.org
Sat Apr 1 23:47:15 UTC 2017
Tom Sydney Kerckhove <syd.kerckhove at gmail.com> writes:
> Dear GHC Devs,
> Because of the unwieldy nature of the data that the GHC type checker
> outputs, I am trying to convert a GHC 'Type'  to a haskell-src-ext
> 'Type' .
> 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'  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
> In particular, I am having trouble finding type class constraints in the
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
I hope this helps.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 487 bytes
Desc: not available
More information about the ghc-devs