Proposal to deprecate and then drop fromJust
Tom Murphy
amindfv at gmail.com
Fri Feb 27 04:06:41 UTC 2015
+1 to {-# WARNING #-}
+0.5 to deprecation/removal
I've used it, but for all the fans of fromJust, here's some code golf:
(fromMaybe (error "impossible"))
(fromMaybe undefined)
(\(Just x) -> x)
The last one is shortest, and with it ghc can tell you you're doing
something partial.
Tom
On Wed, Feb 25, 2015 at 1:25 AM, Konstantine Rybnikov <k-bx at k-bx.com> wrote:
> Maybe it would make sense to incorporate fromJustNote (as in `safe`
> package) and highly recommend that one in docs? It makes it easier to debug
> error and to realize that it will throw an error on Nothing.
> 25 лют. 2015 00:36, користувач "Daniel Díaz" <dhelta.diaz at gmail.com>
> написав:
>
> 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
>>>
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150226/9507980a/attachment.html>
More information about the Libraries
mailing list