Proposal to deprecate and then drop fromJust

Chris Allen cma at bitemyapp.com
Tue Feb 24 06:19:01 UTC 2015


Just a quick look on Github, filtering for uses of fromJust rather than 
re-declarations (mostly), shows 9,418 uses.

https://github.com/search?utf8=%E2%9C%93&q=extension%3Ahs+fromJust+%22import+Data.Maybe%22&type=Code&ref=searchresults

Searching for imports of Data.Maybe alone come to 19,985, indicating 
that at least ~half of the time people import Data.Maybe, they're using 
fromJust.

https://github.com/search?utf8=%E2%9C%93&q=extension%3Ahs+%22import+Data.Maybe%22&type=Code&ref=searchresults

As a baseline, Data.List shows up 28k times.

https://github.com/search?utf8=%E2%9C%93&q=extension%3Ahs+%22import+Data.List%22&type=Code&ref=searchresults

This is just from a 3 minute glance. If we really want to narrow it down 
to Hackage I'll do something more thorough.

On 02/24/2015 12:13 AM, Bardur Arantsson wrote:
> On 24-02-2015 06:42, 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?
>>
> How much code on Hackage is currently using fromJust? (A rough estimate
> by group would probably be sufficient.)
>
> Regards,
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



More information about the Libraries mailing list