summaryrefslogtreecommitdiff
path: root/libraries/base/Data/Foldable.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/Data/Foldable.hs')
-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