You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- | If parsing fails inside this context, then prepend the String to the error String.label::forallmsa. Monadm=>String->ParserTsma->ParserTsma
label preerror p = catchError p go
where go (ParseError err pos) = failWithPosition (preerror <> err) pos
Actually come to think of it, anyone can use this label function without library support. Maybe I'll just do that.
I suppose if we wanted to make this more official and support it in the library, then we could change the error type to ParseError (NonEmptyList String) Position and cons the errors up as we fail out of the parser.
The text was updated successfully, but these errors were encountered:
It would be nice if we could get some context with parse failures, like Megaparsec
label
In
ParserT
,fail
is implemented asthrowError
purescript-parsing/src/Text/Parsing/Parser.purs
Lines 132 to 138 in e801a0e
This suggests a cheap implementation strategy for
label
, usingcatchError :: forall a. m a -> (e -> m a) -> m a
.Actually come to think of it, anyone can use this
label
function without library support. Maybe I'll just do that.I suppose if we wanted to make this more official and support it in the library, then we could change the error type to
ParseError (NonEmptyList String) Position
and cons the errors up as we fail out of the parser.The text was updated successfully, but these errors were encountered: