Data.IntMap/IntSet inconsistencies

Antoine Latter aslatter at
Mon Nov 2 13:23:47 EST 2009

On Mon, Nov 2, 2009 at 12:14 PM, Evan Laforge <qdunkan at> wrote:
> Also +1.
> On a related note, I think it's unfortunate that those functions are
> partial.  Like List.minimum and maximum, I always wind up wrapping
> them in a function that provides a default value.
> I suppose that would be a different proposal though... but maybe if
> we're breaking compatibility anyway it would be a good time to, say,
> change them to 'IntMap k a -> (k, a) -> (k, a)'?  Actually, it seems
> that often 'IntMap k a -> b -> ((k, a) -> b) -> b' is more convenient,
> e.g. 'findMax fm Nothing Just', and you can always get the default val
> version back with 'id'.

I would prefer that partial functions return 'Maybe' - then I can pick
whether or not I want 'Prelude.maybe' behavior or
'Data.Maybe.fromMaybe' behavior. I would prefer seeing findMax :: Map
k a -> Maybe (k, a).

It's also easier to read the function signature and know what is going
to happen, rather than giving the function three parameters.

But it sounds like we need a different ticket.


More information about the Libraries mailing list