Data.IntMap/IntSet inconsistencies

Edward Kmett ekmett at gmail.com
Mon Nov 2 11:05:06 EST 2009


+1.

I'm somewhat leery of the interface change on #2, but I thnk consistency is
warranted and the burden of fixing it would only get worse with time.

-Edward Kmett

On Sun, Nov 1, 2009 at 5:00 PM, Twan van Laarhoven <twanvl at gmail.com> wrote:

> The interfaces from Data.IntMap and Data.Map are subtly different. Here are
> two issues:
>
>
> 1. deleteMin/Max raise an exception on empty maps/set
>
>    > Data.Map.deleteMax Data.Map.empty
>    fromList []
>    > Data.IntMap.deleteMax Data.IntMap.empty
>    fromList *** Exception: deleteMax: empty map has no maximal element
>
>    > Data.Set.deleteMin Data.Set.empty
>    fromList []
>    > Data.IntSet.deleteMin Data.IntSet.empty
>    fromList *** Exception: deleteMin: empty set has no minimal element
>
> Proposal: Data.IntMap/IntSet.deleteMin/Max should return empty when the
> input is empty.
>
>
> 2. findMin/Max have a different signature
>
>    Data.Map.findMin :: Map k a -> (k, a)
>    Data.IntMap.findMin :: IntMap a -> a
>
> The documentation of IntMap.findMin is also incorrect, it reads:
>
>    /O(log n)/ The minimal key of the map.
>
> While it returns the value associated with the minimal key.
>
> Proposal: Data.IntMap.findMin/findMax should have the type  IntMap a ->
> (Key,a)
>
>
>
> Twan
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20091102/15b01382/attachment.html


More information about the Libraries mailing list