New patches:
[Improved, fixed documentation, some minor issues for Data.Map, Data.IntMap. Added examples.
apa3a@yahoo.com**20080204184756] {
hunk ./Data/IntMap.hs 6
+ (c) Andriy Palamarchuk 2008
hunk ./Data/IntMap.hs 34
+ Operation comments contain the operation time complexity in
+ the BigO notation .
hunk ./Data/IntMap.hs 223
+
+ > fromList [(5,'a'), (3,'b')] ! 1 Error: element not in the map
+ > fromList [(5,'a'), (3,'b')] ! 5 == 'a'
hunk ./Data/IntMap.hs 230
  /O(n+m)/. See 'difference'.
+  Same as 'difference'.
hunk ./Data/IntMap.hs 278
+
+ > Data.IntMap.null (empty) == True
+ > Data.IntMap.null (singleton 1 'a') == False
+
hunk ./Data/IntMap.hs 287
+
+ > size empty == 0
+ > size (singleton 1 'a') == 1
+ > size (fromList([(1,'a'), (2,'c'), (3,'b')])) == 3
hunk ./Data/IntMap.hs 299
+
+ > member 5 (fromList [(5,'a'), (3,'b')]) == True
+ > member 1 (fromList [(5,'a'), (3,'b')]) == False
+
hunk ./Data/IntMap.hs 310
+
+ > notMember 5 (fromList [(5,'a'), (3,'b')]) == False
+ > notMember 1 (fromList [(5,'a'), (3,'b')]) == True
+
hunk ./Data/IntMap.hs 317
  /O(min(n,W))/. Lookup the value at a key in the map.
+  /O(min(n,W))/. Lookup the value at a key in the map. See also 'Data.Map.lookup'.
hunk ./Data/IntMap.hs 348
+
+ > findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x'
+ > findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'
+
hunk ./Data/IntMap.hs 362
+
+ > empty == fromList []
+ > size empty == 0
+
hunk ./Data/IntMap.hs 371
+
+ > singleton 1 'a' == fromList [(1, 'a')]
+ > size (singleton 1 'a') == 1
+
hunk ./Data/IntMap.hs 386
+
+ > insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')]
+ > insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')]
+ > insert 5 'x' empty == singleton 5 'x'
+
hunk ./Data/IntMap.hs 409
+
+ > insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")]
+ > insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]
+ > insertWith (++) 5 "xxx" empty == singleton 5 "xxx"
+
hunk ./Data/IntMap.hs 423
+
+ > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "" ++ old_value
+ > insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxxa")]
+ > insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]
+ > insertWithKey f 5 "xxx" empty == singleton 5 "xxx"
+
hunk ./Data/IntMap.hs 445
+
+ > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "" ++ old_value
+ > insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxxa")])
+ > insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")])
+ > insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx")
+
+ This is how to define @insertLookup@ using @insertLookupWithKey@:
+
+ > let insertLookup kx x t = insertLookupWithKey (\_ a _ > a) kx x t
+ > insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")])
+ > insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])
+
hunk ./Data/IntMap.hs 476
+
+ > delete 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+ > delete 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > delete 5 empty == empty
+
hunk ./Data/IntMap.hs 495
+
+ > adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]
+ > adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > adjust ("new " ++) 7 empty == empty
+
hunk ./Data/IntMap.hs 506
+
+ > let f key x = (show key) ++ ":new " ++ x
+ > adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]
+ > adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > adjustWithKey f 7 empty == empty
+
hunk ./Data/IntMap.hs 519
+
+ > let f x = if x == "a" then Just "new a" else Nothing
+ > update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]
+ > update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+
hunk ./Data/IntMap.hs 532
+
+ > let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing
+ > updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]
+ > updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+
hunk ./Data/IntMap.hs 553
+ The function returns original value, if it is updated.
+ This is different behavior than 'Data.Map.updateLookupWithKey'.
+ Returns the original key value if the map entry is deleted.
+
+ > let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing
+ > updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:new a")])
+ > updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a")])
+ > updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a")
+
hunk ./Data/IntMap.hs 580
 In short : @'lookup' k ('alter' f k m) = f ('lookup' k m)@
+ In short : @'lookup' k ('alter' f k m) = f ('lookup' k m)@.
hunk ./Data/IntMap.hs 605
+
+ > unions [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
+ > == fromList [(3, "b"), (5, "a"), (7, "C")]
+ > unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])]
+ > == fromList [(3, "B3"), (5, "A3"), (7, "C")]
+
hunk ./Data/IntMap.hs 615
  The union of a list of maps, with a combining operation
