From d4cbcb8b99849830ad55704f7ef9ec6a05e74689 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Fri, 19 Jan 2024 19:31:25 +0100 Subject: [PATCH] Fix position when an error occurs in `sat`. --- src/GenericParser/Parser.purs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/GenericParser/Parser.purs b/src/GenericParser/Parser.purs index 37ee244..2c1a604 100644 --- a/src/GenericParser/Parser.purs +++ b/src/GenericParser/Parser.purs @@ -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