Skip to content
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

Consider: read -> fromMaybe undefined . readMaybe (and "exposing partiality") #1307

Open
googleson78 opened this issue Oct 15, 2021 · 2 comments

Comments

@googleson78
Copy link
Contributor

googleson78 commented Oct 15, 2021

See the thread at https://mail.haskell.org/pipermail/libraries/2021-October/031453.html, and in particular, the comment by @andreasabel (which I agree with) :

+1 to promoting readMaybe.
HLint could replace read by fromMaybe undefined . readMaybe.
Partiality can be debugged better when it is in the application, rather
than in the library.

If not in the default hints, maybe there could be a hint set called something like "Expose partiality" that does this kind of transformation for most of the partial funtions in base/Prelude

@zliu41
Copy link
Collaborator

zliu41 commented Oct 15, 2021

The only issue I have with this is that I doubt anyone would literally take that suggestion. At the very least they'd use error "..." rather than undefined.

If there's no single best suggested replacement for read, probably it should be a restricted function ({name: read, within: [], message "Use readMaybe"}) rather than a hint.

@ndmitchell
Copy link
Owner

Have a special group of hints that people could enable is fine - that way the user makes a choice to opt in to partiality. I wish there was a todo = undefined in the stdlib, much like there is in Rust, that people could ban from being commited - that would ensure people did something sensible after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants