[Haskell-cafe] Parsec Expected Type

Paul Keir pkeir at dcs.gla.ac.uk
Fri Mar 28 05:02:19 EDT 2008


Thanks, I'd thought it was something to do with incompatible types. I can now create a simpler problem:

tester2 = reserved "parameter" <|> symbol ":"

Certainly I could use reserved ":" instead of symbol, but where is my thinking with symbol here going wrong? Surely the above example isn't so odd?

Paul


-----Original Message-----
From: Luke Palmer [mailto:lrpalmer at gmail.com]
Sent: Fri 3/28/2008 12:26 AM
To: Paul Keir
Cc: haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] Parsec Expected Type
 
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080328/69d305b7/attachment.htm


More information about the Haskell-Cafe mailing list