Today I started to learn about GADTs from: haskell.org and https://wiki.haskell.org
Unfortunately, I don't know how to use them. If I run the code from the example I get the following error:
[1 of 1] Compiling Main ( test.hs, interpreted )
AFP_229.hs:31:1:
Illegal generalised algebraic data declaration for `Term'
(Use GADTs to allow GADTs)
In the data declaration for `Term'
Failed, modules loaded: none.
Prelude>
This is the code I am using:
data Term a where
Lit :: Int -> Term Int
Succ :: Term Int -> Term Int
IsZero :: Term Int -> Term Bool
If :: Term Bool -> Term a -> Term a -> Term a
Pair :: Term a -> Term b -> Term (a,b)
I have tried other sample code, but this gives me the same error. How do you allow GADTs?