<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<blockquote>However, I think it'll require a very long deprecation
cycle before<br>
actually removing it from base, as 'fromJust' is officially part
of<br>
Haskell 2010, and there's probably a lot of code out there using<br>
'fromJust'...<br>
</blockquote>
Terrifyingly, yes. I fired off a shell-script to cabal unpack all
the libraries on Hackage last night and some cursory grepping has
brought me:<br>
<br>
1,176 instances of where fromJust is explicitly imported from
Data.Maybe<br>
7,431 instances of fromJust mentioned in a Haskell source file<br>
<br>
I'm in favour (+1) of the deprecation (warnings) cycle proposal
kicked around.<br>
<br>
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.<br>
<br>
<br>
<div class="moz-cite-prefix">On 02/24/2015 04:54 AM, Michael Snoyman
wrote:<br>
</div>
<blockquote
cite="mid:CAKA2Jg+P8G8RB_iqFLGGPE1miHkr0p0P9tRVJ6AEMr-vTsyaMQ@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<br>
<div class="gmail_quote">On Tue Feb 24 2015 at 12:47:07 PM
Herbert Valerio Riedel <<a moz-do-not-send="true"
href="mailto:hvr@gnu.org">hvr@gnu.org</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">On
2015-02-24 at 06:42:22 +0100, Erik de Castro Lopo wrote:<br>
> We currently have in the Data.Maybe module from base:<br>
><br>
> fromJust :: Maybe a -> a<br>
><br>
> which newbies often find using hoogle or other search
tools and is<br>
> a huge trap. *Every* usage of the above can be replaced
by using<br>
><br>
> fromMaybe :: a -> Maybe a -> a<br>
><br>
> which forces the user to provide a default value for
the case where<br>
> the Maybe a is a Nothing.<br>
><br>
> The idea would be to deprecate fromMaybe for 7.12 and
remove it<br>
> completely later.<br>
<br>
I'm +1 for deprecating (or attach a warning pragma to)
'fromJust' as<br>
I've been bit by 'fromJust' myself in the past, when I was
still mixing<br>
up 'fromMaybe' and 'fromJust'. Nowadays I don't reach out
for 'fromJust'<br>
anymore at all.<br>
<br>
However, I think it'll require a very long deprecation cycle
before<br>
actually removing it from base, as 'fromJust' is officially
part of<br>
Haskell 2010, and there's probably a lot of code out there
using<br>
'fromJust'...<br>
<br>
Relatedly, I was thinking of a separate 'partial-functions'
warning<br>
class, so we could annotate partial functions
(head/last/...) in base,<br>
and have the associated warnings be tunable via a separate
GHC -fwarn*<br>
flag. This could even be generalised to arbitrary
warning-classes:<br>
<br>
{-# WARNING[partial] fromJust "Use 'fromMaybe' instead" #-}<br>
<br>
I'm sure we would come up with other useful
warning-classes...<br>
<br>
<br>
</blockquote>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Michael </div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Libraries mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Libraries@haskell.org">Libraries@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>
</pre>
</blockquote>
<br>
</body>
</html>