{-# LANGUAGE CPP                        #-}
{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE PolyKinds                  #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE Trustworthy                #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  Data.Semigroup
-- Copyright   :  (C) 2011-2015 Edward Kmett
-- License     :  BSD-style (see the file LICENSE)
--
-- Maintainer  :  libraries@haskell.org
-- Stability   :  provisional
-- Portability :  portable
--
-- A type @a@ is a 'Semigroup' if it provides an associative function ('<>')
-- that lets you combine any two values of type @a@ into one. Where being
-- associative means that the following must always hold:
--
-- prop> (a <> b) <> c == a <> (b <> c)
--
-- ==== __Examples__
--
-- The 'Min' 'Semigroup' instance for 'Int' is defined to always pick the smaller
-- number:
-- >>> Min 1 <> Min 2 <> Min 3 <> Min 4 :: Min Int
-- Min {getMin = 1}
--
-- If we need to combine multiple values we can use the 'sconcat' function
-- to do so. We need to ensure however that we have at least one value to
-- operate on, since otherwise our result would be undefined. It is for this
-- reason that 'sconcat' uses "Data.List.NonEmpty.NonEmpty" - a list that
-- can never be empty:
--
-- >>> (1 :| [])
-- 1 :| []               -- equivalent to [1] but guaranteed to be non-empty.
--
-- >>> (1 :| [2, 3, 4])
-- 1 :| [2,3,4]          -- equivalent to [1,2,3,4] but guaranteed to be non-empty.
--
-- Equipped with this guaranteed to be non-empty data structure, we can combine
-- values using 'sconcat' and a 'Semigroup' of our choosing. We can try the 'Min'
-- and 'Max' instances of 'Int' which pick the smallest, or largest number
-- respectively:
--
-- >>> sconcat (1 :| [2, 3, 4]) :: Min Int
-- Min {getMin = 1}
-- >>> sconcat (1 :| [2, 3, 4]) :: Max Int
-- Max {getMax = 4}
--
-- String concatenation is another example of a 'Semigroup' instance:
--
-- >>> "foo" <> "bar"
-- "foobar"
--
-- A 'Semigroup' is a generalization of a 'Monoid'. Yet unlike the 'Semigroup', the 'Monoid'
-- requires the presence of a neutral element ('mempty') in addition to the associative
-- operator. The requirement for a neutral element prevents many types from being a full Monoid,
-- like "Data.List.NonEmpty.NonEmpty".
--
-- Note that the use of @(\<\>)@ in this module conflicts with an operator with the same
-- name that is being exported by "Data.Monoid". However, this package
-- re-exports (most of) the contents of Data.Monoid, so to use semigroups
-- and monoids in the same package just
--
-- > import Data.Semigroup
--
-- @since 4.9.0.0
----------------------------------------------------------------------------
module Data.Semigroup (
    Semigroup(..)
  , stimesMonoid
  , stimesIdempotent
  , stimesIdempotentMonoid
  , mtimesDefault
  -- * Semigroups
  , Min(..)
  , Max(..)
  , First(..)
  , Last(..)
  , WrappedMonoid(..)
  -- * Re-exported monoids from Data.Monoid
  , Dual(..)
  , Endo(..)
  , All(..)
  , Any(..)
  , Sum(..)
  , Product(..)
  -- * Difference lists of a semigroup
  , diff
  , cycle1
  -- * ArgMin, ArgMax
  , Arg(..)
  , ArgMin
  , ArgMax
  ) where

import           Prelude             hiding (foldr1, Applicative(..))

import GHC.Base (Semigroup(..))

import           Data.Semigroup.Internal

import           Control.Applicative
import           Control.Monad.Fix
import           Data.Bifoldable
import           Data.Bifunctor
import           Data.Bitraversable
import           Data.Coerce
import           Data.Data
import           GHC.Generics
import qualified GHC.List as List

-- $setup
-- >>> import Prelude
-- >>> import Data.List.NonEmpty (NonEmpty (..))

-- | A generalization of 'Data.List.cycle' to an arbitrary 'Semigroup'.
-- May fail to terminate for some values in some semigroups.
cycle1 :: Semigroup m => m -> m
cycle1 :: forall m. Semigroup m => m -> m
cycle1 m
xs = m
xs' where xs' :: m
xs' = m
xs m -> m -> m
forall a. Semigroup a => a -> a -> a
<> m
xs'

-- | This lets you use a difference list of a 'Semigroup' as a 'Monoid'.
--
-- === __Example:__
-- >>> let hello = diff "Hello, "
-- >>> appEndo hello "World!"
-- "Hello, World!"
-- >>> appEndo (hello <> mempty) "World!"
-- "Hello, World!"
-- >>> appEndo (mempty <> hello) "World!"
-- "Hello, World!"
-- >>> let world = diff "World"
-- >>> let excl = diff "!"
-- >>> appEndo (hello <> (world <> excl)) mempty
-- "Hello, World!"
-- >>> appEndo ((hello <> world) <> excl) mempty
-- "Hello, World!"
diff :: Semigroup m => m -> Endo m
diff :: forall m. Semigroup m => m -> Endo m
diff = (m -> m) -> Endo m
forall a. (a -> a) -> Endo a
Endo ((m -> m) -> Endo m) -> (m -> m -> m) -> m -> Endo m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m -> m -> m
forall a. Semigroup a => a -> a -> a
(<>)

newtype Min a = Min { forall a. Min a -> a
getMin :: a }
  deriving ( Min a
Min a -> Min a -> Bounded (Min a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Min a
$cminBound :: forall a. Bounded a => Min a
minBound :: Min a
$cmaxBound :: forall a. Bounded a => Min a
maxBound :: Min a
Bounded  -- ^ @since 4.9.0.0
           , Min a -> Min a -> Bool
(Min a -> Min a -> Bool) -> (Min a -> Min a -> Bool) -> Eq (Min a)
forall a. Eq a => Min a -> Min a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Min a -> Min a -> Bool
== :: Min a -> Min a -> Bool
$c/= :: forall a. Eq a => Min a -> Min a -> Bool
/= :: Min a -> Min a -> Bool
Eq       -- ^ @since 4.9.0.0
           , Eq (Min a)
Eq (Min a) =>
(Min a -> Min a -> Ordering)
-> (Min a -> Min a -> Bool)
-> (Min a -> Min a -> Bool)
-> (Min a -> Min a -> Bool)
-> (Min a -> Min a -> Bool)
-> (Min a -> Min a -> Min a)
-> (Min a -> Min a -> Min a)
-> Ord (Min a)
Min a -> Min a -> Bool
Min a -> Min a -> Ordering
Min a -> Min a -> Min a
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Min a)
forall a. Ord a => Min a -> Min a -> Bool
forall a. Ord a => Min a -> Min a -> Ordering
forall a. Ord a => Min a -> Min a -> Min a
$ccompare :: forall a. Ord a => Min a -> Min a -> Ordering
compare :: Min a -> Min a -> Ordering
$c< :: forall a. Ord a => Min a -> Min a -> Bool
< :: Min a -> Min a -> Bool
$c<= :: forall a. Ord a => Min a -> Min a -> Bool
<= :: Min a -> Min a -> Bool
$c> :: forall a. Ord a => Min a -> Min a -> Bool
> :: Min a -> Min a -> Bool
$c>= :: forall a. Ord a => Min a -> Min a -> Bool
>= :: Min a -> Min a -> Bool
$cmax :: forall a. Ord a => Min a -> Min a -> Min a
max :: Min a -> Min a -> Min a
$cmin :: forall a. Ord a => Min a -> Min a -> Min a
min :: Min a -> Min a -> Min a
Ord      -- ^ @since 4.9.0.0
           , Int -> Min a -> ShowS
[Min a] -> ShowS
Min a -> String
(Int -> Min a -> ShowS)
-> (Min a -> String) -> ([Min a] -> ShowS) -> Show (Min a)
forall a. Show a => Int -> Min a -> ShowS
forall a. Show a => [Min a] -> ShowS
forall a. Show a => Min a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Min a -> ShowS
showsPrec :: Int -> Min a -> ShowS
$cshow :: forall a. Show a => Min a -> String
show :: Min a -> String
$cshowList :: forall a. Show a => [Min a] -> ShowS
showList :: [Min a] -> ShowS
Show     -- ^ @since 4.9.0.0
           , ReadPrec [Min a]
ReadPrec (Min a)
Int -> ReadS (Min a)
ReadS [Min a]
(Int -> ReadS (Min a))
-> ReadS [Min a]
-> ReadPrec (Min a)
-> ReadPrec [Min a]
-> Read (Min a)
forall a. Read a => ReadPrec [Min a]
forall a. Read a => ReadPrec (Min a)
forall a. Read a => Int -> ReadS (Min a)
forall a. Read a => ReadS [Min a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (Min a)
readsPrec :: Int -> ReadS (Min a)
$creadList :: forall a. Read a => ReadS [Min a]
readList :: ReadS [Min a]
$creadPrec :: forall a. Read a => ReadPrec (Min a)
readPrec :: ReadPrec (Min a)
$creadListPrec :: forall a. Read a => ReadPrec [Min a]
readListPrec :: ReadPrec [Min a]
Read     -- ^ @since 4.9.0.0
           , Typeable (Min a)
Typeable (Min a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Min a -> c (Min a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Min a))
-> (Min a -> Constr)
-> (Min a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Min a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Min a)))
-> ((forall b. Data b => b -> b) -> Min a -> Min a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Min a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Min a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Min a -> m (Min a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Min a -> m (Min a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Min a -> m (Min a))
-> Data (Min a)
Min a -> Constr
Min a -> DataType
(forall b. Data b => b -> b) -> Min a -> Min a
forall a. Data a => Typeable (Min a)
forall a. Data a => Min a -> Constr
forall a. Data a => Min a -> DataType
forall a. Data a => (forall b. Data b => b -> b) -> Min a -> Min a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Min a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Min a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Min a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Min a -> c (Min a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Min a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Min a))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Min a -> u
forall u. (forall d. Data d => d -> u) -> Min a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Min a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Min a -> c (Min a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Min a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Min a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Min a -> c (Min a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Min a -> c (Min a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Min a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Min a)
$ctoConstr :: forall a. Data a => Min a -> Constr
toConstr :: Min a -> Constr
$cdataTypeOf :: forall a. Data a => Min a -> DataType
dataTypeOf :: Min a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Min a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Min a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Min a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Min a))
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> Min a -> Min a
gmapT :: (forall b. Data b => b -> b) -> Min a -> Min a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Min a -> r
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Min a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Min a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Min a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Min a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Min a -> m (Min a)
Data     -- ^ @since 4.9.0.0
           , (forall x. Min a -> Rep (Min a) x)
-> (forall x. Rep (Min a) x -> Min a) -> Generic (Min a)
forall x. Rep (Min a) x -> Min a
forall x. Min a -> Rep (Min a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Min a) x -> Min a
forall a x. Min a -> Rep (Min a) x
$cfrom :: forall a x. Min a -> Rep (Min a) x
from :: forall x. Min a -> Rep (Min a) x
$cto :: forall a x. Rep (Min a) x -> Min a
to :: forall x. Rep (Min a) x -> Min a
Generic  -- ^ @since 4.9.0.0
           , (forall a. Min a -> Rep1 Min a)
-> (forall a. Rep1 Min a -> Min a) -> Generic1 Min
forall a. Rep1 Min a -> Min a
forall a. Min a -> Rep1 Min a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cfrom1 :: forall a. Min a -> Rep1 Min a
from1 :: forall a. Min a -> Rep1 Min a
$cto1 :: forall a. Rep1 Min a -> Min a
to1 :: forall a. Rep1 Min a -> Min a
Generic1 -- ^ @since 4.9.0.0
           )

-- | @since 4.9.0.0
instance Enum a => Enum (Min a) where
  succ :: Min a -> Min a
succ (Min a
a) = a -> Min a
forall a. a -> Min a
Min (a -> a
forall a. Enum a => a -> a
succ a
a)
  pred :: Min a -> Min a
pred (Min a
a) = a -> Min a
forall a. a -> Min a
Min (a -> a
forall a. Enum a => a -> a
pred a
a)
  toEnum :: Int -> Min a
toEnum = a -> Min a
forall a. a -> Min a
Min (a -> Min a) -> (Int -> a) -> Int -> Min a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a
forall a. Enum a => Int -> a
toEnum
  fromEnum :: Min a -> Int
fromEnum = a -> Int
forall a. Enum a => a -> Int
fromEnum (a -> Int) -> (Min a -> a) -> Min a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Min a -> a
forall a. Min a -> a
getMin
  enumFrom :: Min a -> [Min a]
enumFrom (Min a
a) = a -> Min a
forall a. a -> Min a
Min (a -> Min a) -> [a] -> [Min a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> [a]
forall a. Enum a => a -> [a]
enumFrom a
a
  enumFromThen :: Min a -> Min a -> [Min a]
enumFromThen (Min a
a) (Min a
b) = a -> Min a
forall a. a -> Min a
Min (a -> Min a) -> [a] -> [Min a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> [a]
forall a. Enum a => a -> a -> [a]
enumFromThen a
a a
b
  enumFromTo :: Min a -> Min a -> [Min a]
enumFromTo (Min a
a) (Min a
b) = a -> Min a
forall a. a -> Min a
Min (a -> Min a) -> [a] -> [Min a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> [a]
forall a. Enum a => a -> a -> [a]
enumFromTo a
a a
b
  enumFromThenTo :: Min a -> Min a -> Min a -> [Min a]
enumFromThenTo (Min a
a) (Min a
b) (Min a
c) = a -> Min a
forall a. a -> Min a
Min (a -> Min a) -> [a] -> [Min a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> a -> [a]
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo a
a a
b a
c


-- | @since 4.9.0.0
instance Ord a => Semigroup (Min a) where
  <> :: Min a -> Min a -> Min a
(<>) = (a -> a -> a) -> Min a -> Min a -> Min a
forall a b. Coercible a b => a -> b
coerce (a -> a -> a
forall a. Ord a => a -> a -> a
min :: a -> a -> a)
  stimes :: forall b. Integral b => b -> Min a -> Min a
stimes = b -> Min a -> Min a
forall b a. Integral b => b -> a -> a
stimesIdempotent

-- | @since 4.9.0.0
instance (Ord a, Bounded a) => Monoid (Min a) where
  mempty :: Min a
mempty = Min a
forall a. Bounded a => a
maxBound
  -- By default, we would get a lazy right fold. This forces the use of a strict
  -- left fold instead.
  mconcat :: [Min a] -> Min a
mconcat = (Min a -> Min a -> Min a) -> Min a -> [Min a] -> Min a
forall a b. (b -> a -> b) -> b -> [a] -> b
List.foldl' Min a -> Min a -> Min a
forall a. Semigroup a => a -> a -> a
(<>) Min a
forall a. Monoid a => a
mempty
  {-# INLINE mconcat #-}

-- | @since 4.9.0.0
instance Functor Min where
  fmap :: forall a b. (a -> b) -> Min a -> Min b
fmap a -> b
f (Min a
x) = b -> Min b
forall a. a -> Min a
Min (a -> b
f a
x)

-- | @since 4.9.0.0
instance Foldable Min where
  foldMap :: forall m a. Monoid m => (a -> m) -> Min a -> m
foldMap a -> m
f (Min a
a) = a -> m
f a
a

-- | @since 4.9.0.0
instance Traversable Min where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Min a -> f (Min b)
traverse a -> f b
f (Min a
a) = b -> Min b
forall a. a -> Min a
Min (b -> Min b) -> f b -> f (Min b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a

-- | @since 4.9.0.0
instance Applicative Min where
  pure :: forall a. a -> Min a
pure = a -> Min a
forall a. a -> Min a
Min
  Min a
a <* :: forall a b. Min a -> Min b -> Min a
<* Min b
_ = Min a
a
  Min a
_ *> :: forall a b. Min a -> Min b -> Min b
*> Min b
a = Min b
a
  <*> :: forall a b. Min (a -> b) -> Min a -> Min b
(<*>) = Min (a -> b) -> Min a -> Min b
forall a b. Coercible a b => a -> b
coerce
  liftA2 :: forall a b c. (a -> b -> c) -> Min a -> Min b -> Min c
liftA2 = (a -> b -> c) -> Min a -> Min b -> Min c
forall a b. Coercible a b => a -> b
coerce

-- | @since 4.9.0.0
instance Monad Min where
  >> :: forall a b. Min a -> Min b -> Min b
(>>) = Min a -> Min b -> Min b
forall a b. Min a -> Min b -> Min b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
  Min a
a >>= :: forall a b. Min a -> (a -> Min b) -> Min b
>>= a -> Min b
f = a -> Min b
f a
a

-- | @since 4.9.0.0
instance MonadFix Min where
  mfix :: forall a. (a -> Min a) -> Min a
mfix a -> Min a
f = (Min a -> Min a) -> Min a
forall a. (a -> a) -> a
fix (a -> Min a
f (a -> Min a) -> (Min a -> a) -> Min a -> Min a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Min a -> a
forall a. Min a -> a
getMin)

-- | @since 4.9.0.0
instance Num a => Num (Min a) where
  (Min a
a) + :: Min a -> Min a -> Min a
+ (Min a
b) = a -> Min a
forall a. a -> Min a
Min (a
a a -> a -> a
forall a. Num a => a -> a -> a
+ a
b)
  (Min a
a) * :: Min a -> Min a -> Min a
* (Min a
b) = a -> Min a
forall a. a -> Min a
Min (a
a a -> a -> a
forall a. Num a => a -> a -> a
* a
b)
  (Min a
a) - :: Min a -> Min a -> Min a
- (Min a
b) = a -> Min a
forall a. a -> Min a
Min (a
a a -> a -> a
forall a. Num a => a -> a -> a
- a
b)
  negate :: Min a -> Min a
negate (Min a
a) = a -> Min a
forall a. a -> Min a
Min (a -> a
forall a. Num a => a -> a
negate a
a)
  abs :: Min a -> Min a
abs    (Min a
a) = a -> Min a
forall a. a -> Min a
Min (a -> a
forall a. Num a => a -> a
abs a
a)
  signum :: Min a -> Min a
signum (Min a
a) = a -> Min a
forall a. a -> Min a
Min (a -> a
forall a. Num a => a -> a
signum a
a)
  fromInteger :: Integer -> Min a
fromInteger    = a -> Min a
forall a. a -> Min a
Min (a -> Min a) -> (Integer -> a) -> Integer -> Min a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> a
forall a. Num a => Integer -> a
fromInteger

newtype Max a = Max { forall a. Max a -> a
getMax :: a }
  deriving ( Max a
Max a -> Max a -> Bounded (Max a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Max a
$cminBound :: forall a. Bounded a => Max a
minBound :: Max a
$cmaxBound :: forall a. Bounded a => Max a
maxBound :: Max a
Bounded  -- ^ @since 4.9.0.0
           , Max a -> Max a -> Bool
(Max a -> Max a -> Bool) -> (Max a -> Max a -> Bool) -> Eq (Max a)
forall a. Eq a => Max a -> Max a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Max a -> Max a -> Bool
== :: Max a -> Max a -> Bool
$c/= :: forall a. Eq a => Max a -> Max a -> Bool
/= :: Max a -> Max a -> Bool
Eq       -- ^ @since 4.9.0.0
           , Eq (Max a)
Eq (Max a) =>
(Max a -> Max a -> Ordering)
-> (Max a -> Max a -> Bool)
-> (Max a -> Max a -> Bool)
-> (Max a -> Max a -> Bool)
-> (Max a -> Max a -> Bool)
-> (Max a -> Max a -> Max a)
-> (Max a -> Max a -> Max a)
-> Ord (Max a)
Max a -> Max a -> Bool
Max a -> Max a -> Ordering
Max a -> Max a -> Max a
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Max a)
forall a. Ord a => Max a -> Max a -> Bool
forall a. Ord a => Max a -> Max a -> Ordering
forall a. Ord a => Max a -> Max a -> Max a
$ccompare :: forall a. Ord a => Max a -> Max a -> Ordering
compare :: Max a -> Max a -> Ordering
$c< :: forall a. Ord a => Max a -> Max a -> Bool
< :: Max a -> Max a -> Bool
$c<= :: forall a. Ord a => Max a -> Max a -> Bool
<= :: Max a -> Max a -> Bool
$c> :: forall a. Ord a => Max a -> Max a -> Bool
> :: Max a -> Max a -> Bool
$c>= :: forall a. Ord a => Max a -> Max a -> Bool
>= :: Max a -> Max a -> Bool
$cmax :: forall a. Ord a => Max a -> Max a -> Max a
max :: Max a -> Max a -> Max a
$cmin :: forall a. Ord a => Max a -> Max a -> Max a
min :: Max a -> Max a -> Max a
Ord      -- ^ @since 4.9.0.0
           , Int -> Max a -> ShowS
[Max a] -> ShowS
Max a -> String
(Int -> Max a -> ShowS)
-> (Max a -> String) -> ([Max a] -> ShowS) -> Show (Max a)
forall a. Show a => Int -> Max a -> ShowS
forall a. Show a => [Max a] -> ShowS
forall a. Show a => Max a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Max a -> ShowS
showsPrec :: Int -> Max a -> ShowS
$cshow :: forall a. Show a => Max a -> String
show :: Max a -> String
$cshowList :: forall a. Show a => [Max a] -> ShowS
showList :: [Max a] -> ShowS
Show     -- ^ @since 4.9.0.0
           , ReadPrec [Max a]
ReadPrec (Max a)
Int -> ReadS (Max a)
ReadS [Max a]
(Int -> ReadS (Max a))
-> ReadS [Max a]
-> ReadPrec (Max a)
-> ReadPrec [Max a]
-> Read (Max a)
forall a. Read a => ReadPrec [Max a]
forall a. Read a => ReadPrec (Max a)
forall a. Read a => Int -> ReadS (Max a)
forall a. Read a => ReadS [Max a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (Max a)
readsPrec :: Int -> ReadS (Max a)
$creadList :: forall a. Read a => ReadS [Max a]
readList :: ReadS [Max a]
$creadPrec :: forall a. Read a => ReadPrec (Max a)
readPrec :: ReadPrec (Max a)
$creadListPrec :: forall a. Read a => ReadPrec [Max a]
readListPrec :: ReadPrec [Max a]
Read     -- ^ @since 4.9.0.0
           , Typeable (Max a)
Typeable (Max a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Max a -> c (Max a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Max a))
-> (Max a -> Constr)
-> (Max a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Max a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Max a)))
-> ((forall b. Data b => b -> b) -> Max a -> Max a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Max a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Max a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Max a -> m (Max a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Max a -> m (Max a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Max a -> m (Max a))
-> Data (Max a)
Max a -> Constr
Max a -> DataType
(forall b. Data b => b -> b) -> Max a -> Max a
forall a. Data a => Typeable (Max a)
forall a. Data a => Max a -> Constr
forall a. Data a => Max a -> DataType
forall a. Data a => (forall b. Data b => b -> b) -> Max a -> Max a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Max a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Max a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Max a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Max a -> c (Max a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Max a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Max a))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Max a -> u
forall u. (forall d. Data d => d -> u) -> Max a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Max a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Max a -> c (Max a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Max a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Max a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Max a -> c (Max a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Max a -> c (Max a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Max a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Max a)
$ctoConstr :: forall a. Data a => Max a -> Constr
toConstr :: Max a -> Constr
$cdataTypeOf :: forall a. Data a => Max a -> DataType
dataTypeOf :: Max a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Max a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Max a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Max a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Max a))
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> Max a -> Max a
gmapT :: (forall b. Data b => b -> b) -> Max a -> Max a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Max a -> r
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Max a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Max a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Max a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Max a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Max a -> m (Max a)
Data     -- ^ @since 4.9.0.0
           , (forall x. Max a -> Rep (Max a) x)
-> (forall x. Rep (Max a) x -> Max a) -> Generic (Max a)
forall x. Rep (Max a) x -> Max a
forall x. Max a -> Rep (Max a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Max a) x -> Max a
forall a x. Max a -> Rep (Max a) x
$cfrom :: forall a x. Max a -> Rep (Max a) x
from :: forall x. Max a -> Rep (Max a) x
$cto :: forall a x. Rep (Max a) x -> Max a
to :: forall x. Rep (Max a) x -> Max a
Generic  -- ^ @since 4.9.0.0
           , (forall a. Max a -> Rep1 Max a)
-> (forall a. Rep1 Max a -> Max a) -> Generic1 Max
forall a. Rep1 Max a -> Max a
forall a. Max a -> Rep1 Max a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cfrom1 :: forall a. Max a -> Rep1 Max a
from1 :: forall a. Max a -> Rep1 Max a
$cto1 :: forall a. Rep1 Max a -> Max a
to1 :: forall a. Rep1 Max a -> Max a
Generic1 -- ^ @since 4.9.0.0
           )

-- | @since 4.9.0.0
instance Enum a => Enum (Max a) where
  succ :: Max a -> Max a
succ (Max a
a) = a -> Max a
forall a. a -> Max a
Max (a -> a
forall a. Enum a => a -> a
succ a
a)
  pred :: Max a -> Max a
pred (Max a
a) = a -> Max a
forall a. a -> Max a
Max (a -> a
forall a. Enum a => a -> a
pred a
a)
  toEnum :: Int -> Max a
toEnum = a -> Max a
forall a. a -> Max a
Max (a -> Max a) -> (Int -> a) -> Int -> Max a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a
forall a. Enum a => Int -> a
toEnum
  fromEnum :: Max a -> Int
fromEnum = a -> Int
forall a. Enum a => a -> Int
fromEnum (a -> Int) -> (Max a -> a) -> Max a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Max a -> a
forall a. Max a -> a
getMax
  enumFrom :: Max a -> [Max a]
enumFrom (Max a
a) = a -> Max a
forall a. a -> Max a
Max (a -> Max a) -> [a] -> [Max a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> [a]
forall a. Enum a => a -> [a]
enumFrom a
a
  enumFromThen :: Max a -> Max a -> [Max a]
enumFromThen (Max a
a) (Max a
b) = a -> Max a
forall a. a -> Max a
Max (a -> Max a) -> [a] -> [Max a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> [a]
forall a. Enum a => a -> a -> [a]
enumFromThen a
a a
b
  enumFromTo :: Max a -> Max a -> [Max a]
enumFromTo (Max a
a) (Max a
b) = a -> Max a
forall a. a -> Max a
Max (a -> Max a) -> [a] -> [Max a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> [a]
forall a. Enum a => a -> a -> [a]
enumFromTo a
a a
b
  enumFromThenTo :: Max a -> Max a -> Max a -> [Max a]
enumFromThenTo (Max a
a) (Max a
b) (Max a
c) = a -> Max a
forall a. a -> Max a
Max (a -> Max a) -> [a] -> [Max a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> a -> [a]
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo a
a a
b a
c

-- | @since 4.9.0.0
instance Ord a => Semigroup (Max a) where
  <> :: Max a -> Max a -> Max a
(<>) = (a -> a -> a) -> Max a -> Max a -> Max a
forall a b. Coercible a b => a -> b
coerce (a -> a -> a
forall a. Ord a => a -> a -> a
max :: a -> a -> a)
  stimes :: forall b. Integral b => b -> Max a -> Max a
stimes = b -> Max a -> Max a
forall b a. Integral b => b -> a -> a
stimesIdempotent

-- | @since 4.9.0.0
instance (Ord a, Bounded a) => Monoid (Max a) where
  mempty :: Max a
mempty = Max a
forall a. Bounded a => a
minBound
  -- By default, we would get a lazy right fold. This forces the use of a strict
  -- left fold instead.
  mconcat :: [Max a] -> Max a
mconcat = (Max a -> Max a -> Max a) -> Max a -> [Max a] -> Max a
forall a b. (b -> a -> b) -> b -> [a] -> b
List.foldl' Max a -> Max a -> Max a
forall a. Semigroup a => a -> a -> a
(<>) Max a
forall a. Monoid a => a
mempty
  {-# INLINE mconcat #-}

-- | @since 4.9.0.0
instance Functor Max where
  fmap :: forall a b. (a -> b) -> Max a -> Max b
fmap a -> b
f (Max a
x) = b -> Max b
forall a. a -> Max a
Max (a -> b
f a
x)

-- | @since 4.9.0.0
instance Foldable Max where
  foldMap :: forall m a. Monoid m => (a -> m) -> Max a -> m
foldMap a -> m
f (Max a
a) = a -> m
f a
a

-- | @since 4.9.0.0
instance Traversable Max where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Max a -> f (Max b)
traverse a -> f b
f (Max a
a) = b -> Max b
forall a. a -> Max a
Max (b -> Max b) -> f b -> f (Max b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a

-- | @since 4.9.0.0
instance Applicative Max where
  pure :: forall a. a -> Max a
pure = a -> Max a
forall a. a -> Max a
Max
  Max a
a <* :: forall a b. Max a -> Max b -> Max a
<* Max b
_ = Max a
a
  Max a
_ *> :: forall a b. Max a -> Max b -> Max b
*> Max b
a = Max b
a
  <*> :: forall a b. Max (a -> b) -> Max a -> Max b
(<*>) = Max (a -> b) -> Max a -> Max b
forall a b. Coercible a b => a -> b
coerce
  liftA2 :: forall a b c. (a -> b -> c) -> Max a -> Max b -> Max c
liftA2 = (a -> b -> c) -> Max a -> Max b -> Max c
forall a b. Coercible a b => a -> b
coerce

-- | @since 4.9.0.0
instance Monad Max where
  >> :: forall a b. Max a -> Max b -> Max b
(>>) = Max a -> Max b -> Max b
forall a b. Max a -> Max b -> Max b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
  Max a
a >>= :: forall a b. Max a -> (a -> Max b) -> Max b
>>= a -> Max b
f = a -> Max b
f a
a

-- | @since 4.9.0.0
instance MonadFix Max where
  mfix :: forall a. (a -> Max a) -> Max a
mfix a -> Max a
f = (Max a -> Max a) -> Max a
forall a. (a -> a) -> a
fix (a -> Max a
f (a -> Max a) -> (Max a -> a) -> Max a -> Max a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Max a -> a
forall a. Max a -> a
getMax)

-- | @since 4.9.0.0
instance Num a => Num (Max a) where
  (Max a
a) + :: Max a -> Max a -> Max a
+ (Max a
b) = a -> Max a
forall a. a -> Max a
Max (a
a a -> a -> a
forall a. Num a => a -> a -> a
+ a
b)
  (Max a
a) * :: Max a -> Max a -> Max a
* (Max a
b) = a -> Max a
forall a. a -> Max a
Max (a
a a -> a -> a
forall a. Num a => a -> a -> a
* a
b)
  (Max a
a) - :: Max a -> Max a -> Max a
- (Max a
b) = a -> Max a
forall a. a -> Max a
Max (a
a a -> a -> a
forall a. Num a => a -> a -> a
- a
b)
  negate :: Max a -> Max a
negate (Max a
a) = a -> Max a
forall a. a -> Max a
Max (a -> a
forall a. Num a => a -> a
negate a
a)
  abs :: Max a -> Max a
abs    (Max a
a) = a -> Max a
forall a. a -> Max a
Max (a -> a
forall a. Num a => a -> a
abs a
a)
  signum :: Max a -> Max a
signum (Max a
a) = a -> Max a
forall a. a -> Max a
Max (a -> a
forall a. Num a => a -> a
signum a
a)
  fromInteger :: Integer -> Max a
fromInteger    = a -> Max a
forall a. a -> Max a
Max (a -> Max a) -> (Integer -> a) -> Integer -> Max a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> a
forall a. Num a => Integer -> a
fromInteger

-- | 'Arg' isn't itself a 'Semigroup' in its own right, but it can be
-- placed inside 'Min' and 'Max' to compute an arg min or arg max.
--
-- >>> minimum [ Arg (x * x) x | x <- [-10 .. 10] ]
-- Arg 0 0
data Arg a b = Arg
  a
  -- ^ The argument used for comparisons in 'Eq' and 'Ord'.
  b
  -- ^ The "value" exposed via the 'Functor', 'Foldable' etc. instances.
  deriving
  ( Int -> Arg a b -> ShowS
[Arg a b] -> ShowS
Arg a b -> String
(Int -> Arg a b -> ShowS)
-> (Arg a b -> String) -> ([Arg a b] -> ShowS) -> Show (Arg a b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b. (Show a, Show b) => Int -> Arg a b -> ShowS
forall a b. (Show a, Show b) => [Arg a b] -> ShowS
forall a b. (Show a, Show b) => Arg a b -> String
$cshowsPrec :: forall a b. (Show a, Show b) => Int -> Arg a b -> ShowS
showsPrec :: Int -> Arg a b -> ShowS
$cshow :: forall a b. (Show a, Show b) => Arg a b -> String
show :: Arg a b -> String
$cshowList :: forall a b. (Show a, Show b) => [Arg a b] -> ShowS
showList :: [Arg a b] -> ShowS
Show     -- ^ @since 4.9.0.0
  , ReadPrec [Arg a b]
ReadPrec (Arg a b)
Int -> ReadS (Arg a b)
ReadS [Arg a b]
(Int -> ReadS (Arg a b))
-> ReadS [Arg a b]
-> ReadPrec (Arg a b)
-> ReadPrec [Arg a b]
-> Read (Arg a b)
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall a b. (Read a, Read b) => ReadPrec [Arg a b]
forall a b. (Read a, Read b) => ReadPrec (Arg a b)
forall a b. (Read a, Read b) => Int -> ReadS (Arg a b)
forall a b. (Read a, Read b) => ReadS [Arg a b]
$creadsPrec :: forall a b. (Read a, Read b) => Int -> ReadS (Arg a b)
readsPrec :: Int -> ReadS (Arg a b)
$creadList :: forall a b. (Read a, Read b) => ReadS [Arg a b]
readList :: ReadS [Arg a b]
$creadPrec :: forall a b. (Read a, Read b) => ReadPrec (Arg a b)
readPrec :: ReadPrec (Arg a b)
$creadListPrec :: forall a b. (Read a, Read b) => ReadPrec [Arg a b]
readListPrec :: ReadPrec [Arg a b]
Read     -- ^ @since 4.9.0.0
  , Typeable (Arg a b)
Typeable (Arg a b) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Arg a b -> c (Arg a b))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Arg a b))
-> (Arg a b -> Constr)
-> (Arg a b -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Arg a b)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Arg a b)))
-> ((forall b. Data b => b -> b) -> Arg a b -> Arg a b)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Arg a b -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Arg a b -> r)
-> (forall u. (forall d. Data d => d -> u) -> Arg a b -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Arg a b -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b))
-> Data (Arg a b)
Arg a b -> Constr
Arg a b -> DataType
(forall b. Data b => b -> b) -> Arg a b -> Arg a b
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Arg a b -> u
forall u. (forall d. Data d => d -> u) -> Arg a b -> [u]
forall a b. (Data a, Data b) => Typeable (Arg a b)
forall a b. (Data a, Data b) => Arg a b -> Constr
forall a b. (Data a, Data b) => Arg a b -> DataType
forall a b.
(Data a, Data b) =>
(forall b. Data b => b -> b) -> Arg a b -> Arg a b
forall a b u.
(Data a, Data b) =>
Int -> (forall d. Data d => d -> u) -> Arg a b -> u
forall a b u.
(Data a, Data b) =>
(forall d. Data d => d -> u) -> Arg a b -> [u]
forall a b r r'.
(Data a, Data b) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Arg a b -> r
forall a b r r'.
(Data a, Data b) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Arg a b -> r
forall a b (m :: * -> *).
(Data a, Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b)
forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b)
forall a b (c :: * -> *).
(Data a, Data b) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Arg a b)
forall a b (c :: * -> *).
(Data a, Data b) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Arg a b -> c (Arg a b)
forall a b (t :: * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Arg a b))
forall a b (t :: * -> * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Arg a b))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Arg a b -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Arg a b -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Arg a b)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Arg a b -> c (Arg a b)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Arg a b))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Arg a b))
$cgfoldl :: forall a b (c :: * -> *).
(Data a, Data b) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Arg a b -> c (Arg a b)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Arg a b -> c (Arg a b)
$cgunfold :: forall a b (c :: * -> *).
(Data a, Data b) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Arg a b)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Arg a b)
$ctoConstr :: forall a b. (Data a, Data b) => Arg a b -> Constr
toConstr :: Arg a b -> Constr
$cdataTypeOf :: forall a b. (Data a, Data b) => Arg a b -> DataType
dataTypeOf :: Arg a b -> DataType
$cdataCast1 :: forall a b (t :: * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Arg a b))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Arg a b))
$cdataCast2 :: forall a b (t :: * -> * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Arg a b))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Arg a b))
$cgmapT :: forall a b.
(Data a, Data b) =>
(forall b. Data b => b -> b) -> Arg a b -> Arg a b
gmapT :: (forall b. Data b => b -> b) -> Arg a b -> Arg a b
$cgmapQl :: forall a b r r'.
(Data a, Data b) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Arg a b -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Arg a b -> r
$cgmapQr :: forall a b r r'.
(Data a, Data b) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Arg a b -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Arg a b -> r
$cgmapQ :: forall a b u.
(Data a, Data b) =>
(forall d. Data d => d -> u) -> Arg a b -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Arg a b -> [u]
$cgmapQi :: forall a b u.
(Data a, Data b) =>
Int -> (forall d. Data d => d -> u) -> Arg a b -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Arg a b -> u
$cgmapM :: forall a b (m :: * -> *).
(Data a, Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b)
$cgmapMp :: forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b)
$cgmapMo :: forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Arg a b -> m (Arg a b)
Data     -- ^ @since 4.9.0.0
  , (forall x. Arg a b -> Rep (Arg a b) x)
