[Haskell-cafe] Arithmetic expressions with GADTs: parsing

j.romildo at gmail.com j.romildo at gmail.com
Wed May 2 13:03:45 CEST 2012


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?

Romildo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Expr.hs
Type: text/x-haskell
Size: 1226 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120502/392a10b4/attachment.hs>


More information about the Haskell-Cafe mailing list