Fix position when an error occurs in `sat`.
parent
bbb5c1c415
commit
d4cbcb8b99
|
@ -121,8 +121,10 @@ try p = Parser p'
|
|||
_ -> failureError position error
|
||||
|
||||
sat :: forall e. (Char -> Boolean) -> Parser e Char
|
||||
sat p = do x <- item
|
||||
if p x then pure x else empty
|
||||
sat p = do
|
||||
pos <- current_position
|
||||
x <- item
|
||||
if p x then pure x else Parser \input -> failure pos
|
||||
|
||||
digit :: forall e. Parser e Char
|
||||
digit = sat isDigit
|
||||
|
|
Loading…
Reference in New Issue