GHC不接受GADT类型签名

时间:2014-05-10 06:31:02

标签: haskell

此声明不起作用:

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

如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

至少从GHC 7.8开始,如果你打开GADT支持,那么你的代码就会检查并做你期望的事情

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

导致:

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