[commit: packages/containers] ghc-head: Fix forgotten documentation of Int{Map, Set}.delete{Min, Max}. (2f6484b)

git at git.haskell.org git at git.haskell.org
Fri Aug 30 13:34:35 CEST 2013


Repository : ssh://git@git.haskell.org/containers

On branch  : ghc-head
Link       : http://git.haskell.org/?p=packages/containers.git;a=commit;h=2f6484b44de0236a4a88d63fd5b41213a72f11fa

>---------------------------------------------------------------

commit 2f6484b44de0236a4a88d63fd5b41213a72f11fa
Author: Milan Straka <fox at ucw.cz>
Date:   Wed Nov 21 15:25:26 2012 +0100

    Fix forgotten documentation of Int{Map,Set}.delete{Min,Max}.
    
    These functions used to call error on empty map, but do not so since
    0.5.


>---------------------------------------------------------------

2f6484b44de0236a4a88d63fd5b41213a72f11fa
 Data/IntMap/Base.hs |   12 ++++++++----
 Data/IntSet/Base.hs |   10 ++++++++--
 Data/Set/Base.hs    |    4 ++--
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/Data/IntMap/Base.hs b/Data/IntMap/Base.hs
index 0a54093..ba963f1 100644
--- a/Data/IntMap/Base.hs
+++ b/Data/IntMap/Base.hs
@@ -1125,13 +1125,17 @@ findMax (Bin _ m l r)
           go (Bin _ _ _ r') = go r'
           go Nil            = error "findMax Nil"
 
--- | /O(min(n,W))/. Delete the minimal key. An error is thrown if the IntMap is already empty.
--- Note, this is not the same behavior Map.
+-- | /O(min(n,W))/. Delete the minimal key. Returns an empty map if the map is empty.
+--
+-- Note that this is a change of behaviour for consistency with 'Data.Map.Map' &#8211;
+-- versions prior to 0.5 threw an error if the 'IntMap' was already empty.
 deleteMin :: IntMap a -> IntMap a
 deleteMin = maybe Nil snd . minView
 
--- | /O(min(n,W))/. Delete the maximal key. An error is thrown if the IntMap is already empty.
--- Note, this is not the same behavior Map.
+-- | /O(min(n,W))/. Delete the maximal key. Returns an empty map if the map is empty.
+--
+-- Note that this is a change of behaviour for consistency with 'Data.Map.Map' &#8211;
+-- versions prior to 0.5 threw an error if the 'IntMap' was already empty.
 deleteMax :: IntMap a -> IntMap a
 deleteMax = maybe Nil snd . maxView
 
diff --git a/Data/IntSet/Base.hs b/Data/IntSet/Base.hs
index 7aec215..d674aeb 100644
--- a/Data/IntSet/Base.hs
+++ b/Data/IntSet/Base.hs
@@ -808,11 +808,17 @@ findMax (Bin _ m l r)
           find Nil            = error "findMax Nil"
 
 
--- | /O(min(n,W))/. Delete the minimal element.
+-- | /O(min(n,W))/. Delete the minimal element. Returns an empty set if the set is empty.
+--
+-- Note that this is a change of behaviour for consistency with 'Data.Set.Set' &#8211;
+-- versions prior to 0.5 threw an error if the 'IntSet' was already empty.
 deleteMin :: IntSet -> IntSet
 deleteMin = maybe Nil snd . minView
 
--- | /O(min(n,W))/. Delete the maximal element.
+-- | /O(min(n,W))/. Delete the maximal element. Returns an empty set if the set is empty.
+--
+-- Note that this is a change of behaviour for consistency with 'Data.Set.Set' &#8211;
+-- versions prior to 0.5 threw an error if the 'IntSet' was already empty.
 deleteMax :: IntSet -> IntSet
 deleteMax = maybe Nil snd . maxView
 
diff --git a/Data/Set/Base.hs b/Data/Set/Base.hs
index b664870..3d451b4 100644
--- a/Data/Set/Base.hs
+++ b/Data/Set/Base.hs
@@ -517,13 +517,13 @@ findMax (Bin _ x _ Tip)  = x
 findMax (Bin _ _ _ r)    = findMax r
 findMax Tip              = error "Set.findMax: empty set has no maximal element"
 
--- | /O(log n)/. Delete the minimal element.
+-- | /O(log n)/. Delete the minimal element. Returns an empty set if the set is empty.
 deleteMin :: Set a -> Set a
 deleteMin (Bin _ _ Tip r) = r
 deleteMin (Bin _ x l r)   = balanceR x (deleteMin l) r
 deleteMin Tip             = Tip
 
--- | /O(log n)/. Delete the maximal element.
+-- | /O(log n)/. Delete the maximal element. Returns an empty set if the set is empty.
 deleteMax :: Set a -> Set a
 deleteMax (Bin _ _ l Tip) = l
 deleteMax (Bin _ x l r)   = balanceL x l (deleteMax r)





More information about the ghc-commits mailing list