Skip to content

Commit 7cd38d1

Browse files
Fix Haddock documentation for fromAscListWithKey (#1161)
1 parent 047f435 commit 7cd38d1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

containers/src/Data/IntMap/Internal.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3488,7 +3488,7 @@ fromListWith f xs
34883488
= fromListWithKey (\_ x y -> f x y) xs
34893489
{-# INLINE fromListWith #-} -- Inline for list fusion
34903490

3491-
-- | \(O(n \min(n,W))\). Build a map from a list of key\/value pairs with a combining function. See also fromAscListWithKey'.
3491+
-- | \(O(n \min(n,W))\). Build a map from a list of key\/value pairs with a combining function. See also 'fromAscListWithKey'.
34923492
--
34933493
-- If the keys are in sorted order, ascending or descending, this function
34943494
-- takes \(O(n)\) time.
@@ -3541,8 +3541,9 @@ fromAscListWith f xs = fromAscListWithKey (\_ x y -> f x y) xs
35413541
-- non-decreasing order. This precondition is not checked. Use 'fromListWithKey'
35423542
-- if the precondition may not hold.
35433543
--
3544-
-- > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value
3545-
-- > fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "5:b|a")]
3544+
-- > let f key new_value old_value = show key ++ ":" ++ new_value ++ "|" ++ old_value
3545+
-- > fromAscListWithKey f [(3,"b"), (3,"a"), (5,"a"), (5,"b"), (5,"c")] == fromList [(3, "3:a|b"), (5, "5:c|5:b|a")]
3546+
-- > fromAscListWithKey f [] == empty
35463547
--
35473548
-- Also see the performance note on 'fromListWith'.
35483549

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ fromListWith f xs
11801180
= fromListWithKey (\_ x y -> f x y) xs
11811181
{-# INLINE fromListWith #-} -- Inline for list fusion
11821182

1183-
-- | \(O(n \min(n,W))\). Build a map from a list of key\/value pairs with a combining function. See also fromAscListWithKey'.
1183+
-- | \(O(n \min(n,W))\). Build a map from a list of key\/value pairs with a combining function. See also 'fromAscListWithKey'.
11841184
--
11851185
-- If the keys are in sorted order, ascending or descending, this function
11861186
-- takes \(O(n)\) time.
@@ -1232,7 +1232,9 @@ fromAscListWith f xs = fromAscListWithKey (\_ x y -> f x y) xs
12321232
-- non-decreasing order. This precondition is not checked. Use 'fromListWithKey'
12331233
-- if the precondition may not hold.
12341234
--
1235-
-- > fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]
1235+
-- > let f key new_value old_value = show key ++ ":" ++ new_value ++ "|" ++ old_value
1236+
-- > fromAscListWithKey f [(3,"b"), (3,"a"), (5,"a"), (5,"b"), (5,"c")] == fromList [(3, "3:a|b"), (5, "5:c|5:b|a")]
1237+
-- > fromAscListWithKey f [] == empty
12361238
--
12371239
-- Also see the performance note on 'fromListWith'.
12381240

0 commit comments

Comments
 (0)