[Haskell-cafe] Parsec Expected Type

Luke Palmer lrpalmer at gmail.com
Thu Mar 27 20:26:26 EDT 2008


Hi Paul,

2008/3/27 Paul Keir <pkeir at dcs.gla.ac.uk>:
> Hi,
>
>  Does anyone know why this reduced Parsec production stops compilation, and
> how I can fix it?
>
>  tester = reserved "parameter"
>       <|> do { reserved "dimension"; symbol ":" }

Look at the types of "reserved" and "symbol" (from
http://www.haskell.org/ghc/docs/latest/html/libraries/parsec/Text-ParserCombinators-Parsec-Token.html):

  symbol :: String -> CharParser st String
  reserved :: String -> CharParser st ()

The type of a do block is the same as the type of its last statement.
But (reserved "parameter") and (symbol ";") do not have the same type.

Luke


More information about the Haskell-Cafe mailing list