-> (forall x. Rep (Arg a b) x -> Arg a b) -> Generic (Arg a b)
forall x. Rep (Arg a b) x -> Arg a b
forall x. Arg a b -> Rep (Arg a b) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a b x. Rep (Arg a b) x -> Arg a b
forall a b x. Arg a b -> Rep (Arg a b) x
$cfrom :: forall a b x. Arg a b -> Rep (Arg a b) x
from :: forall x. Arg a b -> Rep (Arg a b) x
$cto :: forall a b x. Rep (Arg a b) x -> Arg a b
to :: forall x. Rep (Arg a b) x -> Arg a b
Generic  -- ^ @since 4.9.0.0
  , (forall a. Arg a a -> Rep1 (Arg a) a)
-> (forall a. Rep1 (Arg a) a -> Arg a a) -> Generic1 (Arg a)
forall a. Rep1 (Arg a) a -> Arg a a
forall a. Arg a a -> Rep1 (Arg a) a
forall a a. Rep1 (Arg a) a -> Arg a a
forall a a. Arg a a -> Rep1 (Arg a) a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cfrom1 :: forall a a. Arg a a -> Rep1 (Arg a) a
from1 :: forall a. Arg a a -> Rep1 (Arg a) a
$cto1 :: forall a a. Rep1 (Arg a) a -> Arg a a
to1 :: forall a. Rep1 (Arg a) a -> Arg a a
Generic1 -- ^ @since 4.9.0.0
  )

