-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defer error in string
#158
Comments
This is a benchmark for failing a
|
I think that deferring error message construction in the case of purescript-parsing/src/Parsing.purs Line 39 in cade0cd
to data ParseError = ParseError (Unit -> String) Position ? |
Also I think we don't even want the error functions to prepend
|
And while we're at it should we accumulate a |
In what situation would there be more than 1 parser error? Or do you want to track all the backtracking decisions in that error list? |
It's not clear to me there is value in having multiple errors with the current approach to error handling and recovery (or lack thereof). The point of the current "consumed" check is that it's a heuristic for generating a single, specific error. If you wanted to have multiple errors, you would want to remove the check, always backtrack, and then let the user decide which is most specific (potentially by how far it progressed). I personally don't think it's worth doing in this library without having a clear idea of what you wanted to accomplish and enable that is better than the status quo. |
Note, a "deferred" error doesn't necessarily need to be a thunk. It could potentially just be a structured data type that is constant-time to construct, and potentially only applies escaping rules when rendered. |
Yeah, let's not do multiple errors.
What would that look like? |
Maybe something like: data ParseError
= UnexpectedInput { inputExpected :: Array String, inputSeen :: String }
| ...
| EmptyAlternative I'm not sure what other data types would be there, but you might look at what kind of errors we throw and see if it makes sense for others to throw them. The most common is invariably unexpected input errors. |
string
is potentially slow on failure because of theshow
call to the input string. Failure cases are hit very often, and if you are usingstring
a lot this can be significant overhead. Deferred errors might be better in general.Originally posted by @natefaubion in #144 (comment)
The text was updated successfully, but these errors were encountered: