[Haskell-cafe] Examples for the problem

Stephen Tetley stephen.tetley at gmail.com
Wed Mar 2 17:24:42 CET 2011


Apologies if this has been answered already (I've got a bit lost with
this thread), but the *try* here seems to be giving you precisely the
behaviour you don't want.

*try* means backtrack on failure, and try the next parser. So if you
want ill formed strings to throw an error if they aren't properly
enclosed in double quotes don't use try.

<|> try $ (char '"' *> (StringLit . B.pack <$>
                   manyTill (notChar '\n') (char '"')))



More information about the Haskell-Cafe mailing list