Proposal to deprecate and then drop fromJust

Daniel Díaz dhelta.diaz at gmail.com
Tue Feb 24 22:36:31 UTC 2015


Hi.

This function has been guilty (more than once) of making my debugging 
harder by providing
too little error information. Sure, the programmer who wrote the code 
should have made
sure that the argument could not possibly be Nothing, but that didn't 
stopped him/her
to use fromJust. Yes, there is always a way to make an "error" happen, 
but without
fromJust you'll have to do so explicitly. I think we should encourage 
good practices.
Just my point of view.

The downside I see are the current occurrences of fromJust all around. I 
guess they are
a huge lot. Although I would love to get rid of them, this would require 
some work (even
if it's very little) from a lot of developers. So if we want to do this, 
a consensus
must be built first.

Therefore, +1 from me.

Best regards,
Daniel Díaz.

On 02/24/2015 06:42 AM, Erik de Castro Lopo 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?
>
> Erik



More information about the Libraries mailing list