GHC does not accept GADT type signature

This expression does not work:

data Identity a where {Identity :: (->) a (Identity a)} 

How to fix it?

+7
haskell
source share
1 answer

At least with GHC 7.8, if you enable GADT support, then your typechecks code will do what you expect :

 {-# LANGUAGE GADTs #-} data Identity a where {Identity :: (->) a (Identity a)} 

as a result of:

 GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Main ( foo.hs, interpreted ) Ok, modules loaded: Main. ฮปยป :i Identity data Identity a = Identity a -- Defined at foo.hs:2:1 
+2
source share

All Articles