-
Couldn't load subscription status.
- Fork 50
Closed
Description
The regex API defers maps a syntax error to a call to fail. Unfortunately this means if you use regex with alt, this failure will probably just get swallowed, and the parser will just fallthrough to the next alternative. This makes it very difficult to track down these errors. I experienced this when writing the json parser benchmarks, which uses regex.
Some alternatives may be:
- Change the signature to yield a
Either String (ParserT String m String), and haveunsafeRegexfunctions which use unsafeCrashWith. This will mean that syntax errors will fail with a hard exception at least, and you'll have a stack trace to the regex call. - Change the failure implementation to
consume $ fail ...which will set the consume bit so it's less likely to fallthrough. Unfortunately this doesn't work if it's wrapped intry, and it gives you no indication where the error comes from. - Provide some sort of hard failure mode in the parser implementation so that it's impossible to recover from it. This still doesn't give you a very good indication where it came from though.
Metadata
Metadata
Assignees
Labels
No labels