I am trying to set up a data structure that is an extension of lambda calculus to allow addition and subtraction. I am trying to create a structure called AE that can either have a Lit as itself, or evaluate addition and subtraction. The error I am getting says that the following:
Invalid type signature: Lit :: ...
Should be of form variable :: type
Lit :: Int -> AE
What is wrong with my declartion of this data structure?
{-# Language GADTs #-}
data AE where
Lit :: Int -> AE
Add :: Int -> Int -> AE
Sub :: Int -> Int -> AE
deriving (Show)
eval :: AE -> Maybe Int
eval (Lit n) = Just n
eval (Add n1 n2) = n1 + n2
eval (Sub n1 n2) = do
if(n1<n2) then return nothing
else return n1 - n2