summaryrefslogtreecommitdiff
path: root/libraries/base/Data/Semigroup.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/Data/Semigroup.hs')
-rw-r--r--libraries/base/Data/Semigroup.hs88
1 files changed, 0 insertions, 88 deletions
diff --git a/libraries/base/Data/Semigroup.hs b/libraries/base/Data/Semigroup.hs
index aaabe97e71..13b1e0e77a 100644
--- a/libraries/base/Data/Semigroup.hs
+++ b/libraries/base/Data/Semigroup.hs
@@ -89,9 +89,6 @@ module Data.Semigroup (
, Any(..)
, Sum(..)
, Product(..)
- -- * A better monoid for Maybe
- , Option(..)
- , option
-- * Difference lists of a semigroup
, diff
, cycle1
@@ -108,7 +105,6 @@ import GHC.Base (Semigroup(..))
import Data.Semigroup.Internal
import Control.Applicative
-import Control.Monad
import Control.Monad.Fix
import Data.Bifoldable
import Data.Bifunctor
@@ -511,87 +507,3 @@ mtimesDefault :: (Integral b, Monoid a) => b -> a -> a
mtimesDefault n x
| n == 0 = mempty
| otherwise = unwrapMonoid (stimes n (WrapMonoid x))
-
-{-# DEPRECATED Option, option "will be removed in GHC 9.2; use 'Maybe' instead." #-}
-
--- | 'Option' is effectively 'Maybe' with a better instance of
--- 'Monoid', built off of an underlying 'Semigroup' instead of an
--- underlying 'Monoid'.
---
--- Ideally, this type would not exist at all and we would just fix the
--- 'Monoid' instance of 'Maybe'.
---
--- In GHC 8.4 and higher, the 'Monoid' instance for 'Maybe' has been
--- corrected to lift a 'Semigroup' instance instead of a 'Monoid'
--- instance. Consequently, this type is no longer useful.
-newtype Option a = Option { getOption :: Maybe a }
- deriving ( Eq -- ^ @since 4.9.0.0
- , Ord -- ^ @since 4.9.0.0
- , Show -- ^ @since 4.9.0.0
- , Read -- ^ @since 4.9.0.0
- , Data -- ^ @since 4.9.0.0
- , Generic -- ^ @since 4.9.0.0
- , Generic1 -- ^ @since 4.9.0.0
- )
-
--- | @since 4.9.0.0
-instance Functor Option where
- fmap f (Option a) = Option (fmap f a)
-
--- | @since 4.9.0.0
-instance Applicative Option where
- pure a = Option (Just a)
- Option a <*> Option b = Option (a <*> b)
- liftA2 f (Option x) (Option y) = Option (liftA2 f x y)
-
- Option Nothing *> _ = Option Nothing
- _ *> b = b
-
--- | @since 4.9.0.0
-instance Monad Option where
- Option (Just a) >>= k = k a
- _ >>= _ = Option Nothing
- (>>) = (*>)
-
--- | @since 4.9.0.0
-instance Alternative Option where
- empty = Option Nothing
- Option Nothing <|> b = b
- a <|> _ = a
-
--- | @since 4.9.0.0
-instance MonadPlus Option
-
--- | @since 4.9.0.0
-instance MonadFix Option where
- mfix f = Option (mfix (getOption . f))
-
--- | @since 4.9.0.0
-instance Foldable Option where
- foldMap f (Option (Just m)) = f m
- foldMap _ (Option Nothing) = mempty
-
--- | @since 4.9.0.0
-instance Traversable Option where
- traverse f (Option (Just a)) = Option . Just <$> f a
- traverse _ (Option Nothing) = pure (Option Nothing)
-
--- | Fold an 'Option' case-wise, just like 'maybe'.
-option :: b -> (a -> b) -> Option a -> b
-option n j (Option m) = maybe n j m
-
--- | @since 4.9.0.0
-instance Semigroup a => Semigroup (Option a) where
- (<>) = coerce ((<>) :: Maybe a -> Maybe a -> Maybe a)
-#if !defined(__HADDOCK_VERSION__)
- -- workaround https://github.com/haskell/haddock/issues/680
- stimes _ (Option Nothing) = Option Nothing
- stimes n (Option (Just a)) = case compare n 0 of
- LT -> errorWithoutStackTrace "stimes: Option, negative multiplier"
- EQ -> Option Nothing
- GT -> Option (Just (stimes n a))
-#endif
-
--- | @since 4.9.0.0
-instance Semigroup a => Monoid (Option a) where
- mempty = Option Nothing