[Haskell-beginners] Parsec chapter in realworldhaskell (ch.16)

Benjamin Edwards edwards.benj at gmail.com
Fri Oct 14 12:03:12 CEST 2011


It's not that it has no effect. If you have two parsers that have no common
initial productions then wrapping the first parser would have no effect.
That is the case here.

Just think of try as wrapping the stream / parser in a transaction. On
failure it rolls back.
On 14 Oct 2011 10:32, "Obscaenvs" <obscaenvs at gmail.com> wrote:

>  In http://book.realworldhaskell.org/read/using-parsec.html , under the
> heading "Extended example: Full CSV Parser", there is in the function
> quotedChar an occurrence of the operator <|> with a try after it (i.e. to
> the right) . Now, in this chapter it says a little before that "try only
> has an effect if it is on the left of a <|>.". So in this particular case,
> try has no effect, or?
>
> The offending code: <code>quotedChar = noneOf "\"" <|> try (string "\"\""
> >> return '"')</code>
>
> Help much appreciated, if not absolutely vital :)
>
> /Fredrik
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111014/4258c87f/attachment.htm>


More information about the Beginners mailing list