Skip to content

Commit 95df982

Browse files
committed
Fix/update documentation for `fromListWithKey
1 parent f2da03b commit 95df982

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

containers/src/Data/IntMap/Internal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3102,7 +3102,7 @@ fromListWith f xs
31023102

31033103
-- | \(O(n \min(n,W))\). Build a map from a list of key\/value pairs with a combining function. See also fromAscListWithKey'.
31043104
--
3105-
-- > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value
3105+
-- > let f key new_value old_value = show key ++ ":" ++ new_value ++ "|" ++ old_value
31063106
-- > fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "3:a|b"), (5, "5:c|5:b|a")]
31073107
-- > fromListWithKey f [] == empty
31083108

containers/src/Data/IntMap/Strict/Internal.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,9 @@ fromListWith f xs
10971097

10981098
-- | \(O(n \min(n,W))\). Build a map from a list of key\/value pairs with a combining function. See also fromAscListWithKey'.
10991099
--
1100-
-- > fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]
1101-
-- > fromListWith (++) [] == empty
1100+
-- > let f key new_value old_value = show key ++ ":" ++ new_value ++ "|" ++ old_value
1101+
-- > fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "3:a|b"), (5, "5:c|5:b|a")]
1102+
-- > fromListWithKey f [] == empty
11021103

11031104
fromListWithKey :: (Key -> a -> a -> a) -> [(Key,a)] -> IntMap a
11041105
fromListWithKey f xs

containers/src/Data/Map/Internal.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,8 +3470,8 @@ fromListWith f xs
34703470

34713471
-- | \(O(n \log n)\). Build a map from a list of key\/value pairs with a combining function. See also 'fromAscListWithKey'.
34723472
--
3473-
-- > let f k a1 a2 = (show k) ++ a1 ++ a2
3474-
-- > fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "3ab"), (5, "5a5ba")]
3473+
-- > let f key new_value old_value = show key ++ ":" ++ new_value ++ "|" ++ old_value
3474+
-- > fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "3:a|b"), (5, "5:c|5:b|a")]
34753475
-- > fromListWithKey f [] == empty
34763476

34773477
fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k,a)] -> Map k a

containers/src/Data/Map/Strict/Internal.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,8 +1549,8 @@ fromListWith f xs
15491549

15501550
-- | \(O(n \log n)\). Build a map from a list of key\/value pairs with a combining function. See also 'fromAscListWithKey'.
15511551
--
1552-
-- > let f k a1 a2 = (show k) ++ a1 ++ a2
1553-
-- > fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "3ab"), (5, "5a5ba")]
1552+
-- > let f key new_value old_value = show key ++ ":" ++ new_value ++ "|" ++ old_value
1553+
-- > fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"c")] == fromList [(3, "3:a|b"), (5, "5:c|5:b|a")]
15541554
-- > fromListWithKey f [] == empty
15551555

15561556
fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k,a)] -> Map k a

0 commit comments

Comments
 (0)