tidy: Logic.Parse

This commit is contained in:
hi 2025-08-12 13:36:06 +00:00
parent 88c140fed5
commit bd9b58c405

View file

@ -79,9 +79,9 @@ parseToken token = Parser parse
| otherwise = Left $ expected (show token) input
parseIf :: Show s => String -> (s -> Bool) -> Parser s s
parseIf description check = Parser $ \input ->
case inputSeq input of
[] -> Left $ ParseError (inputPos input) "unexpected end of input"
parseIf description check = Parser $ \input@(Input pos xs) ->
case xs of
[] -> Left $ ParseError pos "unexpected end of input"
(char:chars)
| check char -> Right $ (char,) $ Input (inputPos input + 1) chars
| check char -> Right $ (char,) $ Input (pos + 1) chars
| otherwise -> Left $ expected description input