-
Notifications
You must be signed in to change notification settings - Fork 7
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
Error handling recommendations? #10
Comments
What would you like to happen when there are errors, and what would be a nice way to write rules and queries in that setting? My general approach has recently been to try to always return something of the right type, even if it's just a dummy value. Usually you can replace only part of the result with some error sentinel, e.g. put a parse error in the syntax tree where the parse error happened. I use Sometimes returning Maybe there is something that could be added to the library to help handling errors, but I don't quite know what yet. :) |
For me ideal scenario would be getting So far I've come up with multiple possible (probably) ways to handle errors in pipeline:
|
Yeah, sounds like we have some thinking to do. Contributions would also be appreciated, e.g for better ways to handle errors or examples using the current machinery!
Maybe something like
When using |
I've started exploring mempty+Writer+umbrella error type way and it seems to do everything I wanted: exhaustiveness due to pattern-matching on Query constructors, reports specific query where error happened and the handling can be done on call site. And with error handler like that I guess I'll do a pull request later adding some simplified example on how to handle errors in intermediate rules. |
It's unclear how one should handle failures in previous steps. Is there any recommended way to do it?
Using the example from readme, what if
Parse
was insteadFilePath -> Query (Either ParseError AST)
, what should happen in Typecheck if Parse returned Left?It seems sixten constructs a dummy value for result and uses Writer to store errors from previous steps. Are there other approaches?
The text was updated successfully, but these errors were encountered: