[commit: containers] master: Updated errorneous documentation. (7b73051)
Ian Lynagh
igloo at earth.li
Thu Feb 23 01:14:46 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/containers
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/7b730517d4e3525b7a823d0d9ff415d1dcc55d71
>---------------------------------------------------------------
commit 7b730517d4e3525b7a823d0d9ff415d1dcc55d71
Author: Milan Straka <fox at ucw.cz>
Date: Wed Nov 23 21:17:20 2011 +0100
Updated errorneous documentation.
Comments to update{Min,Max}[WithKey] were previously taken from
Data.Map and were wrong.
In Data.Map, the update function returns Maybe and possibly removes the
value. But Data.IntMap version returns only the value and cannot cause
the maximum to be removed.
>---------------------------------------------------------------
Data/IntMap/Base.hs | 12 ++++--------
Data/IntMap/Strict.hs | 12 ++++--------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/Data/IntMap/Base.hs b/Data/IntMap/Base.hs
index 5890f14..eeaa72e 100644
--- a/Data/IntMap/Base.hs
+++ b/Data/IntMap/Base.hs
@@ -867,8 +867,7 @@ intersectionWithKey _ _ Nil = Nil
-- | /O(log n)/. Update the value at the minimal key.
--
--- > updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")]
--- > updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+-- > updateMinWithKey (\ k a -> (show k) ++ ":" ++ a) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")]
updateMinWithKey :: (Key -> a -> a) -> IntMap a -> IntMap a
updateMinWithKey f t
@@ -887,8 +886,7 @@ updateMinWithKeyUnsigned f t
-- | /O(log n)/. Update the value at the maximal key.
--
--- > updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")]
--- > updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+-- > updateMaxWithKey (\ k a -> (show k) ++ ":" ++ a) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")]
updateMaxWithKey :: (Key -> a -> a) -> IntMap a -> IntMap a
updateMaxWithKey f t
@@ -951,16 +949,14 @@ minViewUnsigned t
-- | /O(log n)/. Update the value at the maximal key.
--
--- > updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")]
--- > updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+-- > updateMax (\ a -> "X" ++ a) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")]
updateMax :: (a -> a) -> IntMap a -> IntMap a
updateMax f = updateMaxWithKey (const f)
-- | /O(log n)/. Update the value at the minimal key.
--
--- > updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")]
--- > updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+-- > updateMin (\ a -> "X" ++ a) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")]
updateMin :: (a -> a) -> IntMap a -> IntMap a
updateMin f = updateMinWithKey (const f)
diff --git a/Data/IntMap/Strict.hs b/Data/IntMap/Strict.hs
index c49b8a8..a576c08 100644
--- a/Data/IntMap/Strict.hs
+++ b/Data/IntMap/Strict.hs
@@ -590,8 +590,7 @@ intersectionWithKey _ _ Nil = Nil
-- | /O(log n)/. Update the value at the minimal key.
--
--- > updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")]
--- > updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+-- > updateMinWithKey (\ k a -> (show k) ++ ":" ++ a) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")]
updateMinWithKey :: (Key -> a -> a) -> IntMap a -> IntMap a
updateMinWithKey f t
@@ -610,8 +609,7 @@ updateMinWithKeyUnsigned f t
-- | /O(log n)/. Update the value at the maximal key.
--
--- > updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")]
--- > updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+-- > updateMaxWithKey (\ k a -> (show k) ++ ":" ++ a) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")]
updateMaxWithKey :: (Key -> a -> a) -> IntMap a -> IntMap a
updateMaxWithKey f t
@@ -631,16 +629,14 @@ updateMaxWithKeyUnsigned f t
-- | /O(log n)/. Update the value at the maximal key.
--
--- > updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")]
--- > updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+-- > updateMax (\ a -> "X" ++ a) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")]
updateMax :: (a -> a) -> IntMap a -> IntMap a
updateMax f = updateMaxWithKey (const f)
-- | /O(log n)/. Update the value at the minimal key.
--
--- > updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")]
--- > updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+-- > updateMin (\ a -> "X" ++ a) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")]
updateMin :: (a -> a) -> IntMap a -> IntMap a
updateMin f = updateMinWithKey (const f)
More information about the Cvs-libraries
mailing list