Skip to content

Commit f2f2a9a

Browse files
committed
Fix inaccurate and badly formatted docs for update
Previously the docs suggested that the update function received the key as well as the value, but actually it only gets the value.
1 parent 042d354 commit f2f2a9a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Data/HashMap/Base.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,9 @@ adjust# f k0 m0 = go h0 k0 0 m0
11261126
| otherwise = t
11271127
{-# INLINABLE adjust# #-}
11281128

1129-
-- | /O(log n)/ The expression (@'update' f k map@) updates the value @x@ at @k@,
1130-
-- (if it is in the map). If (f k x) is @'Nothing', the element is deleted.
1131-
-- If it is (@'Just' y), the key k is bound to the new value y.
1129+
-- | /O(log n)/ The expression (@'update' f k map@) updates the value @x@ at @k@
1130+
-- (if it is in the map). If (@f x@) is @'Nothing'@, the element is deleted.
1131+
-- If it is (@'Just' y@), the key @k@ is bound to the new value @y@.
11321132
update :: (Eq k, Hashable k) => (a -> Maybe a) -> k -> HashMap k a -> HashMap k a
11331133
update f = alter (>>= f)
11341134
{-# INLINABLE update #-}

Data/HashMap/Strict/Base.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ adjust f k0 m0 = go h0 k0 0 m0
244244
| otherwise = t
245245
{-# INLINABLE adjust #-}
246246

247-
-- | /O(log n)/ The expression (@'update' f k map@) updates the value @x@ at @k@,
248-
-- (if it is in the map). If (f k x) is @'Nothing', the element is deleted.
249-
-- If it is (@'Just' y), the key k is bound to the new value y.
247+
-- | /O(log n)/ The expression (@'update' f k map@) updates the value @x@ at @k@
248+
-- (if it is in the map). If (@f x@) is @'Nothing'@, the element is deleted.
249+
-- If it is (@'Just' y@), the key @k@ is bound to the new value @y@.
250250
update :: (Eq k, Hashable k) => (a -> Maybe a) -> k -> HashMap k a -> HashMap k a
251251
update f = alter (>>= f)
252252
{-# INLINABLE update #-}

0 commit comments

Comments
 (0)