该声明不起作用:
data Identity a where {Identity :: (->) a (Identity a)}
如何解决这个问题?
最佳答案
至少从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
关于haskell - GHC不接受GADT类型签名,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23577889/