Proposal to deprecate and then drop fromJust

Sean Leather sean.leather at
Tue Feb 24 09:34:17 UTC 2015

On Tue, Feb 24, 2015 at 7:42 AM, 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 in favor of removing partial functions from standard libraries because,
no matter how convenient they might be in circumstances where they are
“obviously” not partial, there will always be other cases where they
shouldn't have been used in the first place.

Back when I was dabbling in Scala, I asked a question about why the Scala
equivalent of `fromJust` was in the standard library [1]. One of the
interesting but baffling responses was that Scala was a partial language so
there *must* [2] be partial functions in the standard library. I suppose
the same argument could be made about Haskell.

My thought is that partiality should be a last resort. It's already
convenient enough to use `error` or `undefined`, and bottom should not be
“hidden” in unexpected places but upfront and in my face.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list