+  The union of a list of maps, with a combining operation.
+
+ > unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
+ > == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]
+
hunk ./Data/IntMap.hs 624
  /O(n+m)/. The (leftbiased) union of two maps.
+  /O(n+m)/. The (leftbiased) union of two maps.
hunk ./Data/IntMap.hs 627
+
+ > union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")]
+
hunk ./Data/IntMap.hs 650
  /O(n+m)/. The union with a combining function.
+  /O(n+m)/. The union with a combining function.
+
+ > unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]
+
hunk ./Data/IntMap.hs 658
  /O(n+m)/. The union with a combining function.
+  /O(n+m)/. The union with a combining function.
+
+ > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "" ++ old_value
+ > unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:aA"), (7, "C")]
+
hunk ./Data/IntMap.hs 686
  /O(n+m)/. Difference between two maps (based on keys).
+  /O(n+m)/. Difference between two maps (based on keys).
+
+ > difference (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 3 "b"
+
hunk ./Data/IntMap.hs 713
  /O(n+m)/. Difference with a combining function.
+  /O(n+m)/. Difference with a combining function.
+
+ > let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing
+ > differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")])
+ > == singleton 3 "b:B"
+
hunk ./Data/IntMap.hs 727
+
+ > let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "" ++ ar) else Nothing
+ > differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")])
+ > == singleton 3 "3:bB"
+
hunk ./Data/IntMap.hs 762
  /O(n+m)/. The (leftbiased) intersection of two maps (based on keys).
+  /O(n+m)/. The (leftbiased) intersection of two maps (based on keys).
+
+ > intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"
+
hunk ./Data/IntMap.hs 791
  /O(n+m)/. The intersection with a combining function.
+  /O(n+m)/. The intersection with a combining function.
+
+ > intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"
+
hunk ./Data/IntMap.hs 799
  /O(n+m)/. The intersection with a combining function.
+  /O(n+m)/. The intersection with a combining function.
+
+ > let f k al ar = (show k) ++ ":" ++ al ++ "" ++ ar
+ > intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:aA"
+
hunk ./Data/IntMap.hs 836
+
+ > 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"
+
hunk ./Data/IntMap.hs 854
+
+ > 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"
+
hunk ./Data/IntMap.hs 874
+
+ > v < maxViewWithKey (fromList [(5,"a"), (3,"b")])
+ > v == ((5,"a"), singleton 3 "b")
+ > maxViewWithKey empty Error: empty map
+
hunk ./Data/IntMap.hs 885
 Nil > fail "maxView: empty map has no maximal element"
+ Nil > fail "maxViewWithKey: empty map has no maximal element"
hunk ./Data/IntMap.hs 894
+
+ > v < minViewWithKey (fromList [(5,"a"), (3,"b")])
+ > v == ((3,"b"), singleton 5 "a")
+ > minViewWithKey empty Error: empty map
+
hunk ./Data/IntMap.hs 905
 Nil > fail "minView: empty map has no minimal element"
