summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libraries/base/GHC/Base.hs26
-rw-r--r--libraries/base/GHC/Conc/Sync.hs8
2 files changed, 26 insertions, 8 deletions
diff --git a/libraries/base/GHC/Base.hs b/libraries/base/GHC/Base.hs
index 589c889cf8..6cc195d362 100644
--- a/libraries/base/GHC/Base.hs
+++ b/libraries/base/GHC/Base.hs
@@ -1120,7 +1120,9 @@ class Applicative f => Alternative f where
some_v = liftA2 (:) v many_v
--- | @since 2.01
+-- | Picks the leftmost 'Just' value, or, alternatively, 'Nothing'.
+--
+-- @since 2.01
instance Alternative Maybe where
empty = Nothing
Nothing <|> r = r
@@ -1152,7 +1154,9 @@ class (Alternative m, Monad m) => MonadPlus m where
mplus :: m a -> m a -> m a
mplus = (<|>)
--- | @since 2.01
+-- | Picks the leftmost 'Just' value, or, alternatively, 'Nothing'.
+--
+-- @since 2.01
instance MonadPlus Maybe
---------------------------------------------
@@ -1214,12 +1218,16 @@ instance Monad [] where
{-# INLINE (>>) #-}
(>>) = (*>)
--- | @since 2.01
+-- | Combines lists by concatenation, starting from the empty list.
+--
+-- @since 2.01
instance Alternative [] where
empty = []
(<|>) = (++)
--- | @since 2.01
+-- | Combines lists by concatenation, starting from the empty list.
+--
+-- @since 2.01
instance MonadPlus []
{-
@@ -1602,12 +1610,18 @@ instance Monad IO where
(>>) = (*>)
(>>=) = bindIO
--- | @since 4.9.0.0
+-- | Takes the first non-throwing 'IO' action\'s result.
+-- 'empty' throws an exception.
+--
+-- @since 4.9.0.0
instance Alternative IO where
empty = failIO "mzero"
(<|>) = mplusIO
--- | @since 4.9.0.0
+-- | Takes the first non-throwing 'IO' action\'s result.
+-- 'mzero' throws an exception.
+--
+-- @since 4.9.0.0
instance MonadPlus IO
returnIO :: a -> IO a
diff --git a/libraries/base/GHC/Conc/Sync.hs b/libraries/base/GHC/Conc/Sync.hs
index 5fe89aa4c3..b587da0785 100644
--- a/libraries/base/GHC/Conc/Sync.hs
+++ b/libraries/base/GHC/Conc/Sync.hs
@@ -733,12 +733,16 @@ thenSTM (STM m) k = STM ( \s ->
returnSTM :: a -> STM a
returnSTM x = STM (\s -> (# s, x #))
--- | @since 4.8.0.0
+-- | Takes the first non-'retry'ing 'STM' action.
+--
+-- @since 4.8.0.0
instance Alternative STM where
empty = retry
(<|>) = orElse
--- | @since 4.3.0.0
+-- | Takes the first non-'retry'ing 'STM' action.
+--
+-- @since 4.3.0.0
instance MonadPlus STM
-- | Unsafely performs IO in the STM monad. Beware: this is a highly