Skip to content

Commit 3e21bf6

Browse files
committed
Document traversal order for sets and maps
* Document that the `Foldable` instances for `IntMap`, `Map`, and `Set` fold in order of increasing key. * Document that the `Traversable` instances for `IntMap` and `Map` traverse in order of increasing key. Closes #535 [skip ci]
1 parent 4fff7c0 commit 3e21bf6

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

Data/IntMap/Internal.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ instance Semigroup (IntMap a) where
438438
stimes = stimesIdempotentMonoid
439439
#endif
440440

441+
-- | Folds in order of increasing key.
441442
instance Foldable.Foldable IntMap where
442443
fold = go
443444
where go Nil = mempty
@@ -497,6 +498,7 @@ instance Foldable.Foldable IntMap where
497498
{-# INLINABLE product #-}
498499
#endif
499500

501+
-- | Traverses in order of increasing key.
500502
instance Traversable IntMap where
501503
traverse f = traverseWithKey (\_ -> f)
502504
{-# INLINE traverse #-}

Data/Map/Internal.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4166,10 +4166,12 @@ instance Functor (Map k) where
41664166
a <$ (Bin sx kx _ l r) = Bin sx kx a (a <$ l) (a <$ r)
41674167
#endif
41684168

4169+
-- | Traverses in order of increasing key.
41694170
instance Traversable (Map k) where
41704171
traverse f = traverseWithKey (\_ -> f)
41714172
{-# INLINE traverse #-}
41724173

4174+
-- | Folds in order of increasing key.
41734175
instance Foldable.Foldable (Map k) where
41744176
fold = go
41754177
where go Tip = mempty

Data/Set/Internal.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ instance Ord a => Semigroup (Set a) where
308308
#endif
309309

310310

311+
-- | Folds in order of increasing key.
311312
instance Foldable.Foldable Set where
312313
fold = go
313314
where go Tip = mempty

0 commit comments

Comments
 (0)