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

Simon Peyton Jones simonpj at microsoft.com
Mon Apr 3 10:59:39 UTC 2017


Tom

Please start a wiki page, somewhere under https://ghc.haskell.org/trac/ghc/wiki/Commentary
that gives the information you wish was more clearly described.

And/or add a Note in TyCoRep to explain.

My answer to your question would be:

The type that Haskell programmers write 
	Ord a => a -> a
is represented in Type using FunTy, thus
	Ord a -> a -> a
There is no "=>" data contructor.

Instead you can tell the difference between -> and => by looking at the kind of the bit before the ->.  Thus
	ty1 -> ty2
if ty1 :: Constraint, then it it's a "=>" otherwise a "->".

Use (isPredTy ty1) to tell the difference.


Does that help

Simon

|  -----Original Message-----
|  From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Tom
|  Sydney Kerckhove
|  Sent: 02 April 2017 14:02
|  To: Ben Gamari <ben at smart-cactus.org>
|  Cc: ghc-devs at haskell.org
|  Subject: Re: Translation of GHC typechecker output to haskell-src-
|  exts's 'Type'
|  
|  On 02-04-17 14:40:05, Tom Sydney Kerckhove wrote:
|  > Is there a way to access the types before this translation happens?
|  > It's okay if I have to assume that type-checking succeeds...
|  
|  I have found a way to do what I want, even after this translation.
|  It relies on the fact that type class constraints always occur on the
|  left side of the result of splitFunTy.
|  
|  Thank you for your help!
|  
|  --
|  Tom Sydney Kerckhove


More information about the ghc-devs mailing list