This declaration doesn't work:
data Identity a where {Identity :: (->) a (Identity a)}
How to fix this?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.