Proposal to deprecate and then drop fromJust

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Tue Feb 24 09:36:33 UTC 2015


Andrew Gibiansky <andrew.gibiansky at gmail.com> writes:

> I am strongly against this, as sometimes you *do* want to use fromJust. For
> example:

What people want isn’t necessarily good language design.

> 1. Quick and dirty scripting/examples where you don't care about
> error-proofing your work and just want it to be done quickly. In that
> context, fromJust is a good function.

but you can have your own library that contains “fromMaybe
undefined” as well as all the other quick and dirty functions
useful for one-off programmes.

> 2. You know by construction that it is a Just constructor. This is usually
> not a good design, but sometimes it's useful. Writing an (error "fromJust")
> is possible, but annoying.

Programming languages accrue all sorts of bad practices from
that sort of argument. Good Haskell programming involves making
the type system move as many errors as possible from run time to
compile time.

> (That said, I do wish that `head` and `tail` were replaced by `headMay` and
> `tailMay`, which you could then use with `fromJust` if you wanted to. But
> that's another discussion for adding things from `safe` to `base`,
> unrelated...)

I’m with you on that.

So I’m +1 on the proposal.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Libraries mailing list