purescript-contrib/purescript-parsing

lookAhead consume on failure?

Opened this issue · 1 comments

-- | Parse a phrase, without modifying the consumed state or stream position.
lookAhead :: forall s a m. Monad m => ParserT s m a -> ParserT s m a
lookAhead p = (ParserT <<< ExceptT <<< StateT) \s -> do
Tuple e _ <- runStateT (runExceptT (unwrap p)) s
pure (Tuple e s)

This seems different from the way that Parsec and Megaparsec work? They consume input in case of failure.

https://hackage.haskell.org/package/megaparsec-9.2.0/docs/Text-Megaparsec.html#v:lookAhead

https://hackage.haskell.org/package/parsec-3.1.15.0/docs/Text-Parsec.html#v:lookAhead

See also purescript-contrib/purescript-string-parsers#73