
* j.romildo@gmail.com
Hello.
In order to learn GADTs, I have written the attached program, which defines a type for arithmetic expressions using GADTs, a parser for them, and an evaluation function.
But my parser does not typecheck. ghc-7.4.1 gives me the error message:
Expr.hs:25:28: Couldn't match expected type `Double' with actual type `Bool' Expected type: Bool -> Expr Double Actual type: Bool -> Expr Bool In the first argument of `(<$>)', namely `B' In the first argument of `(<|>)', namely `B <$> pBool'
Any clues on how to fix that?
The alternatives given to <|> must be of the same type. In your case, one is Expr Double and one is Expr Bool. Inclusion of pBool in pFactor is probably a mistake — unless you're going to multiply booleans. -- Roman I. Cheplyaka :: http://ro-che.info/