Commit 0634964f authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

Document common pitfall w/ `notFollowedBy` & non-consuming parsers

This is a provisional measure until `notFollowedBy` gets fixed.

See #3 for more details
parent 4c62f13c
......@@ -255,6 +255,17 @@ eof = notFollowedBy anyToken <?> "end of input"
-- > keywordLet = try (do{ string "let"
-- > ; notFollowedBy alphaNum
-- > })
--
-- __NOTE__: Currently, 'notFollowedBy' exhibits surprising behaviour
-- when applied to a parser @p@ that doesn't consume any input;
-- specifically
--
-- - @'notFollowedBy' . 'notFollowedBy'@ is /not/ equivalent to 'lookAhead', and
--
-- - @'notFollowedBy' 'eof'@ /never/ fails.
--
-- See [haskell/parsec#3](https://github.com/haskell/parsec/issues/8)
-- for more details.
notFollowedBy :: (Stream s m t, Show a) => ParsecT s u m a -> ParsecT s u m ()
notFollowedBy p = try (do{ c <- try p; unexpected (show c) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment