haskell / haskell/parsec

`notFollowedBy` and parsers which don't consume input.

Open
#8 3 comments 2 reactions 0 assignees View on GitHub
pvp:major
Dominant language
Haskell
Stars
892
Forks
99
PR merge metrics
No merged PRs in 30d

Description

Currently `notFollowedBy` always succeeds with parsers that don't consume input:

``` haskell
-- This parser succeeds.
> parseTest (lookAhead (string "a")) "abc"
"a"

-- Therefore this parser should fail – but it doesn't.
> parseTest (notFollowedBy (lookAhead (string "a"))) "abc"
()
```

Is this bug [old enough](http://www.haskell.org/pipermail/haskell/2004-February/013622.html) to be considered a feature? (Even if so, this behavior should probably be documented.) If not, here's a version that works (but no idea how much slower, if at all):

``` haskell
notFollowedBy' :: (Stream s m t, Show a) => ParsecT s u m a -> ParsecT s u m ()
notFollowedBy' p = try $ join $
do {a <- try p; return (unexpected (show a));}
<|> return (return ())
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.