+ Nil > fail "minViewWithKey: empty map has no minimal element"
hunk ./Data/IntMap.hs 914
+
+ > 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"
+
hunk ./Data/IntMap.hs 922
+
+ > 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"
+
hunk ./Data/IntMap.hs 1029
{  /O(n+m)/.
+{  /O(n+m)/.
hunk ./Data/IntMap.hs 1045

hunk ./Data/IntMap.hs 1061
+
+ > map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]
+
hunk ./Data/IntMap.hs 1069
+
+ > let f key x = (show key) ++ ":" ++ x
+ > mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]
+
hunk ./Data/IntMap.hs 1082
+
+ > let f a b = (a ++ b, b ++ "X")
+ > mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])
+
hunk ./Data/IntMap.hs 1092
+
+ > let f a k b = (a ++ " " ++ (show k) ++ "" ++ b, b ++ "X")
+ > mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3b 5a", fromList [(3, "bX"), (5, "aX")])
+
hunk ./Data/IntMap.hs 1127
+
+ > filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+ > filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty
+ > filter (< "a") (fromList [(5,"a"), (3,"b")]) == empty
+
hunk ./Data/IntMap.hs 1137
+
+ > filterWithKey (\k _ > k > 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+
hunk ./Data/IntMap.hs 1150
  /O(n)/. partition the map according to some predicate. The first
+  /O(n)/. Partition the map according to some predicate. The first
hunk ./Data/IntMap.hs 1153
+
+ > partition (> "a") (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")
+ > partition (< "x") (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty)
+ > partition (> "x") (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])
+
hunk ./Data/IntMap.hs 1162
  /O(n)/. partition the map according to some predicate. The first
+  /O(n)/. Partition the map according to some predicate. The first
hunk ./Data/IntMap.hs 1165
+
+ > partitionWithKey (\ k _ > k > 3) (fromList [(5,"a"), (3,"b")]) == (singleton 5 "a", singleton 3 "b")
+ > partitionWithKey (\ k _ > k < 7) (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty)
+ > partitionWithKey (\ k _ > k > 7) (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])
+
hunk ./Data/IntMap.hs 1183
+
+ > let f x = if x == "a" then Just "new a" else Nothing
+ > mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"
+
hunk ./Data/IntMap.hs 1192
+
+ > let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing
+ > mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"
+
hunk ./Data/IntMap.hs 1205
+
+ > let f a = if a < "c" then Left a else Right a
+ > mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
+ > == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")])
+ >
+ > mapEither (\ a > Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
+ > == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
+
hunk ./Data/IntMap.hs 1218
+
+ > let f k a = if k < 5 then Left (k * 2) else Right (a ++ a)
+ > mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
+ > == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")])
+ >
+ > mapEitherWithKey (\_ a > Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
+ > == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")])
+
hunk ./Data/IntMap.hs 1240
+
+ > split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")])
+ > split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a")
+ > split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")
+ > split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty)
+ > split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty)
+
hunk ./Data/IntMap.hs 1276
+
+ > splitLookup 2 (fromList [(5,"a"), (3,"b")]) == (empty, Nothing, fromList [(3,"b"), (5,"a")])
+ > splitLookup 3 (fromList [(5,"a"), (3,"b")]) == (empty, Just "b", singleton 5 "a")
+ > splitLookup 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Nothing, singleton 5 "a")
+ > splitLookup 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Just "a", empty)
+ > splitLookup 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], Nothing, empty)
+
hunk ./Data/IntMap.hs 1319
+ > let f a len = len + (length a)
+ > fold f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
+
hunk ./Data/IntMap.hs 1332
+ > let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"
+ > foldWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"
+
hunk ./Data/IntMap.hs 1361
+
+ > elems (fromList [(5,"a"), (3,"b")]) == ["b","a"]
+ > elems empty == []
+
hunk ./Data/IntMap.hs 1370
+
+ > keys (fromList [(5,"a"), (3,"b")]) == [3,5]
+ > keys empty == []
+
hunk ./Data/IntMap.hs 1379
+
+ > keysSet (fromList [(5,"a"), (3,"b")]) == Data.IntSet.fromList [3,5]
+ > keysSet empty == Data.IntSet.empty
+
hunk ./Data/IntMap.hs 1388
+
+ > assocs (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
+ > assocs empty == []
+
hunk ./Data/IntMap.hs 1401
+
+ > toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
+ > toList empty == []
+
hunk ./Data/IntMap.hs 1411
+
+ > toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
+
hunk ./Data/IntMap.hs 1420
+
+ > fromList [] == empty
+ > fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
+ > fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
+
hunk ./Data/IntMap.hs 1431
  /O(n*min(n,W))/. Create a map from a list of key\/value pairs with a combining function. See also 'fromAscListWith'.
+  /O(n*min(n,W))/. Create a map from a list of key\/value pairs with a combining function. See also 'fromAscListWith'.
+
+ > fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]
+ > fromListWith (++) [] == empty
+
hunk ./Data/IntMap.hs 1440
  /O(n*min(n,W))/. Build a map from a list of key\/value pairs with a combining function. See also fromAscListWithKey'.
+  /O(n*min(n,W))/. Build a map from a list of key\/value pairs with a combining function. See also fromAscListWithKey'.
+
+ > fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]
+ > fromListWith (++) [] == empty
+
hunk ./Data/IntMap.hs 1453
+
+ > fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
+ > fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")]
+
hunk ./Data/IntMap.hs 1463
+
+ > fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]
+
hunk ./Data/IntMap.hs 1472
+
+ > fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]
+
hunk ./Data/IntMap.hs 1481
+
+ > fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
+
hunk ./Data/Map.hs 7
+ (c) Andriy Palamarchuk 2008
hunk ./Data/Map.hs 35
+
+ Operation comments contain the operation time complexity in
+ the BigO notation .
hunk ./Data/Map.hs 99
 , mapKeys
 , mapKeysWith
 , mapKeysMonotonic
+ , mapKeys
+ , mapKeysWith
+ , mapKeysMonotonic
hunk ./Data/Map.hs 110
 , keysSet
