Proposal to deprecate and then drop fromJust

Joachim Breitner mail at
Tue Feb 24 10:19:44 UTC 2015


Am Dienstag, den 24.02.2015, 11:14 +0100 schrieb Henning Thielemann:
> On Tue, 24 Feb 2015, Ivan Lazar Miljenovic wrote:
> > I've used fromJust in the past when I knew the value would be Just by
> > construction.
> If you know that the value is always Just by construction, why don't you 
> express this with the types, i.e. by turning from 'Maybe a' to 'a'?

Not everything can be expressed with types.

Example: You build a graph data structure around Data.Map. Your abstract
interface makes sure that in your graph, you only reference nodes that
are in the domain of the map. So it is reasonable to use "fromJust
(M.lookup key map)"¹ internally.

The Maybe is part of another packages interface, and rightly so – how
would you get rid of it?

(In this case, one could argue that you should write
    fromMaybe (error "I broke the graph")..."
but it still refutes the argument that you can always replace "Maybe a"
by "a" if you know that it is a Just anyways.)


¹ Yes, this is also "map M.! key" – which, if we were consistent, needs
to be deprecated as well.

Joachim “nomeata” Breitner
  mail at joachim-breitner.de
  Jabber: nomeata at  • GPG-Key: 0xF0FBF51F
  Debian Developer: nomeata at

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the Libraries mailing list