Describe the bug
-- | Read ahead without consuming input.
lookAhead :: forall a. Parser a -> Parser a
lookAhead (Parser p) = Parser \s ->
case p s of
Right { result } -> Right { result, suffix: s }
left -> left
As you can see from the definition the suffix is "reset" to s in case of success, but in case of error the error is passed on as is, meaning the PosString at the failure is propagated.
Expected behavior
I would expect the function to do what its documentation suggests: to not consume any input. Or if this is really not intended I would expect the documentation to be correct and not misleading.
Additional context
This cost me quite some debugging time :) I'm currently working around it by using try $ lookAhead everywhere.
Describe the bug
As you can see from the definition the suffix is "reset" to
sin case of success, but in case of error the error is passed on as is, meaning thePosStringat the failure is propagated.Expected behavior
I would expect the function to do what its documentation suggests: to not consume any input. Or if this is really not intended I would expect the documentation to be correct and not misleading.
Additional context
This cost me quite some debugging time :) I'm currently working around it by using
try $ lookAheadeverywhere.