+ , keysSet
hunk ./Data/Map.hs 203
+
+ > fromList [(5,'a'), (3,'b')] ! 1 Error: element not in the map
+ > fromList [(5,'a'), (3,'b')] ! 5 == 'a'
+
hunk ./Data/Map.hs 210
  /O(n+m)/. See 'difference'.
+  Same as 'difference'.
hunk ./Data/Map.hs 250
+
+ > Data.Map.null (empty) == True
+ > Data.Map.null (singleton 1 'a') == False
+
hunk ./Data/Map.hs 261
+
+ > size empty == 0
+ > size (singleton 1 'a') == 1
+ > size (fromList([(1,'a'), (2,'c'), (3,'b')])) == 3
+
hunk ./Data/Map.hs 273
  /O(log n)/. Lookup the value at a key in the map.
+  /O(log n)/. Lookup the value at a key in the map.
hunk ./Data/Map.hs 279
+
+ > let m = fromList [(5,'a'), (3,'b'), (7,'c')]
+ > value1 < Data.Map.lookup 5 m
+ > value1
+ > 'a'
+ > value2 < Data.Map.lookup 1 m
+ > Error: Key not found
+
+ An example of using @lookup@ with @Maybe@ monad:
+
+ > import Prelude hiding (lookup)
+ > import Data.Map
+ >
+ > employeeDept = fromList([("John","Sales"), ("Bob","IT")])
+ > deptCountry = fromList([("IT","USA"), ("Sales","France")])
+ > countryCurrency = fromList([("USA", "Dollar"), ("France", "Euro")])
+ >
+ > employeeCurrency :: String > Maybe String
+ > employeeCurrency name = do
+ > dept < lookup name employeeDept
+ > country < lookup dept deptCountry
+ > lookup country countryCurrency
+ >
+ > main = do
+ > putStrLn $ "John's currency: " ++ (show (employeeCurrency "John"))
+ > putStrLn $ "Pete's currency: " ++ (show (employeeCurrency "Pete"))
+
+ The output of this program:
+
+ > John's currency: Just "Euro"
+ > Pete's currency: Nothing
+
hunk ./Data/Map.hs 335
  /O(log n)/. Is the key a member of the map?
+  /O(log n)/. Is the key a member of the map? See also 'notMember'.
+
+ > member 5 (fromList [(5,'a'), (3,'b')]) == True
+ > member 1 (fromList [(5,'a'), (3,'b')]) == False
+
hunk ./Data/Map.hs 346
  /O(log n)/. Is the key not a member of the map?
+  /O(log n)/. Is the key not a member of the map? See also 'member'.
+
+ > notMember 5 (fromList [(5,'a'), (3,'b')]) == False
+ > notMember 1 (fromList [(5,'a'), (3,'b')]) == True
+
hunk ./Data/Map.hs 363
 the value at key @k@ or returns @def@ when the key is not in the map.
+ the value at key @k@ or returns default value @def@
+ when the key is not in the map.
+
+ > findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x'
+ > findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'
+
hunk ./Data/Map.hs 381
+
+ > empty == fromList []
+ > size empty == 0
+
hunk ./Data/Map.hs 390
+
+ > singleton 1 'a' == fromList [(1, 'a')]
+ > size (singleton 1 'a') == 1
+
hunk ./Data/Map.hs 403
 replaced with the supplied value, i.e. 'insert' is equivalent to
+ replaced with the supplied value. 'insert' is equivalent to
hunk ./Data/Map.hs 405
+
+ > insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')]
+ > insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')]
+ > insert 5 'x' empty == singleton 5 'x'
+
hunk ./Data/Map.hs 420
  /O(log n)/. Insert with a combining function.
+  /O(log n)/. Insert with a function, combining new value and old value.
hunk ./Data/Map.hs 425
+
+ > insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")]
+ > insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]
+ > insertWith (++) 5 "xxx" empty == singleton 5 "xxx"
+
hunk ./Data/Map.hs 440
  /O(log n)/. Insert with a combining function.
+  /O(log n)/. Insert with a function, combining key, new value and old value.
hunk ./Data/Map.hs 446
+
+ > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "" ++ old_value
+ > insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxxa")]
+ > insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]
+ > insertWithKey f 5 "xxx" empty == singleton 5 "xxx"
+
hunk ./Data/Map.hs 474
  /O(log n)/. The expression (@'insertLookupWithKey' f k x map@)
