<p dir="ltr">I think this is a great case for the proposed deprecated export feature. Instead of deprecating fromJust, we move it to Data.Maybe.Partial and deprecate its export from Prelude and Data.Maybe.</p>
<div class="gmail_quote">On Feb 24, 2015 2:07 PM, "Chris Allen" <<a href="mailto:cma@bitemyapp.com">cma@bitemyapp.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div 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>On 02/24/2015 04:54 AM, Michael Snoyman
      wrote:<br>
    </div>
    <blockquote 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 href="mailto:hvr@gnu.org" target="_blank">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></fieldset>
      <br>
      <pre>_______________________________________________
Libraries mailing list
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>
</pre>
    </blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div>