[Haskell-cafe] ParsecT bug [was: ANNOUNCE: Parsec 3.1.0]

Roman Cheplyaka roma at ro-che.info
Thu Mar 4 12:40:09 EST 2010

By coincidence, today I found a bug in the parsec 3.0.[01]. Probably due
to changes introduced the bug is absent in parsec 3.1.0.

I think it is worth to release 3.0.2 with this bug fixed.

The bug itself is demonstrated in the following code. It gives
Right (False,True) with parsec-3.0.x while should be giving Right (False,False).

And, by the way, does parsec have any code repository and/or bug tracker?

> import Text.Parsec hiding (parse)
> import Control.Monad.Reader
> type Parser = ParsecT String () (Reader Bool)
> change :: Parser a -> Parser a
> change p = local (const False) p
> p = change $ do
>     was <- ask
>     anyChar
>     now <- ask
>     return (was,now)
> parse :: Parser a -> SourceName -> String -> Either ParseError a
> parse p name s = runReader (runPT p () name s) True
> main = print $ parse p "" "a"

* Derek Elkins <derek.a.elkins at gmail.com> [2010-03-03 22:45:12-0600]
> Changes:
>     - the changes to the core of Parsec lead to some changes to when
> things get executed when it is used as a monad transformer
>         "In the new version bind, return and mplus no longer run in
> the inner monad, so if the inner monad was side-effecting for these
> actions the behavior of existing code will change."
>     - notFollowedBy p now behaves like notFollowedBy (try p) which
> changes the behavior slightly when p consumes input, though the
> behavior should be more natural now.
>     - the set of names exported from Text.Parsec.Prim has changed somewhat

Roman I. Cheplyaka :: http://ro-che.info/
"Don't let school get in the way of your education." - Mark Twain

More information about the Haskell-Cafe mailing list