+  /O(log n)/. Combines insert operation with old value retrieval.
+ The expression (@'insertLookupWithKey' f k x map@)
hunk ./Data/Map.hs 478
+
+ > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "" ++ old_value
+ > insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxxa")])
+ > insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")])
+ > insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx")
+
+ This is how to define @insertLookup@ using @insertLookupWithKey@:
+
+ > let insertLookup kx x t = insertLookupWithKey (\_ a _ > a) kx x t
+ > insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")])
+ > insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])
+
hunk ./Data/Map.hs 506
+
+ > delete 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+ > delete 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > delete 5 empty == empty
+
hunk ./Data/Map.hs 521
  /O(log n)/. Adjust a value at a specific key. When the key is not
+  /O(log n)/. Update a value at a specific key with the result of the provided function.
+ When the key is not
hunk ./Data/Map.hs 524
+
+ > adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]
+ > adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > adjust ("new " ++) 7 empty == empty
+
hunk ./Data/Map.hs 535
+
+ > let f key x = (show key) ++ ":new " ++ x
+ > adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]
+ > adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > adjustWithKey f 7 empty == empty
+
hunk ./Data/Map.hs 548
+
+ > let f x = if x == "a" then Just "new a" else Nothing
+ > update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]
+ > update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+
hunk ./Data/Map.hs 562
+
+ > let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing
+ > updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]
+ > updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+
hunk ./Data/Map.hs 580
  /O(log n)/. Lookup and update.
+  /O(log n)/. Lookup and update. See also 'updateWithKey'.
+ The function returns changed value, if it is updated.
+ Returns the original key value if the map entry is deleted.
+
+ > let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing
+ > updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "5:new a", fromList [(3, "b"), (5, "5:new a")])
+ > updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a")])
+ > updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a")
+
hunk ./Data/Map.hs 603
 In short : @'lookup' k ('alter' f k m) = f ('lookup' k m)@
+ In short : @'lookup' k ('alter' f k m) = f ('lookup' k m)@.
+
+ > let f _ = Nothing
+ > alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
+ > alter f 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+ >
+ > let f _ = Just "c"
+ > alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "c")]
+ > alter f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "c")]
+
hunk ./Data/Map.hs 633
+
+ > findIndex 2 (fromList [(5,"a"), (3,"b")]) Error: element is not in the map
+ > findIndex 3 (fromList [(5,"a"), (3,"b")]) == 0
+ > findIndex 5 (fromList [(5,"a"), (3,"b")]) == 1
+ > findIndex 6 (fromList [(5,"a"), (3,"b")]) Error: element is not in the map
+
hunk ./Data/Map.hs 646
 /0/ up to, but not including, the 'size' of the map.
+ /0/ up to, but not including, the 'size' of the map.
+
+ > isJust (lookupIndex 2 (fromList [(5,"a"), (3,"b")])) == False
+ > fromJust (lookupIndex 3 (fromList [(5,"a"), (3,"b")])) == 0
+ > fromJust (lookupIndex 5 (fromList [(5,"a"), (3,"b")])) == 1
+ > isJust (lookupIndex 6 (fromList [(5,"a"), (3,"b")])) == False
+
hunk ./Data/Map.hs 667
+
+ > elemAt 0 (fromList [(5,"a"), (3,"b")]) == (3,"b")
+ > elemAt 1 (fromList [(5,"a"), (3,"b")]) == (5, "a")
+ > elemAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range
+
hunk ./Data/Map.hs 684
+
+ > updateAt (\ _ _ > Just "x") 0 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "x"), (5, "a")]
+ > updateAt (\ _ _ > Just "x") 1 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "x")]
+ > updateAt (\ _ _ > Just "x") 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range
+ > updateAt (\ _ _ > Just "x") (1) (fromList [(5,"a"), (3,"b")]) Error: index out of range
+ > updateAt (\_ _ > Nothing) 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+ > updateAt (\_ _ > Nothing) 1 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+ > updateAt (\_ _ > Nothing) 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range
+ > updateAt (\_ _ > Nothing) (1) (fromList [(5,"a"), (3,"b")]) Error: index out of range
+
hunk ./Data/Map.hs 708
+
+ > deleteAt 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+ > deleteAt 1 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+ > deleteAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range
+ > deleteAt (1) (fromList [(5,"a"), (3,"b")]) Error: index out of range
+
hunk ./Data/Map.hs 722
  /O(log n)/. The minimal key of the map.
+  /O(log n)/. The minimal key of the map. Calls 'error' is the map is empty.
+
+ > findMin (fromList [(5,"a"), (3,"b")]) == (3,"b")
+ > findMin empty Error: empty map has no minimal element
+
hunk ./Data/Map.hs 732
  /O(log n)/. The maximal key of the map.
