Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GHC does not accept GADT type signature

Tags:

haskell

This declaration doesn't work:

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

How to fix this?

like image 989
ThePiercingPrince Avatar asked May 10 '14 06:05

ThePiercingPrince


1 Answers

At least as of GHC 7.8, if you turn on GADT support, then your code typechecks and does what you'd expect:

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

resulting in:

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
like image 111
Cactus Avatar answered Nov 15 '22 08:11

Cactus