Proposal to deprecate and then drop fromJust

Henning Thielemann lemming at
Tue Feb 24 10:39:30 UTC 2015

On Tue, 24 Feb 2015, Joachim Breitner wrote:

> Hi,
> 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.

Yes, there are these cases where the prover capabilities of current 
Haskell are too weak. We should use "fromMaybe (error msg)" in this case. 
The error message could also give inspectors of the code an idea why the 
programmer thinks that the error never occurs.

However, I bet that half of the uses of fromJust on Hackage can be 
replaced by something total.

More information about the Libraries mailing list