summaryrefslogtreecommitdiff
path: root/libraries/base/Data
diff options
context:
space:
mode:
authorJade Lovelace <jadel@mercury.com>2022-10-31 17:16:31 -0700
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-08 12:55:18 -0500
commit132f89089cc463172329b8f8766ad5c799ce2058 (patch)
tree3fff8d7869509dbe0c5bc3e37cd5ae96e6414653 /libraries/base/Data
parentce726cd2a3182006999c57eff73368ab9a4f7c60 (diff)
downloadhaskell-132f89089cc463172329b8f8766ad5c799ce2058.tar.gz
Clarify msum/asum documentation
Diffstat (limited to 'libraries/base/Data')
-rw-r--r--libraries/base/Data/Foldable.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/libraries/base/Data/Foldable.hs b/libraries/base/Data/Foldable.hs
index e2d792a1f2..084d846be2 100644
--- a/libraries/base/Data/Foldable.hs
+++ b/libraries/base/Data/Foldable.hs
@@ -1175,7 +1175,7 @@ sequence_ = foldr c (return ())
where c m k = m >> k
{-# INLINE c #-}
--- | The sum of a collection of actions, generalizing 'concat'.
+-- | The sum of a collection of actions using '(<|>)', generalizing 'concat'.
--
-- 'asum' is just like 'msum', but generalised to 'Alternative'.
--
@@ -1189,10 +1189,16 @@ asum :: (Foldable t, Alternative f) => t (f a) -> f a
{-# INLINE asum #-}
asum = foldr (<|>) empty
--- | The sum of a collection of actions, generalizing 'concat'.
+-- | The sum of a collection of actions using '(<|>)', generalizing 'concat'.
--
-- 'msum' is just like 'asum', but specialised to 'MonadPlus'.
--
+-- ==== __Examples__
+--
+-- Basic usage, using the 'MonadPlus' instance for 'Maybe':
+--
+-- >>> msum [Just "Hello", Nothing, Just "World"]
+-- Just "Hello"
msum :: (Foldable t, MonadPlus m) => t (m a) -> m a
{-# INLINE msum #-}
msum = asum