+  /O(log n)/. The maximal key of the map. Calls 'error' is the map is empty.
+
+ > findMax (fromList [(5,"a"), (3,"b")]) == (5,"a")
+ > findMax empty Error: empty map has no maximal element
+
hunk ./Data/Map.hs 742
  /O(log n)/. Delete the minimal key.
+  /O(log n)/. Delete the minimal key. Returns an empty map if the map is empty.
+
+ > deleteMin (fromList [(5,"a"), (3,"b"), (7,"c")]) == fromList [(5,"a"), (7,"c")]
+ > deleteMin empty == empty
+
hunk ./Data/Map.hs 752
  /O(log n)/. Delete the maximal key.
+  /O(log n)/. Delete the maximal key. Returns an empty map if the map is empty.
+
+ > deleteMax (fromList [(5,"a"), (3,"b"), (7,"c")]) == fromList [(3,"b"), (5,"a")]
+ > deleteMax empty == empty
+
hunk ./Data/Map.hs 763
+
+ > 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"
+
hunk ./Data/Map.hs 772
+
+ > 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"
+
hunk ./Data/Map.hs 782
+
+ > 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"
+
hunk ./Data/Map.hs 796
+
+ > 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"
+
hunk ./Data/Map.hs 811
+
+ > v < minViewWithKey (fromList [(5,"a"), (3,"b")])
+ > v == ((3,"b"), singleton 5 "a")
+ > minViewWithKey empty Error: empty map
+
hunk ./Data/Map.hs 817
minViewWithKey Tip = fail "Map.minView: empty map"
+minViewWithKey Tip = fail "Map.minViewWithKey: empty map"
hunk ./Data/Map.hs 822
+
+ > v < maxViewWithKey (fromList [(5,"a"), (3,"b")])
+ > v == ((5,"a"), singleton 3 "b")
+ > maxViewWithKey empty Error: empty map
+
hunk ./Data/Map.hs 828
maxViewWithKey Tip = fail "Map.maxView: empty map"
+maxViewWithKey Tip = fail "Map.maxViewWithKey: empty map"
hunk ./Data/Map.hs 833
+
+ > v < minView (fromList [(5,"a"), (3,"b")])
+ > v == ("b", singleton 5 "a")
+ > minView empty Error: empty map
+
hunk ./Data/Map.hs 844
+
+ > v < maxView (fromList [(5,"a"), (3,"b")])
+ > v == ("a", singleton 3 "b")
+ > maxView empty Error: empty map
+
hunk ./Data/Map.hs 862
+
+ > unions [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
+ > == fromList [(3, "b"), (5, "a"), (7, "C")]
+ > unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])]
+ > == fromList [(3, "B3"), (5, "A3"), (7, "C")]
+
hunk ./Data/Map.hs 874
+
+ > unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
+ > == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]
+
hunk ./Data/Map.hs 887
 Hedgeunion is more efficient on (bigset `union` smallset)
