Minor containers API changes

Henning Thielemann lemming at henning-thielemann.de
Mon Nov 28 17:53:32 CET 2011

On Mon, 28 Nov 2011, Milan Straka wrote:

> First five are an attempt to unify the API of different structures. The
> documentation states IntMap is Map replacement and IntSet is Set
> replacement, but there are several shortcomings:
> 1) `{Map,Set}.deleteMin empty` return `empty`
>   `{IntMap,IntSet}.deleteMin empty` trigger `error "Cannot delete in empty..."`
>   Solutions: (a) make `{Map,Set}.deleteMin empty` throw error
>              (b) make `{IntMap,IntSet}.deleteMin empty` return empty
>   I vote for (b), because (a) could cause unexpected runtime errors.
>   Additionally, I expect very little programs depend on
>   `{IntMap,IntSet}.deleteMin empty` causing runtime error.

I would like that it is consistent with Map.delete on an empty set.

Prelude> Map.delete undefined Map.empty :: Map.Map Char Int
fromList []

Looks like a vote for (b).

More information about the Libraries mailing list