However, I think it'll require a very long deprecation cycle beforeTerrifyingly, yes. I fired off a shell-script to cabal unpack all the libraries on Hackage last night and some cursory grepping has brought me:
actually removing it from base, as 'fromJust' is officially part of
Haskell 2010, and there's probably a lot of code out there using
'fromJust'...
1,176 instances of where fromJust is explicitly imported from Data.Maybe
7,431 instances of fromJust mentioned in a Haskell source file
I'm in favour (+1) of the deprecation (warnings) cycle proposal kicked around.
Also if anyone knows of a semantically aware (ie, can distinguish functions, imports, etc.) open source code search tool, I'd be very grateful if they'd point me in that direction.
On 02/24/2015 04:54 AM, Michael Snoyman wrote:
On Tue Feb 24 2015 at 12:47:07 PM Herbert Valerio Riedel <hvr@gnu.org> wrote:
On 2015-02-24 at 06:42:22 +0100, Erik de Castro Lopo wrote:
> 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.
I'm +1 for deprecating (or attach a warning pragma to) 'fromJust' as
I've been bit by 'fromJust' myself in the past, when I was still mixing
up 'fromMaybe' and 'fromJust'. Nowadays I don't reach out for 'fromJust'
anymore at all.
However, I think it'll require a very long deprecation cycle before
actually removing it from base, as 'fromJust' is officially part of
Haskell 2010, and there's probably a lot of code out there using
'fromJust'...
Relatedly, I was thinking of a separate 'partial-functions' warning
class, so we could annotate partial functions (head/last/...) in base,
and have the associated warnings be tunable via a separate GHC -fwarn*
flag. This could even be generalised to arbitrary warning-classes:
{-# WARNING[partial] fromJust "Use 'fromMaybe' instead" #-}
I'm sure we would come up with other useful warning-classes...
This sounds like a great idea, which I'd support fully. The idea of letting people opt-out of partiality warnings somehow would IMO address the concerns here perfectly.
Even though I'm strongly opposed to fromJust, I'm -1 on removing it any time soon due to ensuing breakage. I'm on the fence with a standard deprecation warning (since by what I just said we really *aren't* deprecating it), but a WARNING would be great.
Michael
_______________________________________________ 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