+ Hedgeunion is more efficient on (bigset \``union`\` smallset).
+
+ > union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")]
+
hunk ./Data/Map.hs 927
+
+ > unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]
+
hunk ./Data/Map.hs 936
 Hedgeunion is more efficient on (bigset `union` smallset).
+ Hedgeunion is more efficient on (bigset \``union`\` smallset).
+
+ > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "" ++ old_value
+ > unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:aA"), (7, "C")]
+
hunk ./Data/Map.hs 965
+ Return elements of the first map not existing in the second map.
hunk ./Data/Map.hs 967
+
+ > difference (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 3 "b"
+
hunk ./Data/Map.hs 986
+ When two equal keys are
+ encountered, the combining function is applied to the values of these keys.
+ If it returns 'Nothing', the element is discarded (proper set difference). If
+ it returns (@'Just' y@), the element is updated with a new value @y@.
hunk ./Data/Map.hs 991
+
+ > let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing
+ > differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")])
+ > == singleton 3 "b:B"
+
hunk ./Data/Map.hs 1005
+
+ > let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "" ++ ar) else Nothing
+ > differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")])
+ > == singleton 3 "3:bB"
+
hunk ./Data/Map.hs 1038
  /O(n+m)/. Intersection of two maps. The values in the first
 map are returned, i.e. (@'intersection' m1 m2 == 'intersectionWith' 'const' m1 m2@).
+  /O(n+m)/. Intersection of two maps.
+ Return data in the first map for the keys existing in both maps.
+ (@'intersection' m1 m2 == 'intersectionWith' 'const' m1 m2@).
+
+ > intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"
+
hunk ./Data/Map.hs 1049
+
+ > intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"
+
hunk ./Data/Map.hs 1057
 Intersection is more efficient on (bigset `intersection` smallset)
+ Intersection is more efficient on (bigset \``intersection`\` smallset).
+
+ > let f k al ar = (show k) ++ ":" ++ al ++ "" ++ ar
+ > intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:aA"
+
hunk ./Data/Map.hs 1078

hunk ./Data/Map.hs 1101
  /O(n+m)/.
+  /O(n+m)/.
hunk ./Data/Map.hs 1103
+
hunk ./Data/Map.hs 1108
{  /O(n+m)/.
+{  /O(n+m)/.
hunk ./Data/Map.hs 1123
+
+
hunk ./Data/Map.hs 1160
+
+
hunk ./Data/Map.hs 1171
+
+ > filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
+ > filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty
+ > filter (< "a") (fromList [(5,"a"), (3,"b")]) == empty
+
hunk ./Data/Map.hs 1181
+
+ > filterWithKey (\k _ > k > 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
+
hunk ./Data/Map.hs 1191
  /O(n)/. partition the map according to a predicate. The first
+  /O(n)/. Partition the map according to a predicate. The first
hunk ./Data/Map.hs 1194
+
+ > partition (> "a") (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")
+ > partition (< "x") (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty)
+ > partition (> "x") (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])
+
hunk ./Data/Map.hs 1203
  /O(n)/. partition the map according to a predicate. The first
+  /O(n)/. Partition the map according to a predicate. The first
hunk ./Data/Map.hs 1206
+
+ > partitionWithKey (\ k _ > k > 3) (fromList [(5,"a"), (3,"b")]) == (singleton 5 "a", singleton 3 "b")
+ > partitionWithKey (\ k _ > k < 7) (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty)
+ > partitionWithKey (\ k _ > k > 7) (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])
+
hunk ./Data/Map.hs 1221
+
+ > let f x = if x == "a" then Just "new a" else Nothing
+ > mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"
+
hunk ./Data/Map.hs 1230
+
+ > let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing
+ > mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"
+
hunk ./Data/Map.hs 1241
+
+ > let f a = if a < "c" then Left a else Right a
+ > mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
+ > == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")])
+ >
+ > mapEither (\ a > Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
+ > == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
+
hunk ./Data/Map.hs 1254
+
+ > let f k a = if k < 5 then Left (k * 2) else Right (a ++ a)
+ > mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
+ > == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")])
+ >
+ > mapEitherWithKey (\_ a > Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
+ > == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")])
+
hunk ./Data/Map.hs 1276
+
+ > map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]
+
hunk ./Data/Map.hs 1284
+
+ > let f key x = (show key) ++ ":" ++ x
+ > mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]
+
hunk ./Data/Map.hs 1295
+
+ > let f a b = (a ++ b, b ++ "X")
+ > mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])
+
hunk ./Data/Map.hs 1305
+
+ > let f a k b = (a ++ " " ++ (show k) ++ "" ++ b, b ++ "X")
+ > mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3b 5a", fromList [(3, "bX"), (5, "aX")])
+
hunk ./Data/Map.hs 1337
  /O(n*log n)/.
+  /O(n*log n)/.
hunk ./Data/Map.hs 1343
+
+ > mapKeys (+ 1) (fromList [(5,"a"), (3,"b")]) == fromList [(4, "b"), (6, "a")]
+ > mapKeys (\ _ > 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "c"
+ > mapKeys (\ _ > 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "c"
hunk ./Data/Map.hs 1351
  /O(n*log n)/.
+  /O(n*log n)/.
hunk ./Data/Map.hs 1357
+
+ > mapKeysWith (++) (\ _ > 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "cdab"
+ > mapKeysWith (++) (\ _ > 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "cdab"
hunk ./Data/Map.hs 1369
+ That is, for any values @x@ and @y@, if @x@ < @y@ then @f x@ < @f y@.
hunk ./Data/Map.hs 1376
+
+ This means that @f@ maps distinct original keys to distinct resulting keys.
+ This function has better performance than 'mapKeys'.
+
+ > mapKeysMonotonic (\ k > k * 2) (fromList [(5,"a"), (3,"b")]) == fromList [(6, "b"), (10, "a")]
+ > valid (mapKeysMonotonic (\ k > k * 2) (fromList [(5,"a"), (3,"b")])) == True
+ > valid (mapKeysMonotonic (\ _ > 1) (fromList [(5,"a"), (3,"b")])) == False
hunk ./Data/Map.hs 1399
+ > let f a len = len + (length a)
+ > fold f 0 (fromList [(5,"a"), (3,"bbb")]) == 4
+
hunk ./Data/Map.hs 1412
+ > let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"
+ > foldWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"
+
hunk ./Data/Map.hs 1439
+
+ > elems (fromList [(5,"a"), (3,"b")]) == ["b","a"]
+ > elems empty == []
+
hunk ./Data/Map.hs 1448
+
+ > keys (fromList [(5,"a"), (3,"b")]) == [3,5]
+ > keys empty == []
+
hunk ./Data/Map.hs 1457
+
+ > keysSet (fromList [(5,"a"), (3,"b")]) == Data.Set.fromList [3,5]
+ > keysSet empty == Data.Set.empty
+
hunk ./Data/Map.hs 1465
+
+ > assocs (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
+ > assocs empty == []
+
hunk ./Data/Map.hs 1478
+ If the list contains more than one value for the same key, the last value
+ for the key is retained.
+
+ > fromList [] == empty
+ > fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
+ > fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
+
hunk ./Data/Map.hs 1492
+
+ > fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]
+ > fromListWith (++) [] == empty
+
hunk ./Data/Map.hs 1501
+
+ > let f k a1 a2 = (show k) ++ a1 ++ a2
+ > fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "3ab"), (5, "5a5ba")]
+ > fromListWithKey f [] == empty
+
hunk ./Data/Map.hs 1513
+
+ > toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
+ > toList empty == []
+
hunk ./Data/Map.hs 1521
+
+ > toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
+
hunk ./Data/Map.hs 1527
  /O(n)/.
+  /O(n)/.
hunk ./Data/Map.hs 1541
+
+ > fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
+ > fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")]
+ > valid (fromAscList [(3,"b"), (5,"a"), (5,"b")]) == True
+ > valid (fromAscList [(5,"a"), (3,"b"), (5,"b")]) == False
+
hunk ./Data/Map.hs 1553
+
+ > fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]
+ > valid (fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")]) == True
+ > valid (fromAscListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == False
+
hunk ./Data/Map.hs 1565
+
+ > let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2
+ > fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")] == fromList [(3, "b"), (5, "5:b5:ba")]
+ > valid (fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")]) == True
+ > valid (fromAscListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == False
+
hunk ./Data/Map.hs 1590
+
+ > fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
+ > valid (fromDistinctAscList [(3,"b"), (5,"a")]) == True
+ > valid (fromDistinctAscList [(3,"b"), (5,"a"), (5,"b")]) == False
+
hunk ./Data/Map.hs 1681
 the keys in @map1@ are smaller than @k@ and the keys in @map2@ larger than @k@. Any key equal to @k@ is found in neither @map1@ nor @map2@.
+ the keys in @map1@ are smaller than @k@ and the keys in @map2@ larger than @k@.
+ Any key equal to @k@ is found in neither @map1@ nor @map2@.
+
+ > split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")])
+ > split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a")
+ > split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")
+ > split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty)
+ > split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty)
+
hunk ./Data/Map.hs 1700
+
+ > splitLookup 2 (fromList [(5,"a"), (3,"b")]) == (empty, Nothing, fromList [(3,"b"), (5,"a")])
+ > splitLookup 3 (fromList [(5,"a"), (3,"b")]) == (empty, Just "b", singleton 5 "a")
+ > splitLookup 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Nothing, singleton 5 "a")
+ > splitLookup 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Just "a", empty)
+ > splitLookup 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], Nothing, empty)
+
hunk ./Data/Map.hs 1810
+
+ > deleteFindMin (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((3,"b"), fromList[(5,"a"), (10,"c")])
+ > deleteFindMin Error: can not return the minimal element of an empty map
+
hunk ./Data/Map.hs 1822
+
+ > deleteFindMax (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((10,"c"), fromList [(3,"b"), (5,"a")])
+ > deleteFindMax empty Error: can not return the maximal element of an empty map
+
hunk ./Data/Map.hs 1980
 in a compressed, hanging format.
+ in a compressed, hanging format. See 'showTreeWith'.
hunk ./Data/Map.hs 2081
+
+ > valid (fromAscList [(3,"b"), (5,"a")]) == True
+ > valid (fromAscList [(5,"a"), (3,"b")]) == False
+
}
Context:
[Fix a link in haddock docs
Ian Lynagh **20071126184450]
[Fix some URLs
Ian Lynagh **20071126214233]
[Add tiny regression test
David Benbennick **20071113045358]
[Fix ticket 1762
David Benbennick **20071111201939]
[Specify buildtype: Simple
Duncan Coutts **20071018125404]
[Add a boring file
Ian Lynagh **20070913204647]
[TAG 20070913
Ian Lynagh **20070913215901]
Patch bundle hash:
245f259beed9afa1702486da444186d49a821a33