-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
customize error message for unrecognized value #149
Conversation
Listing the entire environment probably isn't helpful for the particular audience this fix is catering for. It will probably overwhelm them (the default env is quite large). I think it would be preferable to simply tell them the likely solution.
Maybe begin with something similar to what we already have, but follow up with something targeted for an absolute beginner someone who doesn't know what polymorphic means, or what an environment is, or how its relevant. I also agree with @panayi that saying "there is no type" is probably going to confuse them more than "there is no known type". It gives them a hint that they need to give sanctuary-def more information. Also, maybe sanctuary-def should adopt the first person as Elm does, so
Can become
And robotic phrases like
Can become
Having a persona for the error message can make explanation via prose seem more natural. Its rarely done, but I think its a great idea, that we should steal from Elm, particularly when sanctuary-def is a radically different approach to using JavaScript. This might be beyond the scope of this PR though, or may not be palatable for other reasons. I'm just imagining how some people I work with would interpret a sanctuary-def error, they would already struggle with the terminology (which I do want them to learn), and the type signatures (which I also want them to learn), but if the error message can guide them towards a solution to the point where they don't need to ask me for help, or open an issue here, or ask in the gitter, it's empowering. And I think that may lead people to have more courage to tackle the intimidating words, and be more likely to define their own types and lean on the library more often. I don't want us to avoid the real terms, I think that leads to amorphous nonsense, but there's no reason we can't elaborate and define those terms inline. |
It might also be helpful to detect common unrecognized values, and provide more specific errors that direct them to a type provided by the community that solves their exact problem. |
I find your suggestions extremely palatable! Rewriting all the existing error messages is out of scope for this pull request, but it is well worth doing. I've opened #150 to track this. Here's what I propose:
|
Good plan! 🎉 |
@davidchambers I like the branching of error-message for differentiating "no known type" Vs "can't satisfy type constraint". I think had I seen this message (not a member of any type in env + a list of existing types), it would be much easier to figure out that a new type def is needed.
If the list is too large, it could perhaps print out an array, that the user can expand to inspect. @JAForbes's suggestion for providing the user ways to resolve the issue in context, sounds awesome. |
496cab1
to
e3c2733
Compare
e3c2733
to
2097059
Compare
I've changed my mind. This pull request, though imperfect, is an improvement. I'll merge it. We can and should rethink these error messages as part of #150, but that prospect needn't prevent us from making an incremental improvement immediately. |
Closes #144
How do these error messages look to you, @panayi?