[Haskell-cafe] Parsec Expected Type
Paul Keir
pkeir at dcs.gla.ac.uk
Fri Mar 28 17:21:21 EDT 2008
Could tester2 return "some kind of base type", which the two inherit from? I don't know. I'm really only presenting the ugly tester2 function because I'm looking for a Parsec-concordant solution to what appears a simple problem.
What I'd like is to parse either the string "parameter", or the string ":". I'm using 'reserved' and 'symbol' because they seem to correspond well to the concepts in the language I'm parsing. I could try,
tester3 = reserved "parameter" <|> do { symbol ":"; return () }
but that's feels a bit contrived; or I could use 'reserved' twice.
Perhaps I'd express my confusion better if I ask: Why are 'reserved' and 'symbol' different types?
Paul (Haskell Novice)
-----Original Message-----
From: Jonathan Cast [mailto:jonathanccast at fastmail.fm]
Sent: Fri 3/28/2008 2:05 PM
To: Paul Keir
Cc: Luke Palmer; haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] Parsec Expected Type
On 28 Mar 2008, at 2:02 AM, Paul Keir wrote:
> 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?
>
What type do you expect tester2 to return?
jcc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080328/b7615f6f/attachment.htm
More information about the Haskell-Cafe
mailing list