Data.IntMap.Strict.findWithDefault is too strict

Christian Maeder Christian.Maeder at
Fri Dec 14 10:46:46 CET 2012

It makes no sense to evaluate all branches of a case distinction before 
deciding which branch to take. Therefore it is not possible (or more 
difficult) in a strict language to user-define functions like if-then-else.

In fact, I consider findWithDefault to be just an abbreviation for a 
case distinction. Even if the default value is not bottom, it makes no 
sense to evaluate it in the possibly many cases, when it is not used.

The current implementation of strict maps does not work well as a 
replacement for lazy maps and if it does it is less efficient than 
possible, as it possibly evaluates something unneeded or merely checks 
if the default value is already evaluated.


Am 14.12.2012 06:59, schrieb Johan Tibell:
> On Thu, Dec 13, 2012 at 7:11 PM, Daniel Peebles <pumpkingod at> wrote:
>> Even a strict language like scala uses call-by-name arguments for the
>> counterpart to this function in its collections library. It seems to be
>> overstepping the mandate of being a "strict map library" to try to pretend
>> that Haskell is a strict language.
> We already went through all this when we made the decision. I'm not
> really inclined to change the decision unless there's new information
> that should cause us to reconsider it.
> -- Johan

More information about the Libraries mailing list