-- |
-- >>> Min (Arg 0 ()) <> Min (Arg 1 ())
-- Min {getMin = Arg 0 ()}
type ArgMin a b = Min (Arg a b)

-- |
-- >>> Max (Arg 0 ()) <> Max (Arg 1 ())
-- Max {getMax = Arg 1 ()}
type ArgMax a b = Max (Arg a b)

-- | @since 4.9.0.0
instance Functor (Arg a) where
  fmap :: forall a b. (a -> b) -> Arg a a -> Arg a b
fmap a -> b
f (Arg a
x a
a) = a -> b -> Arg a b
forall a b. a -> b -> Arg a b
Arg a
x (a -> b
f a
a)

-- | @since 4.9.0.0
instance Foldable (Arg a) where
  foldMap :: forall m a. Monoid m => (a -> m) -> Arg a a -> m
foldMap a -> m
f (Arg a
_ a
a) = a -> m
f a
a

-- | @since 4.9.0.0
instance Traversable (Arg a) where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Arg a a -> f (Arg a b)
traverse a -> f b
f (Arg a
x a
a) = a -> b -> Arg a b
forall a b. a -> b -> Arg a b
Arg a
x (b -> Arg a b) -> f b -> f (Arg a b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a

-- | @since 4.9.0.0
instance Eq a => Eq (Arg a b) where
  Arg a
a b
_ == :: Arg a b -> Arg a b -> Bool
== Arg a
b b
_ = a
a a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
b

-- | @since 4.9.0.0
instance Ord a => Ord (Arg a b) where
  Arg a
a b
_ compare :: Arg a b -> Arg a b -> Ordering
`compare` Arg a
b b
_ = a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare a
a a
b
  min :: Arg a b -> Arg a b -> Arg a b
min x :: Arg a b
x@(Arg a
a b
_) y :: Arg a b
y@(Arg a
b b
_)
    | a
a a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
b    = Arg a b
x
    | Bool
otherwise = Arg a b
y
  max :: Arg a b -> Arg a b -> Arg a b
max x :: Arg a b
x@(Arg a
a b
_) y :: Arg a b
y@(Arg a
b b
_)
    | a
a a -> a -> Bool
forall a. Ord a => a -> a -> Bool
>= a
b    = Arg a b
x
    | Bool
otherwise = Arg a b
y

-- | @since 4.9.0.0
instance Bifunctor Arg where
  bimap :: forall a b c d. (a -> b) -> (c -> d) -> Arg a c -> Arg b d
bimap a -> b
f c -> d
g (Arg a
a c
b) = b -> d -> Arg b d
forall a b. a -> b -> Arg a b
Arg (a -> b
f a
a) (c -> d
g c
b)

-- | @since 4.10.0.0
instance Bifoldable Arg where
  bifoldMap :: forall m a b. Monoid m => (a -> m) -> (b -> m) -> Arg a b -> m
bifoldMap a -> m
f b -> m
g (Arg a
a b
b) = a -> m
f a
a m -> m -> m
forall a. Semigroup a => a -> a -> a
<> b -> m
g b
b

-- | @since 4.10.0.0
instance Bitraversable Arg where
  bitraverse :: forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> Arg a b -> f (Arg c d)
bitraverse a -> f c
f b -> f d
g (Arg a
a b
b) = c -> d -> Arg c d
forall a b. a -> b -> Arg a b
Arg (c -> d -> Arg c d) -> f c -> f (d -> Arg c d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f c
f a
a f (d -> Arg c d) -> f d -> f (Arg c d)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> b -> f d
g b
b

newtype First a = First { forall a. First a -> a
getFirst :: a }
  deriving ( First a
First a -> First a -> Bounded (First a)
forall a. a -> a -> Bounded a
forall a. Bounded a => First a
$cminBound :: forall a. Bounded a => First a
minBound :: First a
$cmaxBound :: forall a. Bounded a => First a
maxBound :: First a
Bounded  -- ^ @since 4.9.0.0
           , First a -> First a -> Bool
(First a -> First a -> Bool)
-> (First a -> First a -> Bool) -> Eq (First a)
forall a. Eq a => First a -> First a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => First a -> First a -> Bool
== :: First a -> First a -> Bool
$c/= :: forall a. Eq a => First a -> First a -> Bool
/= :: First a -> First a -> Bool
Eq       -- ^ @since 4.9.0.0
           , Eq (First a)
Eq (First a) =>
(First a -> First a -> Ordering)
-> (First a -> First a -> Bool)
-> (First a -> First a -> Bool)
-> (First a -> First a -> Bool)
-> (First a -> First a -> Bool)
-> (First a -> First a -> First a)
-> (First a -> First a -> First a)
-> Ord (First a)
First a -> First a -> Bool
First a -> First a -> Ordering
First a -> First a -> First a
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (First a)
forall a. Ord a => First a -> First a -> Bool
forall a. Ord a => First a -> First a -> Ordering
forall a. Ord a => First a -> First a -> First a
$ccompare :: forall a. Ord a => First a -> First a -> Ordering
compare :: First a -> First a -> Ordering
$c< :: forall a. Ord a => First a -> First a -> Bool
< :: First a -> First a -> Bool
$c<= :: forall a. Ord a => First a -> First a -> Bool
<= :: First a -> First a -> Bool
$c> :: forall a. Ord a => First a -> First a -> Bool
> :: First a -> First a -> Bool
$c>= :: forall a. Ord a => First a -> First a -> Bool
>= :: First a -> First a -> Bool
$cmax :: forall a. Ord a => First a -> First a -> First a
max :: First a -> First a -> First a
$cmin :: forall a. Ord a => First a -> First a -> First a
min :: First a -> First a -> First a
Ord      -- ^ @since 4.9.0.0
           , Int -> First a -> ShowS
[First a] -> ShowS
First a -> String
(Int -> First a -> ShowS)
-> (First a -> String) -> ([First a] -> ShowS) -> Show (First a)
forall a. Show a => Int -> First a -> ShowS
forall a. Show a => [First a] -> ShowS
forall a. Show a => First a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> First a -> ShowS
showsPrec :: Int -> First a -> ShowS
$cshow :: forall a. Show a => First a -> String
show :: First a -> String
$cshowList :: forall a. Show a => [First a] -> ShowS
showList :: [First a] -> ShowS
Show     -- ^ @since 4.9.0.0
           , ReadPrec [First a]
ReadPrec (First a)
Int -> ReadS (First a)
ReadS [First a]
(Int -> ReadS (First a))
-> ReadS [First a]
-> ReadPrec (First a)
-> ReadPrec [First a]
-> Read (First a)
forall a. Read a => ReadPrec [First a]
forall a. Read a => ReadPrec (First a)
forall a. Read a => Int -> ReadS (First a)
forall a. Read a => ReadS [First a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (First a)
readsPrec :: Int -> ReadS (First a)
$creadList :: forall a. Read a => ReadS [First a]
readList :: ReadS [First a]
$creadPrec :: forall a. Read a => ReadPrec (First a)
readPrec :: ReadPrec (First a)
$creadListPrec :: forall a. Read a => ReadPrec [First a]
readListPrec :: ReadPrec [First a]
Read     -- ^ @since 4.9.0.0
           , Typeable (First a)
Typeable (First a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> First a -> c (First a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (First a))
-> (First a -> Constr)
-> (First a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (First a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (First a)))
-> ((forall b. Data b => b -> b) -> First a -> First a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> First a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> First a -> r)
-> (forall u. (forall d. Data d => d -> u) -> First a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> First a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> First a -> m (First a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> First a -> m (First a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> First a -> m (First a))
-> Data (First a)
First a -> Constr
First a -> DataType
(forall b. Data b => b -> b) -> First a -> First a
forall a. Data a => Typeable (First a)
forall a. Data a => First a -> Constr
forall a. Data a => First a -> DataType
forall a.
Data a =>
(forall b. Data b => b -> b) -> First a -> First a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> First a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> First a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> First a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> First a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> First a -> m (First a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> First a -> m (First a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (First a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> First a -> c (First a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (First a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (First a))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> First a -> u
forall u. (forall d. Data d => d -> u) -> First a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> First a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> First a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> First a -> m (First a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> First a -> m (First a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (First a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> First a -> c (First a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (First a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (First a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> First a -> c (First a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> First a -> c (First a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (First a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (First a)
$ctoConstr :: forall a. Data a => First a -> Constr
toConstr :: First a -> Constr
$cdataTypeOf :: forall a. Data a => First a -> DataType
dataTypeOf :: First a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (First a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (First a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (First a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (First a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> First a -> First a
gmapT :: (forall b. Data b => b -> b) -> First a -> First a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> First a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> First a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> First a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> First a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> First a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> First a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> First a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> First a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> First a -> m (First a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> First a -> m (First a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> First a -> m (First a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> First a -> m (First a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> First a -> m (First a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> First a -> m (First a)
Data     -- ^ @since 4.9.0.0
           , (forall x. First a -> Rep (First a) x)
-> (forall x. Rep (First a) x -> First a) -> Generic (First a)
forall x. Rep (First a) x -> First a
forall x. First a -> Rep (First a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (First a) x -> First a
forall a x. First a -> Rep (First a) x
$cfrom :: forall a x. First a -> Rep (First a) x
from :: forall x. First a -> Rep (First a) x
$cto :: forall a x. Rep (First a) x -> First a
to :: forall x. Rep (First a) x -> First a
Generic  -- ^ @since 4.9.0.0
           , (forall a. First a -> Rep1 First a)
-> (forall a. Rep1 First a -> First a) -> Generic1 First
forall a. Rep1 First a -> First a
forall a. First a -> Rep1 First a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cfrom1 :: forall a. First a -> Rep1 First a
from1 :: forall a. First a -> Rep1 First a
$cto1 :: forall a. Rep1 First a -> First a
to1 :: forall a. Rep1 First a -> First a
Generic1 -- ^ @since 4.9.0.0
           )

-- | @since 4.9.0.0
instance Enum a => Enum (First a) where
  succ :: First a -> First a
succ (First a
a) = a -> First a
forall a. a -> First a
First (a -> a
forall a. Enum a => a -> a
succ a
a)
  pred :: First a -> First a
pred (First a
a) = a -> First a
forall a. a -> First a
First (a -> a
forall a. Enum a => a -> a
pred a
a)
  toEnum :: Int -> First a
toEnum = a -> First a
forall a. a -> First a
First (a -> First a) -> (Int -> a) -> Int -> First a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a
forall a. Enum a => Int -> a
toEnum
  fromEnum :: First a -> Int
fromEnum = a -> Int
forall a. Enum a => a -> Int
fromEnum (a -> Int) -> (First a -> a) -> First a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. First a -> a
forall a. First a -> a
getFirst
  enumFrom :: First a -> [First a]
enumFrom (First a
a) = a -> First a
forall a. a -> First a
First (a -> First a) -> [a] -> [First a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> [a]
forall a. Enum a => a -> [a]
enumFrom a
a
  enumFromThen :: First a -> First a -> [First a]
enumFromThen (First a
a) (First a
b) = a -> First a
forall a. a -> First a
First (a -> First a) -> [a] -> [First a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> [a]
forall a. Enum a => a -> a -> [a]
enumFromThen a
a a
b
  enumFromTo :: First a -> First a -> [First a]
enumFromTo (First a
a) (First a
b) = a -> First a
forall a. a -> First a
First (a -> First a) -> [a] -> [First a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> [a]
forall a. Enum a => a -> a -> [a]
enumFromTo a
a a
b
  enumFromThenTo :: First a -> First a -> First a -> [First a]
enumFromThenTo (First a
a) (First a
b) (First a
c) = a -> First a
forall a. a -> First a
First (a -> First a) -> [a] -> [First a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> a -> [a]
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo a
a a
b a
c

-- | @since 4.9.0.0
instance Semigroup (First a) where
  First a
a <> :: First a -> First a -> First a
<> First a
_ = First a
a
  stimes :: forall b. Integral b => b -> First a -> First a
stimes = b -> First a -> First a
forall b a. Integral b => b -> a -> a
stimesIdempotent

-- | @since 4.9.0.0
instance Functor First where
  fmap :: forall a b. (a -> b) -> First a -> First b
fmap a -> b
f (First a
x) = b -> First b
forall a. a -> First a
First (a -> b
f a
x)

-- | @since 4.9.0.0
instance Foldable First where
  foldMap :: forall m a. Monoid m => (a -> m) -> First a -> m
foldMap a -> m
f (First a
a) = a -> m
f a
a

-- | @since 4.9.0.0
instance Traversable First where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> First a -> f (First b)
traverse a -> f b
f (First a
a) = b -> First b
forall a. a -> First a
First (b -> First b) -> f b -> f (First b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a

-- | @since 4.9.0.0
instance Applicative First where
  pure :: forall a. a -> First a
pure a
x = a -> First a
forall a. a -> First a
First a
x
  First a
a <* :: forall a b. First a -> First b -> First a
<* First b
_ = First a
a
  First a
_ *> :: forall a b. First a -> First b -> First b
*> First b
a = First b
a
  <*> :: forall a b. First (a -> b) -> First a -> First b
(<*>) = First (a -> b) -> First a -> First b
forall a b. Coercible a b => a -> b
coerce
  liftA2 :: forall a b c. (a -> b -> c) -> First a -> First b -> First c
liftA2 = (a -> b -> c) -> First a -> First b -> First c
forall a b. Coercible a b => a -> b
coerce

-- | @since 4.9.0.0
instance Monad First where
  >> :: forall a b. First a -> First b -> First b
(>>) = First a -> First b -> First b
forall a b. First a -> First b -> First b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
  First a
a >>= :: forall a b. First a -> (a -> First b) -> First b
>>= a -> First b
f = a -> First b
f a
a

-- | @since 4.9.0.0
instance MonadFix First where
  mfix :: forall a. (a -> First a) -> First a
mfix a -> First a
f = (First a -> First a) -> First a
forall a. (a -> a) -> a
fix (a -> First a
f (a -> First a) -> (First a -> a) -> First a -> First a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. First a -> a
forall a. First a -> a
getFirst)

newtype Last a = Last { forall a. Last a -> a
getLast :: a }
  deriving ( Last a
Last a -> Last a -> Bounded (Last a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Last a
$cminBound :: forall a. Bounded a => Last a
minBound :: Last a
$cmaxBound :: forall a. Bounded a => Last a
maxBound :: Last a
Bounded  -- ^ @since 4.9.0.0
           , Last a -> Last a -> Bool
(Last a -> Last a -> Bool)
-> (Last a -> Last a -> Bool) -> Eq (Last a)
forall a. Eq a => Last a -> Last a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Last a -> Last a -> Bool
== :: Last a -> Last a -> Bool
$c/= :: forall a. Eq a => Last a -> Last a -> Bool
/= :: Last a -> Last a -> Bool
Eq       -- ^ @since 4.9.0.0
           , Eq (Last a)
Eq (Last a) =>
(Last a -> Last a -> Ordering)
-> (Last a -> Last a -> Bool)
-> (Last a -> Last a -> Bool)
-> (Last a -> Last a -> Bool)
-> (Last a -> Last a -> Bool)
-> (Last a -> Last a -> Last a)
-> (Last a -> Last a -> Last a)
-> Ord (Last a)
Last a -> Last a -> Bool
Last a -> Last a -> Ordering
Last a -> Last a -> Last a
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Last a)
forall a. Ord a => Last a -> Last a -> Bool
forall a. Ord a => Last a -> Last a -> Ordering
forall a. Ord a => Last a -> Last a -> Last a
$ccompare :: forall a. Ord a => Last a -> Last a -> Ordering
compare :: Last a -> Last a -> Ordering
$c< :: forall a. Ord a => Last a -> Last a -> Bool
< :: Last a -> Last a -> Bool
$c<= :: forall a. Ord a => Last a -> Last a -> Bool
<= :: Last a -> Last a -> Bool
$c> :: forall a. Ord a => Last a -> Last a -> Bool
> :: Last a -> Last a -> Bool
$c>= :: forall a. Ord a => Last a -> Last a -> Bool
>= :: Last a -> Last a -> Bool
$cmax :: forall a. Ord a => Last a -> Last a -> Last a
max :: Last a -> Last a -> Last a
$cmin :: forall a. Ord a => Last a -> Last a -> Last a
min :: Last a -> Last a -> Last a
Ord      -- ^ @since 4.9.0.0
           , Int -> Last a -> ShowS
[Last a] -> ShowS
Last a -> String
(Int -> Last a -> ShowS)
-> (Last a -> String) -> ([Last a] -> ShowS) -> Show (Last a)
forall a. Show a => Int -> Last a -> ShowS
forall a. Show a => [Last a] -> ShowS
forall a. Show a => Last a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Last a -> ShowS
showsPrec :: Int -> Last a -> ShowS
$cshow :: forall a. Show a => Last a -> String
show :: Last a -> String
$cshowList :: forall a. Show a => [Last a] -> ShowS
showList :: [Last a] -> ShowS
Show     -- ^ @since 4.9.0.0
           , ReadPrec [Last a]
ReadPrec (Last a)
Int -> ReadS (Last a)
ReadS [Last a]
(Int -> ReadS (Last a))
-> ReadS [Last a]
-> ReadPrec (Last a)
-> ReadPrec [Last a]
-> Read (Last a)
forall a. Read a => ReadPrec [Last a]
forall a. Read a => ReadPrec (Last a)
forall a. Read a => Int -> ReadS (Last a)
forall a. Read a => ReadS [Last a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (Last a)
readsPrec :: Int -> ReadS (Last a)
$creadList :: forall a. Read a => ReadS [Last a]
readList :: ReadS [Last a]
$creadPrec :: forall a. Read a => ReadPrec (Last a)
readPrec :: ReadPrec (Last a)
$creadListPrec :: forall a. Read a => ReadPrec [Last a]
readListPrec :: ReadPrec [Last a]
Read     -- ^ @since 4.9.0.0
           , Typeable (Last a)
Typeable (Last a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Last a -> c (Last a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Last a))
-> (Last a -> Constr)
-> (Last a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Last a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Last a)))
-> ((forall b. Data b => b -> b) -> Last a -> Last a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Last a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Last a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Last a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Last a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Last a -> m (Last a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Last a -> m (Last a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Last a -> m (Last a))
-> Data (Last a)
Last a -> Constr
Last a -> DataType
(forall b. Data b => b -> b) -> Last a -> Last a
forall a. Data a => Typeable (Last a)
forall a. Data a => Last a -> Constr
forall a. Data a => Last a -> DataType
forall a.
Data a =>
(forall b. Data b => b -> b) -> Last a -> Last a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Last a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> Last a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Last a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Last a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Last a -> m (Last a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Last a -> m (Last a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Last a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Last a -> c (Last a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Last a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Last a))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Last a -> u
forall u. (forall d. Data d => d -> u) -> Last a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Last a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Last a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Last a -> m (Last a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Last a -> m (Last a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Last a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Last a -> c (Last a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Last a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Last a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Last a -> c (Last a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Last a -> c (Last a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Last a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Last a)
$ctoConstr :: forall a. Data a => Last a -> Constr
toConstr :: Last a -> Constr
$cdataTypeOf :: forall a. Data a => Last a -> DataType
dataTypeOf :: Last a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Last a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Last a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Last a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Last a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Last a -> Last a
gmapT :: (forall b. Data b => b -> b) -> Last a -> Last a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Last a -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Last a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Last a -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Last a -> r
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> Last a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Last a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Last a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Last a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Last a -> m (Last a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Last a -> m (Last a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Last a -> m (Last a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Last a -> m (Last a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Last a -> m (Last a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Last a -> m (Last a)
Data     -- ^ @since 4.9.0.0
           , (forall x. Last a -> Rep (Last a) x)
-> (forall x. Rep (Last a) x -> Last a) -> Generic (Last a)
forall x. Rep (Last a) x -> Last a
forall x. Last a -> Rep (Last a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Last a) x -> Last a
forall a x. Last a -> Rep (Last a) x
$cfrom :: forall a x. Last a -> Rep (Last a) x
from :: forall x. Last a -> Rep (Last a) x
$cto :: forall a x. Rep (Last a) x -> Last a
to :: forall x. Rep (Last a) x -> Last a
Generic  -- ^ @since 4.9.0.0
           , (forall a. Last a -> Rep1 Last a)
-> (forall a. Rep1 Last a -> Last a) -> Generic1 Last
forall a. Rep1 Last a -> Last a
forall a. Last a -> Rep1 Last a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cfrom1 :: forall a. Last a -> Rep1 Last a
from1 :: forall a. Last a -> Rep1 Last a
$cto1 :: forall a. Rep1 Last a -> Last a
to1 :: forall a. Rep1 Last a -> Last a
Generic1 -- ^ @since 4.9.0.0
           )

-- | @since 4.9.0.0
instance Enum a => Enum (Last a) where
  succ :: Last a -> Last a
succ (Last a
a) = a -> Last a
forall a. a -> Last a
Last (a -> a
forall a. Enum a => a -> a
succ a
a)
  pred :: Last a -> Last a
pred (Last a
a) = a -> Last a
forall a. a -> Last a
Last (a -> a
forall a. Enum a => a -> a
pred a
a)
  toEnum :: Int -> Last a
toEnum = a -> Last a
forall a. a -> Last a
Last (a -> Last a) -> (Int -> a) -> Int -> Last a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a
forall a. Enum a => Int -> a
toEnum
  fromEnum :: Last a -> Int
fromEnum = a -> Int
forall a. Enum a => a -> Int
fromEnum (a -> Int) -> (Last a -> a) -> Last a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Last a -> a
forall a. Last a -> a
getLast
  enumFrom :: Last a -> [Last a]
enumFrom (Last a
a) = a -> Last a
forall a. a -> Last a
Last (a -> Last a) -> [a] -> [Last a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> [a]
forall a. Enum a => a -> [a]
enumFrom a
a
  enumFromThen :: Last a -> Last a -> [Last a]
enumFromThen (Last a
a) (Last a
b) = a -> Last a
forall a. a -> Last a
Last (a -> Last a) -> [a] -> [Last a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> [a]
forall a. Enum a => a -> a -> [a]
enumFromThen a
a a
b
  enumFromTo :: Last a -> Last a -> [Last a]
enumFromTo (Last a
a) (Last a
b) = a -> Last a
forall a. a -> Last a
Last (a -> Last a) -> [a] -> [Last a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> [a]
forall a. Enum a => a -> a -> [a]
enumFromTo a
a a
b
  enumFromThenTo :: Last a -> Last a -> Last a -> [Last a]
enumFromThenTo (Last a
a) (Last a
b) (Last a
c) = a -> Last a
forall a. a -> Last a
Last (a -> Last a) -> [a] -> [Last a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> a -> [a]
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo a
a a
b a
c

-- | @since 4.9.0.0
instance Semigroup (Last a) where
  Last a
_ <> :: Last a -> Last a -> Last a
<> Last a
b = Last a
b
  stimes :: forall b. Integral b => b -> Last a -> Last a
stimes = b -> Last a -> Last a
forall b a. Integral b => b -> a -> a
stimesIdempotent

-- | @since 4.9.0.0
instance Functor Last where
  fmap :: forall a b. (a -> b) -> Last a -> Last b
fmap a -> b
f (Last a
x) = b -> Last b
forall a. a -> Last a
Last (a -> b
f a
x)
  a
a <$ :: forall a b. a -> Last b -> Last a
<$ Last b
_ = a -> Last a
forall a. a -> Last a
Last a
a

-- | @since 4.9.0.0
instance Foldable Last where
  foldMap :: forall m a. Monoid m => (a -> m) -> Last a -> m
foldMap a -> m
f (Last a
a) = a -> m
f a
a

-- | @since 4.9.0.0
instance Traversable Last where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Last a -> f (Last b)
traverse a -> f b
f (Last a
a) = b -> Last b
forall a. a -> Last a
Last (b -> Last b) -> f b -> f (Last b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a

-- | @since 4.9.0.0
instance Applicative Last where
  pure :: forall a. a -> Last a
pure = a -> Last a
forall a. a -> Last a
Last
  Last a
a <* :: forall a b. Last a -> Last b -> Last a
<* Last b
_ = Last a
a
  Last a
_ *> :: forall a b. Last a -> Last b -> Last b
*> Last b
a = Last b
a
  <*> :: forall a b. Last (a -> b) -> Last a -> Last b
(<*>) = Last (a -> b) -> Last a -> Last b
forall a b. Coercible a b => a -> b
coerce
  liftA2 :: forall a b c. (a -> b -> c) -> Last a -> Last b -> Last c
liftA2 = (a -> b -> c) -> Last a -> Last b -> Last c
forall a b. Coercible a b => a -> b
coerce

-- | @since 4.9.0.0
instance Monad Last where
  >> :: forall a b. Last a -> Last b -> Last b
(>>) = Last a -> Last b -> Last b
forall a b. Last a -> Last b -> Last b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
  Last a
a >>= :: forall a b. Last a -> (a -> Last b) -> Last b
>>= a -> Last b
f = a -> Last b
f a
a

-- | @since 4.9.0.0
instance MonadFix Last where
  mfix :: forall a. (a -> Last a) -> Last a
mfix a -> Last a
f = (Last a -> Last a) -> Last a
forall a. (a -> a) -> a
fix (a -> Last a
f (a -> Last a) -> (Last a -> a) -> Last a -> Last a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Last a -> a
forall a. Last a -> a
getLast)

-- | Provide a Semigroup for an arbitrary Monoid.
--
-- __NOTE__: This is not needed anymore since 'Semigroup' became a superclass of
-- 'Monoid' in /base-4.11/ and this newtype be deprecated at some point in the future.
newtype WrappedMonoid m = WrapMonoid { forall m. WrappedMonoid m -> m
unwrapMonoid :: m }
  deriving ( WrappedMonoid m
WrappedMonoid m -> WrappedMonoid m -> Bounded (WrappedMonoid m)
forall a. a -> a -> Bounded a
forall m. Bounded m => WrappedMonoid m
$cminBound :: forall m. Bounded m => WrappedMonoid m
minBound :: WrappedMonoid m
$cmaxBound :: forall m. Bounded m => WrappedMonoid m
maxBound :: WrappedMonoid m
Bounded  -- ^ @since 4.9.0.0
           , WrappedMonoid m -> WrappedMonoid m -> Bool
(WrappedMonoid m -> WrappedMonoid m -> Bool)
-> (WrappedMonoid m -> WrappedMonoid m -> Bool)
-> Eq (WrappedMonoid m)
forall m. Eq m => WrappedMonoid m -> WrappedMonoid m -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall m. Eq m => WrappedMonoid m -> WrappedMonoid m -> Bool
== :: WrappedMonoid m -> WrappedMonoid m -> Bool
$c/= :: forall m. Eq m => WrappedMonoid m -> WrappedMonoid m -> Bool
/= :: WrappedMonoid m -> WrappedMonoid m -> Bool
Eq       -- ^ @since 4.9.0.0
           , Eq (WrappedMonoid m)
Eq (WrappedMonoid m) =>
(WrappedMonoid m -> WrappedMonoid m -> Ordering)
-> (WrappedMonoid m -> WrappedMonoid m -> Bool)
-> (WrappedMonoid m -> WrappedMonoid m -> Bool)
-> (WrappedMonoid m -> WrappedMonoid m -> Bool)
-> (WrappedMonoid m -> WrappedMonoid m -> Bool)
-> (WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m)
-> (WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m)
-> Ord (WrappedMonoid m)
WrappedMonoid m -> WrappedMonoid m -> Bool
WrappedMonoid m -> WrappedMonoid m -> Ordering
WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall m. Ord m => Eq (WrappedMonoid m)
forall m. Ord m => WrappedMonoid m -> WrappedMonoid m -> Bool
forall m. Ord m => WrappedMonoid m -> WrappedMonoid m -> Ordering
forall m.
Ord m =>
WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m
$ccompare :: forall m. Ord m => WrappedMonoid m -> WrappedMonoid m -> Ordering
compare :: WrappedMonoid m -> WrappedMonoid m -> Ordering
$c< :: forall m. Ord m => WrappedMonoid m -> WrappedMonoid m -> Bool
< :: WrappedMonoid m -> WrappedMonoid m -> Bool
$c<= :: forall m. Ord m => WrappedMonoid m -> WrappedMonoid m -> Bool
<= :: WrappedMonoid m -> WrappedMonoid m -> Bool
$c> :: forall m. Ord m => WrappedMonoid m -> WrappedMonoid m -> Bool
> :: WrappedMonoid m -> WrappedMonoid m -> Bool
$c>= :: forall m. Ord m => WrappedMonoid m -> WrappedMonoid m -> Bool
>= :: WrappedMonoid m -> WrappedMonoid m -> Bool
$cmax :: forall m.
Ord m =>
WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m
max :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m
$cmin :: forall m.
Ord m =>
WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m
min :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m
Ord      -- ^ @since 4.9.0.0
           , Int -> WrappedMonoid m -> ShowS
[WrappedMonoid m] -> ShowS
WrappedMonoid m -> String
(Int -> WrappedMonoid m -> ShowS)
-> (WrappedMonoid m -> String)
-> ([WrappedMonoid m] -> ShowS)
-> Show (WrappedMonoid m)
forall m. Show m => Int -> WrappedMonoid m -> ShowS
forall m. Show m => [WrappedMonoid m] -> ShowS
forall m. Show m => WrappedMonoid m -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall m. Show m => Int -> WrappedMonoid m -> ShowS
showsPrec :: Int -> WrappedMonoid m -> ShowS
$cshow :: forall m. Show m => WrappedMonoid m -> String
show :: WrappedMonoid m -> String
$cshowList :: forall m. Show m => [WrappedMonoid m] -> ShowS
showList :: [WrappedMonoid m] -> ShowS
Show     -- ^ @since 4.9.0.0
           , ReadPrec [WrappedMonoid m]
ReadPrec (WrappedMonoid m)
Int -> ReadS (WrappedMonoid m)
ReadS [WrappedMonoid m]
(Int -> ReadS (WrappedMonoid m))
-> ReadS [WrappedMonoid m]
-> ReadPrec (WrappedMonoid m)
-> ReadPrec [WrappedMonoid m]
-> Read (WrappedMonoid m)
forall m. Read m => ReadPrec [WrappedMonoid m]
forall m. Read m => ReadPrec (WrappedMonoid m)
forall m. Read m => Int -> ReadS (WrappedMonoid m)
forall m. Read m => ReadS [WrappedMonoid m]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall m. Read m => Int -> ReadS (WrappedMonoid m)
readsPrec :: Int -> ReadS (WrappedMonoid m)
$creadList :: forall m. Read m => ReadS [WrappedMonoid m]
readList :: ReadS [WrappedMonoid m]
$creadPrec :: forall m. Read m => ReadPrec (WrappedMonoid m)
readPrec :: ReadPrec (WrappedMonoid m)
$creadListPrec :: forall m. Read m => ReadPrec [WrappedMonoid m]
readListPrec :: ReadPrec [WrappedMonoid m]
Read     -- ^ @since 4.9.0.0
           , Typeable (WrappedMonoid m)
Typeable (WrappedMonoid m) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> WrappedMonoid m -> c (WrappedMonoid m))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (WrappedMonoid m))
-> (WrappedMonoid m -> Constr)
-> (WrappedMonoid m -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (WrappedMonoid m)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (WrappedMonoid m)))
-> ((forall b. Data b => b -> b)
    -> WrappedMonoid m -> WrappedMonoid m)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> WrappedMonoid m -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> WrappedMonoid m -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> WrappedMonoid m -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> WrappedMonoid m -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> WrappedMonoid m -> m (WrappedMonoid m))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> WrappedMonoid m -> m (WrappedMonoid m))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> WrappedMonoid m -> m (WrappedMonoid m))
-> Data (WrappedMonoid m)
WrappedMonoid m -> Constr
WrappedMonoid m -> DataType
(forall b. Data b => b -> b) -> WrappedMonoid m -> WrappedMonoid m
forall m. Data m => Typeable (WrappedMonoid m)
forall m. Data m => WrappedMonoid m -> Constr
forall m. Data m => WrappedMonoid m -> DataType
forall m.
Data m =>
(forall b. Data b => b -> b) -> WrappedMonoid m -> WrappedMonoid m
forall m u.
Data m =>
Int -> (forall d. Data d => d -> u) -> WrappedMonoid m -> u
forall m u.
Data m =>
(forall d. Data d => d -> u) -> WrappedMonoid m -> [u]
forall m r r'.
Data m =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WrappedMonoid m -> r
forall m r r'.
Data m =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WrappedMonoid m -> r
forall m (m :: * -> *).
(Data m, Monad m) =>
(forall d. Data d => d -> m d)
-> WrappedMonoid m -> m (WrappedMonoid m)
forall m (m :: * -> *).
(Data m, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> WrappedMonoid m -> m (WrappedMonoid m)
forall m (c :: * -> *).
Data m =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WrappedMonoid m)
forall m (c :: * -> *).
Data m =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WrappedMonoid m -> c (WrappedMonoid m)
forall m (t :: * -> *) (c :: * -> *).
(Data m, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (WrappedMonoid m))
forall m (t :: * -> * -> *) (c :: * -> *).
(Data m, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WrappedMonoid m))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> WrappedMonoid m -> u
forall u. (forall d. Data d => d -> u) -> WrappedMonoid m -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WrappedMonoid m -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WrappedMonoid m -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> WrappedMonoid m -> m (WrappedMonoid m)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> WrappedMonoid m -> m (WrappedMonoid m)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WrappedMonoid m)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WrappedMonoid m -> c (WrappedMonoid m)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (WrappedMonoid m))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WrappedMonoid m))
$cgfoldl :: forall m (c :: * -> *).
Data m =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WrappedMonoid m -> c (WrappedMonoid m)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WrappedMonoid m -> c (WrappedMonoid m)
$cgunfold :: forall m (c :: * -> *).
Data m =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WrappedMonoid m)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WrappedMonoid m)
$ctoConstr :: forall m. Data m => WrappedMonoid m -> Constr
toConstr :: WrappedMonoid m -> Constr
$cdataTypeOf :: forall m. Data m => WrappedMonoid m -> DataType
dataTypeOf :: WrappedMonoid m -> DataType
$cdataCast1 :: forall m (t :: * -> *) (c :: * -> *).
(Data m, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (WrappedMonoid m))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (WrappedMonoid m))
$cdataCast2 :: forall m (t :: * -> * -> *) (c :: * -> *).
(Data m, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WrappedMonoid m))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WrappedMonoid m))
$cgmapT :: forall m.
Data m =>
(forall b. Data b => b -> b) -> WrappedMonoid m -> WrappedMonoid m
gmapT :: (forall b. Data b => b -> b) -> WrappedMonoid m -> WrappedMonoid m
$cgmapQl :: forall m r r'.
Data m =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WrappedMonoid m -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WrappedMonoid m -> r
$cgmapQr :: forall m r r'.
Data m =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WrappedMonoid m -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WrappedMonoid m -> r
$cgmapQ :: forall m u.
Data m =>
(forall d. Data d => d -> u) -> WrappedMonoid m -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> WrappedMonoid m -> [u]
$cgmapQi :: forall m u.
Data m =>
Int -> (forall d. Data d => d -> u) -> WrappedMonoid m -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> WrappedMonoid m -> u
$cgmapM :: forall m (m :: * -> *).
(Data m, Monad m) =>
(forall d. Data d => d -> m d)
-> WrappedMonoid m -> m (WrappedMonoid m)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> WrappedMonoid m -> m (WrappedMonoid m)
$cgmapMp :: forall m (m :: * -> *).
(Data m, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> WrappedMonoid m -> m (WrappedMonoid m)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> WrappedMonoid m -> m (WrappedMonoid m)
$cgmapMo :: forall m (m :: * -> *).
(Data m, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> WrappedMonoid m -> m (WrappedMonoid m)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> WrappedMonoid m -> m (WrappedMonoid m)
Data     -- ^ @since 4.9.0.0
           , (forall x. WrappedMonoid m -> Rep (WrappedMonoid m) x)
-> (forall x. Rep (WrappedMonoid m) x -> WrappedMonoid m)
-> Generic (WrappedMonoid m)
forall x. Rep (WrappedMonoid m) x -> WrappedMonoid m
forall x. WrappedMonoid m -> Rep (WrappedMonoid m) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall m x. Rep (WrappedMonoid m) x -> WrappedMonoid m
forall m x. WrappedMonoid m -> Rep (WrappedMonoid m) x
$cfrom :: forall m x. WrappedMonoid m -> Rep (WrappedMonoid m) x
from :: forall x. WrappedMonoid m -> Rep (WrappedMonoid m) x
$cto :: forall m x. Rep (WrappedMonoid m) x -> WrappedMonoid m
to :: forall x. Rep (WrappedMonoid m) x -> WrappedMonoid m
Generic  -- ^ @since 4.9.0.0
           , (forall a. WrappedMonoid a -> Rep1 WrappedMonoid a)
-> (forall a. Rep1 WrappedMonoid a -> WrappedMonoid a)
-> Generic1 WrappedMonoid
forall a. Rep1 WrappedMonoid a -> WrappedMonoid a
forall a. WrappedMonoid a -> Rep1 WrappedMonoid a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cfrom1 :: forall a. WrappedMonoid a -> Rep1 WrappedMonoid a
from1 :: forall a. WrappedMonoid a -> Rep1 WrappedMonoid a
$cto1 :: forall a. Rep1 WrappedMonoid a -> WrappedMonoid a
to1 :: forall a. Rep1 WrappedMonoid a -> WrappedMonoid a
Generic1 -- ^ @since 4.9.0.0
           )

-- | @since 4.9.0.0
instance Monoid m => Semigroup (WrappedMonoid m) where
  <> :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m
(<>) = (m -> m -> m)
-> WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m
forall a b. Coercible a b => a -> b
coerce (m -> m -> m
forall a. Monoid a => a -> a -> a
mappend :: m -> m -> m)

-- | @since 4.9.0.0
instance Monoid m => Monoid (WrappedMonoid m) where
  mempty :: WrappedMonoid m
mempty = m -> WrappedMonoid m
forall m. m -> WrappedMonoid m
WrapMonoid m
forall a. Monoid a => a
mempty
  -- This ensures that we use whatever mconcat is defined for the wrapped
  -- Monoid.
  mconcat :: [WrappedMonoid m] -> WrappedMonoid m
mconcat = ([m] -> m) -> [WrappedMonoid m] -> WrappedMonoid m
forall a b. Coercible a b => a -> b
coerce ([m] -> m
forall a. Monoid a => [a] -> a
mconcat :: [m] -> m)

-- | @since 4.9.0.0
instance Enum a => Enum (WrappedMonoid a) where
  succ :: WrappedMonoid a -> WrappedMonoid a
succ (WrapMonoid a
a) = a -> WrappedMonoid a
forall m. m -> WrappedMonoid m
WrapMonoid (a -> a
forall a. Enum a => a -> a
succ a
a)
  pred :: WrappedMonoid a -> WrappedMonoid a
pred (WrapMonoid a
a) = a -> WrappedMonoid a
forall m. m -> WrappedMonoid m
WrapMonoid (a -> a
forall a. Enum a => a -> a
pred a
a)
  toEnum :: Int -> WrappedMonoid a
toEnum = a -> WrappedMonoid a
forall m. m -> WrappedMonoid m
WrapMonoid (a -> WrappedMonoid a) -> (Int -> a) -> Int -> WrappedMonoid a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a
forall a. Enum a => Int -> a
toEnum
  fromEnum :: WrappedMonoid a -> Int
fromEnum = a -> Int
forall a. Enum a => a -> Int
fromEnum (a -> Int) -> (WrappedMonoid a -> a) -> WrappedMonoid a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedMonoid a -> a
forall m. WrappedMonoid m -> m
unwrapMonoid
  enumFrom :: WrappedMonoid a -> [WrappedMonoid a]
enumFrom (WrapMonoid a
a) = a -> WrappedMonoid a
forall m. m -> WrappedMonoid m
WrapMonoid (a -> WrappedMonoid a) -> [a] -> [WrappedMonoid a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> [a]
forall a. Enum a => a -> [a]
enumFrom a
a
  enumFromThen :: WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a]
enumFromThen (WrapMonoid a
a) (WrapMonoid a
b) = a -> WrappedMonoid a
forall m. m -> WrappedMonoid m
WrapMonoid (a -> WrappedMonoid a) -> [a] -> [WrappedMonoid a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> [a]
forall a. Enum a => a -> a -> [a]
enumFromThen a
a a
b
  enumFromTo :: WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a]
enumFromTo (WrapMonoid a
a) (WrapMonoid a
b) = a -> WrappedMonoid a
forall m. m -> WrappedMonoid m
WrapMonoid (a -> WrappedMonoid a) -> [a] -> [WrappedMonoid a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> [a]
forall a. Enum a => a -> a -> [a]
enumFromTo a
a a
b
  enumFromThenTo :: WrappedMonoid a
-> WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a]
enumFromThenTo (WrapMonoid a
a) (WrapMonoid a
b) (WrapMonoid a
c) =
      a -> WrappedMonoid a
forall m. m -> WrappedMonoid m
WrapMonoid (a -> WrappedMonoid a) -> [a] -> [WrappedMonoid a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> a -> a -> [a]
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo a
a a
b a
c

-- | Repeat a value @n@ times.
--
-- > mtimesDefault n a = a <> a <> ... <> a  -- using <> (n-1) times
--
-- In many cases, `stimes 0 a` for a `Monoid` will produce `mempty`.
-- However, there are situations when it cannot do so. In particular,
-- the following situation is fairly common:
--
-- @
-- data T a = ...
--
-- class Constraint1 a
-- class Constraint1 a => Constraint2 a
--
-- @
-- instance Constraint1 a => 'Semigroup' (T a)
-- instance Constraint2 a => 'Monoid' (T a)
-- @
--
-- Since @Constraint1@ is insufficient to implement 'mempty',
-- 'stimes' for @T a@ cannot do so.
--
-- When working with such a type, or when working polymorphically with
-- 'Semigroup' instances, @mtimesDefault@ should be used when the
-- multiplier might be zero. It is implemented using 'stimes' when
-- the multiplier is nonzero and 'mempty' when it is zero.
mtimesDefault :: (Integral b, Monoid a) => b -> a -> a
mtimesDefault :: forall b a. (Integral b, Monoid a) => b -> a -> a
mtimesDefault b
n a
x
  | b
n b -> b -> Bool
forall a. Eq a => a -> a -> Bool
== b
0    = a
forall a. Monoid a => a
mempty
  | Bool
otherwise = b -> a -> a
forall b. Integral b => b -> a -> a
forall a b. (Semigroup a, Integral b) => b -> a -> a
stimes b
n a
x