Proposal to deprecate and then drop fromJust

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Tue Feb 24 05:49:47 UTC 2015


On 24 February 2015 at 16:42, Erik de Castro Lopo <mle+hs at mega-nerd.com> wrote:
> Hi all,
>
> We currently have in the Data.Maybe module from base:
>
>      fromJust :: Maybe a -> a
>
> which newbies often find using hoogle or other search tools and is
> a huge trap. *Every* usage of the above can be replaced by using
>
>       fromMaybe :: a -> Maybe a -> a
>
> which forces the user to provide a default value for the case where
> the Maybe a is a Nothing.
>
> The idea would be to deprecate fromMaybe for 7.12 and remove it
> completely later.
>
> Comments?

I've used fromJust in the past when I knew the value would be Just by
construction.

That said, I could always have written my own fromJust function with a
custom error message, and did switch some of them to direct pattern
matches (so that at least the error message said *where* the error
occurred).

So I'm undecided; maybe (no pun intended!) -0.1.

>
> Erik
> --
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


More information about the Libraries mailing list