
I'm a big fan of fromJust, so a -1 to this proposal. I'm also a fan of
adding fromLeft and fromRight, but doubt anyone is going to agree with
me. These functions have an obvious meaning, and an obvious
implementation and an obvious name - they're handy. They should be
used with caution, and documented as to their downsides, but they're
still useful.
I also wouldn't describe fromJust as "unsafe", merely that "using
fromJust might be unsafe" - and that's something you might reasonably
want to check (and could, with the Catch tool,
http://community.haskell.org/~ndm/catch/, which is now thoroughly
dead).
As to the HLint warning, I'm not a great fan of it, since it's
basically saying "use explicit error since your compiler won't give
you a stack trace". I want to do configurable packages of HLint
replacements, so having it in there is a reasonable thing. I'll think
some more on that aspect.
Thanks, Neil
On Tue, Feb 24, 2015 at 1:09 PM, Oleg Grenrus
And I did it myself, as it was about adding one single line rule:
https://github.com/ndmitchell/hlint/pull/115
Let’s see what Neil thinks about :)
- Oleg
On 24 Feb 2015, at 12:28, Oleg Grenrus
wrote: On 24 Feb 2015, at 12:23, Erik de Castro Lopo
wrote: Possibly what we need is a pragma to mark functions partial and a warning flag that warns on usage of functions that have been marked partial.
I had this in mind too, but that is very heavy solution. I’d rather start with making hlint warnings?
foo :: Maybe Int -> Int foo x = if isJust x then fromJust x else 0
bar :: Maybe Int -> Int bar x = 1 + fromJust x
It warns about `foo` nonsense. It could propose to change `bar` part into `fromMaybe (error “I’know what I’m doing”) x` ?
- Oleg
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries