Translation of GHC typechecker output to haskell-src-exts's 'Type'

Tom Sydney Kerckhove syd.kerckhove at gmail.com
Sun Apr 2 12:40:05 UTC 2017


On 01-04-17 19:47:15, Ben Gamari wrote:
> Tom Sydney Kerckhove <syd.kerckhove at gmail.com> writes:
> 
> > Dear GHC Devs,
> 
> Hi Tom,

Hi Mr Gamari

> 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.

Oh, that's already done by then? It makes a lot more sense now why I get
this:

ghcs translation: Ord a -> [a] -> [a]
haskell-src-exts: Ord a => [a] -> [a]

I'm guessing that this 'Ord a' that I get, is the type of the dictionary
for 'Ord' in the case of 'a'.

Is there a way to access the types before this translation happens?
It's okay if I have to assume that type-checking succeeds...

> 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.

This does help, thank you!
 
> Cheers,

Thank you for your time.

> - Ben
> 



-- 
Tom Sydney Kerckhove
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20170402/82565841/attachment.sig>


More information about the ghc-devs mailing list