Relude.Monoid

relude-1.2.2.0: Safe, performant, user-friendly and lightweight Haskell Standard Library

Copyright | (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 Kowainik
License | MIT
Maintainer | Kowainik <xrom.xkov@gmail.com>
Stability | Stable
Portability | Portable
Safe Haskell | Safe
Language | Haskell2010

Relude.Monoid

Contents

- Reexports
- Combinators

Description

Reexports functions to work with monoids plus adds extra useful functions.

Synopsis

- newtype Any = Any {
  - getAny :: Bool
  }
- newtype Last a = Last {
  - getLast :: Maybe a
  }
- newtype First a = First {
  - getFirst :: Maybe a
  }
- class Semigroup a => Monoid a where
  - mempty :: a
  - mappend :: a -> a -> a
  - mconcat :: [a] -> a
- newtype Alt (f :: k -> Type) (a :: k) = Alt {
  - getAlt :: f a
  }
- newtype Product a = Product {
  - getProduct :: a
  }
- newtype Sum a = Sum {
  - getSum :: a
  }
- newtype All = All {
  - getAll :: Bool
  }
- newtype Endo a = Endo {
  - appEndo :: a -> a
  }
- newtype Dual a = Dual {
  - getDual :: a
  }
- newtype Ap (f :: k -> Type) (a :: k) = Ap {
  - getAp :: f a
  }
- class Semigroup a where
  - (<>) :: a -> a -> a
  - sconcat :: NonEmpty a -> a
  - stimes :: Integral b => b -> a -> a
- stimesIdempotent :: Integral b => b -> a -> a
- stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> a
- stimesMonoid :: (Integral b, Monoid a) => b -> a -> a
- data WrappedMonoid m
- cycle1 :: Semigroup m => m -> m
- mtimesDefault :: (Integral b, Monoid a) => b -> a -> a
- newtype Ap (f :: k -> Type) (a :: k) = Ap {
  - getAp :: f a
  }
- maybeToMonoid :: Monoid m => Maybe m -> m
- memptyIfFalse :: Monoid m => Bool -> m -> m
- memptyIfTrue :: Monoid m => Bool -> m -> m

# Reexports

newtype Any #

Boolean monoid under disjunction `(||)`.

    Any x <> Any y = Any (x || y)

#### Examples

Expand

    >>> Any True <> mempty <> Any False
    Any {getAny = True}

    >>> mconcat (map (\x -> Any (even x)) [2,4,6,7,8])
    Any {getAny = True}

    >>> Any False <> mempty
    Any {getAny = False}

Constructors

Any |
Fields getAny :: Bool

#### Instances

Instances details

NFData Any | Since: deepseq-1.4.0.0
Instance details Defined in Control.DeepSeq Methods rnf :: Any -> () #
Monoid Any | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Any # mappend :: Any -> Any -> Any # mconcat :: [Any] -> Any #
Semigroup Any | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Any -> Any -> Any # sconcat :: NonEmpty Any -> Any # stimes :: Integral b => b -> Any -> Any #
Data Any | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Any -> c Any # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Any # toConstr :: Any -> Constr # dataTypeOf :: Any -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Any) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Any) # gmapT :: (forall b. Data b => b -> b) -> Any -> Any # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Any -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Any -> r # gmapQ :: (forall d. Data d => d -> u) -> Any -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Any -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Any -> m Any # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Any -> m Any # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Any -> m Any #
Bounded Any | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods minBound :: Any # maxBound :: Any #
Generic Any |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep Any | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep Any = D1 ('MetaData "Any" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Any" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAny") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))
Methods from :: Any -> Rep Any x # to :: Rep Any x -> Any #
Read Any | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods readsPrec :: Int -> ReadS Any # readList :: ReadS [Any] # readPrec :: ReadPrec Any # readListPrec :: ReadPrec [Any] #
Show Any | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods showsPrec :: Int -> Any -> ShowS # show :: Any -> String # showList :: [Any] -> ShowS #
Eq Any | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (==) :: Any -> Any -> Bool # (/=) :: Any -> Any -> Bool #
Ord Any | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods compare :: Any -> Any -> Ordering # (<) :: Any -> Any -> Bool # (<=) :: Any -> Any -> Bool # (>) :: Any -> Any -> Bool # (>=) :: Any -> Any -> Bool # max :: Any -> Any -> Any # min :: Any -> Any -> Any #
type Rep Any | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep Any = D1 ('MetaData "Any" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Any" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAny") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

newtype Last a #

Maybe monoid returning the rightmost non-`Nothing` value.

``Last` a` is isomorphic to ``Dual` (`First` a)`, and thus to ``Dual` (`Alt` `Maybe` a)`

`Data.Semigroup.` `Last`. The former returns the last non-`Nothing`, so `x <> Data.Monoid.Last Nothing = x`. The latter simply returns the last value, thus `x <> Data.Semigroup.Last Nothing = Data.Semigroup.Last Nothing`.

#### Examples

Expand

    >>> Last (Just "hello") <> Last Nothing <> Last (Just "world")
    Last {getLast = Just "world"}

    >>> Last Nothing <> mempty
    Last {getLast = Nothing}

Constructors

Last |
Fields getLast :: Maybe a

#### Instances

Instances details

MonadZip Last | Since: base-4.8.0.0
Instance details Defined in Control.Monad.Zip Methods mzip :: Last a -> Last b -> Last (a, b) # mzipWith :: (a -> b -> c) -> Last a -> Last b -> Last c # munzip :: Last (a, b) -> (Last a, Last b) #
NFData1 Last | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a -> ()) -> Last a -> () #
Applicative Last | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods pure :: a -> Last a # (<*>) :: Last (a -> b) -> Last a -> Last b # liftA2 :: (a -> b -> c) -> Last a -> Last b -> Last c # (*>) :: Last a -> Last b -> Last b # (<*) :: Last a -> Last b -> Last a #
Functor Last | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods fmap :: (a -> b) -> Last a -> Last b # (<$) :: a -> Last b -> Last a #
Monad Last | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (>>=) :: Last a -> (a -> Last b) -> Last b # (>>) :: Last a -> Last b -> Last b # return :: a -> Last a #
Foldable Last | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Last m -> m # foldMap :: Monoid m => (a -> m) -> Last a -> m # foldMap' :: Monoid m => (a -> m) -> Last a -> m # foldr :: (a -> b -> b) -> b -> Last a -> b # foldr' :: (a -> b -> b) -> b -> Last a -> b # foldl :: (b -> a -> b) -> b -> Last a -> b # foldl' :: (b -> a -> b) -> b -> Last a -> b # foldr1 :: (a -> a -> a) -> Last a -> a # foldl1 :: (a -> a -> a) -> Last a -> a # toList :: Last a -> [a] # null :: Last a -> Bool # length :: Last a -> Int # elem :: Eq a => a -> Last a -> Bool # maximum :: Ord a => Last a -> a # minimum :: Ord a => Last a -> a # sum :: Num a => Last a -> a # product :: Num a => Last a -> a #
Traversable Last | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Last a -> f (Last b) # sequenceA :: Applicative f => Last (f a) -> f (Last a) # mapM :: Monad m => (a -> m b) -> Last a -> m (Last b) # sequence :: Monad m => Last (m a) -> m (Last a) #
Generic1 Last |
Instance details Defined in GHC.Internal.Data.Monoid Associated Types
type Rep1 Last | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep1 Last = D1 ('MetaData "Last" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Last" 'PrefixI 'True) (S1 ('MetaSel ('Just "getLast") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 Maybe)))
Methods from1 :: Last a -> Rep1 Last a # to1 :: Rep1 Last a -> Last a #
NFData a => NFData (Last a) | Since: deepseq-1.4.0.0
Instance details Defined in Control.DeepSeq Methods rnf :: Last a -> () #
Monoid (Last a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods mempty :: Last a # mappend :: Last a -> Last a -> Last a # mconcat :: [Last a] -> Last a #
Semigroup (Last a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (<>) :: Last a -> Last a -> Last a # sconcat :: NonEmpty (Last a) -> Last a # stimes :: Integral b => b -> Last a -> Last a #
Data a => Data (Last a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Last a -> c (Last a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Last a) # toConstr :: Last a -> Constr # dataTypeOf :: Last a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Last a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Last a)) # gmapT :: (forall b. Data b => b -> b) -> Last a -> Last a # gmapQl :: (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 # gmapQ :: (forall d. Data d => d -> u) -> Last a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Last a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Last a -> m (Last a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Last a -> m (Last a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Last a -> m (Last a) #
Generic (Last a) |
Instance details Defined in GHC.Internal.Data.Monoid Associated Types
type Rep (Last a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep (Last a) = D1 ('MetaData "Last" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Last" 'PrefixI 'True) (S1 ('MetaSel ('Just "getLast") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe a))))
Methods from :: Last a -> Rep (Last a) x # to :: Rep (Last a) x -> Last a #
Read a => Read (Last a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods readsPrec :: Int -> ReadS (Last a) # readList :: ReadS [Last a] # readPrec :: ReadPrec (Last a) # readListPrec :: ReadPrec [Last a] #
Show a => Show (Last a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods showsPrec :: Int -> Last a -> ShowS # show :: Last a -> String # showList :: [Last a] -> ShowS #
Eq a => Eq (Last a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods (==) :: Last a -> Last a -> Bool # (/=) :: Last a -> Last a -> Bool #
Ord a => Ord (Last a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods compare :: 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 # max :: Last a -> Last a -> Last a # min :: Last a -> Last a -> Last a #
type Rep1 Last | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep1 Last = D1 ('MetaData "Last" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Last" 'PrefixI 'True) (S1 ('MetaSel ('Just "getLast") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 Maybe)))
type Rep (Last a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep (Last a) = D1 ('MetaData "Last" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Last" 'PrefixI 'True) (S1 ('MetaSel ('Just "getLast") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe a))))

newtype First a #

Maybe monoid returning the leftmost non-`Nothing` value.

``First` a` is isomorphic to ``Alt` `Maybe` a`, but precedes it historically.

Beware that `Data.Monoid.` `First` is different from `Data.Semigroup.` `First`. The former returns the first non-`Nothing`, so `Data.Monoid.First Nothing <> x = x`. The latter simply returns the first value, thus `Data.Semigroup.First Nothing <> x = Data.Semigroup.First Nothing`.

#### Examples

Expand

    >>> First (Just "hello") <> First Nothing <> First (Just "world")
    First {getFirst = Just "hello"}

    >>> First Nothing <> mempty
    First {getFirst = Nothing}

Constructors

First |
Fields getFirst :: Maybe a

#### Instances

Instances details

MonadZip First | Since: base-4.8.0.0
Instance details Defined in Control.Monad.Zip Methods mzip :: First a -> First b -> First (a, b) # mzipWith :: (a -> b -> c) -> First a -> First b -> First c # munzip :: First (a, b) -> (First a, First b) #
NFData1 First | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a -> ()) -> First a -> () #
Applicative First | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods pure :: a -> First a # (<*>) :: First (a -> b) -> First a -> First b # liftA2 :: (a -> b -> c) -> First a -> First b -> First c # (*>) :: First a -> First b -> First b # (<*) :: First a -> First b -> First a #
Functor First | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods fmap :: (a -> b) -> First a -> First b # (<$) :: a -> First b -> First a #
Monad First | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (>>=) :: First a -> (a -> First b) -> First b # (>>) :: First a -> First b -> First b # return :: a -> First a #
Foldable First | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => First m -> m # foldMap :: Monoid m => (a -> m) -> First a -> m # foldMap' :: Monoid m => (a -> m) -> First a -> m # foldr :: (a -> b -> b) -> b -> First a -> b # foldr' :: (a -> b -> b) -> b -> First a -> b # foldl :: (b -> a -> b) -> b -> First a -> b # foldl' :: (b -> a -> b) -> b -> First a -> b # foldr1 :: (a -> a -> a) -> First a -> a # foldl1 :: (a -> a -> a) -> First a -> a # toList :: First a -> [a] # null :: First a -> Bool # length :: First a -> Int # elem :: Eq a => a -> First a -> Bool # maximum :: Ord a => First a -> a # minimum :: Ord a => First a -> a # sum :: Num a => First a -> a # product :: Num a => First a -> a #
Traversable First | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> First a -> f (First b) # sequenceA :: Applicative f => First (f a) -> f (First a) # mapM :: Monad m => (a -> m b) -> First a -> m (First b) # sequence :: Monad m => First (m a) -> m (First a) #
Generic1 First |
Instance details Defined in GHC.Internal.Data.Monoid Associated Types
type Rep1 First | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep1 First = D1 ('MetaData "First" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "First" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFirst") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 Maybe)))
Methods from1 :: First a -> Rep1 First a # to1 :: Rep1 First a -> First a #
NFData a => NFData (First a) | Since: deepseq-1.4.0.0
Instance details Defined in Control.DeepSeq Methods rnf :: First a -> () #
Monoid (First a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods mempty :: First a # mappend :: First a -> First a -> First a # mconcat :: [First a] -> First a #
Semigroup (First a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (<>) :: First a -> First a -> First a # sconcat :: NonEmpty (First a) -> First a # stimes :: Integral b => b -> First a -> First a #
Data a => Data (First a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> First a -> c (First a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (First a) # toConstr :: First a -> Constr # dataTypeOf :: First a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (First a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (First a)) # gmapT :: (forall b. Data b => b -> b) -> First a -> First a # gmapQl :: (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 # gmapQ :: (forall d. Data d => d -> u) -> First a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> First a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> First a -> m (First a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> First a -> m (First a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> First a -> m (First a) #
Generic (First a) |
Instance details Defined in GHC.Internal.Data.Monoid Associated Types
type Rep (First a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep (First a) = D1 ('MetaData "First" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "First" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFirst") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe a))))
Methods from :: First a -> Rep (First a) x # to :: Rep (First a) x -> First a #
Read a => Read (First a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods readsPrec :: Int -> ReadS (First a) # readList :: ReadS [First a] # readPrec :: ReadPrec (First a) # readListPrec :: ReadPrec [First a] #
Show a => Show (First a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods showsPrec :: Int -> First a -> ShowS # show :: First a -> String # showList :: [First a] -> ShowS #
Eq a => Eq (First a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods (==) :: First a -> First a -> Bool # (/=) :: First a -> First a -> Bool #
Ord a => Ord (First a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods compare :: 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 # max :: First a -> First a -> First a # min :: First a -> First a -> First a #
type Rep1 First | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep1 First = D1 ('MetaData "First" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "First" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFirst") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 Maybe)))
type Rep (First a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep (First a) = D1 ('MetaData "First" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "First" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFirst") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe a))))

class Semigroup a => Monoid a where #

The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:

Right identity
  `x `<>` `mempty` = x`
Left identity
  ``mempty` `<>` x = x`
Associativity
  `x `<>` (y `<>` z) = (x `<>` y) `<>` z` (`Semigroup` law)
Concatenation
  ``mconcat` = `foldr` (`<>`) `mempty``

You can alternatively define `mconcat` instead of `mempty`, in which case the laws are:

Unit
  ``mconcat` (`pure` x) = x`
Multiplication
  ``mconcat` (`join` xss) = `mconcat` (`fmap` `mconcat` xss)`
Subclass
  ``mconcat` (`toList` xs) = `sconcat` xs`

The method names refer to the monoid of lists under concatenation, but there are many other instances.

Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define `newtype`s and make those instances of `Monoid`, e.g. `Sum` and `Product`.

NOTE: `Semigroup` is a superclass of `Monoid` since base-4.11.0.0.

Minimal complete definition

mempty | mconcat

Methods

mempty :: a #

Identity of `mappend`

#### Examples

Expand

    >>> "Hello world" <> mempty
    "Hello world"

    >>> mempty <> [1, 2, 3]
    [1,2,3]

mappend :: a -> a -> a #

An associative operation

NOTE: This method is redundant and has the default implementation ``mappend` = (`<>`)` since base-4.11.0.0. Should it be implemented manually, since `mappend` is a synonym for (`<>`), it is expected that the two functions are defined the same way. In a future GHC release `mappend` will be removed from `Monoid`.

mconcat :: [a] -> a #

Fold a list using the monoid.

For most types, the default definition for `mconcat` will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.

    >>> mconcat ["Hello", " ", "Haskell", "!"]
    "Hello Haskell!"

#### Instances

Instances details

Monoid ByteArray | Since: base-4.17.0.0
Instance details Defined in Data.Array.Byte Methods mempty :: ByteArray # mappend :: ByteArray -> ByteArray -> ByteArray # mconcat :: [ByteArray] -> ByteArray #
Monoid Builder |
Instance details Defined in Data.ByteString.Builder.Internal Methods mempty :: Builder # mappend :: Builder -> Builder -> Builder # mconcat :: [Builder] -> Builder #
Monoid ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods mempty :: ByteString # mappend :: ByteString -> ByteString -> ByteString # mconcat :: [ByteString] -> ByteString #
Monoid ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods mempty :: ByteString # mappend :: ByteString -> ByteString -> ByteString # mconcat :: [ByteString] -> ByteString #
Monoid ShortByteString |
Instance details Defined in Data.ByteString.Short.Internal Methods mempty :: ShortByteString # mappend :: ShortByteString -> ShortByteString -> ShortByteString # mconcat :: [ShortByteString] -> ShortByteString #
Monoid IntSet |
Instance details Defined in Data.IntSet.Internal Methods mempty :: IntSet # mappend :: IntSet -> IntSet -> IntSet # mconcat :: [IntSet] -> IntSet #
Monoid All | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: All # mappend :: All -> All -> All # mconcat :: [All] -> All #
Monoid Any | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Any # mappend :: Any -> Any -> Any # mconcat :: [Any] -> Any #
Monoid Ordering | @since base-2.01
Instance details Defined in GHC.Internal.Base Methods mempty :: Ordering # mappend :: Ordering -> Ordering -> Ordering # mconcat :: [Ordering] -> Ordering #
Monoid OsString | "String-Concatenation" for `OsString`. This is not the same as `(</>)`.
Instance details Defined in System.OsString.Internal.Types Methods mempty :: OsString # mappend :: OsString -> OsString -> OsString # mconcat :: [OsString] -> OsString #
Monoid PosixString |
Instance details Defined in System.OsString.Internal.Types Methods mempty :: PosixString # mappend :: PosixString -> PosixString -> PosixString # mconcat :: [PosixString] -> PosixString #
Monoid WindowsString |
Instance details Defined in System.OsString.Internal.Types Methods mempty :: WindowsString # mappend :: WindowsString -> WindowsString -> WindowsString # mconcat :: [WindowsString] -> WindowsString #
Monoid Doc |
Instance details Defined in Text.PrettyPrint.HughesPJ Methods mempty :: Doc # mappend :: Doc -> Doc -> Doc # mconcat :: [Doc] -> Doc #
Monoid Builder |
Instance details Defined in Data.Text.Internal.Builder Methods mempty :: Builder # mappend :: Builder -> Builder -> Builder # mconcat :: [Builder] -> Builder #
Monoid StrictBuilder |
Instance details Defined in Data.Text.Internal.StrictBuilder Methods mempty :: StrictBuilder # mappend :: StrictBuilder -> StrictBuilder -> StrictBuilder # mconcat :: [StrictBuilder] -> StrictBuilder #
Monoid () | @since base-2.01
Instance details Defined in GHC.Internal.Base Methods mempty :: () # mappend :: () -> () -> () # mconcat :: [()] -> () #
Monoid (Comparison a) | ``mempty`` on comparisons always returns `EQ`. Without newtypes this equals ``pure` (`pure` EQ)`.
    mempty :: Comparison a
    mempty = Comparison _ _ -> EQ
Instance details Defined in Data.Functor.Contravariant Methods mempty :: Comparison a # mappend :: Comparison a -> Comparison a -> Comparison a # mconcat :: [Comparison a] -> Comparison a #
Monoid (Equivalence a) | ``mempty`` on equivalences always returns `True`. Without newtypes this equals ``pure` (`pure` True)`.
    mempty :: Equivalence a
    mempty = Equivalence _ _ -> True
Instance details Defined in Data.Functor.Contravariant Methods mempty :: Equivalence a # mappend :: Equivalence a -> Equivalence a -> Equivalence a # mconcat :: [Equivalence a] -> Equivalence a #
Monoid (Predicate a) | ``mempty`` on predicates always returns `True`. Without newtypes this equals ``pure` True`.
    mempty :: Predicate a
    mempty = _ -> True
Instance details Defined in Data.Functor.Contravariant Methods mempty :: Predicate a # mappend :: Predicate a -> Predicate a -> Predicate a # mconcat :: [Predicate a] -> Predicate a #
(Ord a, Bounded a) => Monoid (Max a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods mempty :: Max a # mappend :: Max a -> Max a -> Max a # mconcat :: [Max a] -> Max a #
(Ord a, Bounded a) => Monoid (Min a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods mempty :: Min a # mappend :: Min a -> Min a -> Min a # mconcat :: [Min a] -> Min a #
Monoid m => Monoid (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods mempty :: WrappedMonoid m # mappend :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m # mconcat :: [WrappedMonoid m] -> WrappedMonoid m #
Monoid (IntMap a) |
Instance details Defined in Data.IntMap.Internal Methods mempty :: IntMap a # mappend :: IntMap a -> IntMap a -> IntMap a # mconcat :: [IntMap a] -> IntMap a #
Monoid (Seq a) |
Instance details Defined in Data.Sequence.Internal Methods mempty :: Seq a # mappend :: Seq a -> Seq a -> Seq a # mconcat :: [Seq a] -> Seq a #
Monoid (MergeSet a) |
Instance details Defined in Data.Set.Internal Methods mempty :: MergeSet a # mappend :: MergeSet a -> MergeSet a -> MergeSet a # mconcat :: [MergeSet a] -> MergeSet a #
Ord a => Monoid (Set a) |
Instance details Defined in Data.Set.Internal Methods mempty :: Set a # mappend :: Set a -> Set a -> Set a # mconcat :: [Set a] -> Set a #
Monoid a => Monoid (STM a) | @since base-4.17.0.0
Instance details Defined in GHC.Internal.Conc.Sync Methods mempty :: STM a # mappend :: STM a -> STM a -> STM a # mconcat :: [STM a] -> STM a #
Monoid a => Monoid (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods mempty :: Identity a # mappend :: Identity a -> Identity a -> Identity a # mconcat :: [Identity a] -> Identity a #
Monoid (First a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods mempty :: First a # mappend :: First a -> First a -> First a # mconcat :: [First a] -> First a #
Monoid (Last a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Monoid Methods mempty :: Last a # mappend :: Last a -> Last a -> Last a # mconcat :: [Last a] -> Last a #
Monoid a => Monoid (Down a) | @since base-4.11.0.0
Instance details Defined in GHC.Internal.Data.Ord Methods mempty :: Down a # mappend :: Down a -> Down a -> Down a # mconcat :: [Down a] -> Down a #
Monoid a => Monoid (Dual a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Dual a # mappend :: Dual a -> Dual a -> Dual a # mconcat :: [Dual a] -> Dual a #
Monoid (Endo a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Endo a # mappend :: Endo a -> Endo a -> Endo a # mconcat :: [Endo a] -> Endo a #
Num a => Monoid (Product a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Product a # mappend :: Product a -> Product a -> Product a # mconcat :: [Product a] -> Product a #
Num a => Monoid (Sum a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Sum a # mappend :: Sum a -> Sum a -> Sum a # mconcat :: [Sum a] -> Sum a #
(Generic a, Monoid (Rep a ())) => Monoid (Generically a) | @since base-4.17.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: Generically a # mappend :: Generically a -> Generically a -> Generically a # mconcat :: [Generically a] -> Generically a #
Monoid p => Monoid (Par1 p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: Par1 p # mappend :: Par1 p -> Par1 p -> Par1 p # mconcat :: [Par1 p] -> Par1 p #
Monoid a => Monoid (IO a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods mempty :: IO a # mappend :: IO a -> IO a -> IO a # mconcat :: [IO a] -> IO a #
Monoid (Doc a) |
Instance details Defined in Text.PrettyPrint.Annotated.HughesPJ Methods mempty :: Doc a # mappend :: Doc a -> Doc a -> Doc a # mconcat :: [Doc a] -> Doc a #
Monoid a => Monoid (Q a) | Since: template-haskell-2.17.0.0
Instance details Defined in Language.Haskell.TH.Syntax Methods mempty :: Q a # mappend :: Q a -> Q a -> Q a # mconcat :: [Q a] -> Q a #
Monoid (Validity k) |
Instance details Defined in Data.HashMap.Internal.Debug Methods mempty :: Validity k # mappend :: Validity k -> Validity k -> Validity k # mconcat :: [Validity k] -> Validity k #
(Hashable a, Eq a) => Monoid (HashSet a) | `mempty` = `empty` `mappend` = `union` \(O(n+m)\) To obtain good performance, the smaller set must be presented as the first argument. #### Examples Expand
    >>> mappend (fromList [1,2]) (fromList [2,3])
    fromList [1,2,3]
Instance details Defined in Data.HashSet.Internal Methods mempty :: HashSet a # mappend :: HashSet a -> HashSet a -> HashSet a # mconcat :: [HashSet a] -> HashSet a #
Semigroup a => Monoid (Maybe a) | Lift a semigroup into `Maybe` forming a `Monoid` according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup `S` may be turned into a monoid simply by adjoining an element `e` not in `S` and defining `e*e = e` and `e*s = s = s*e` for all `s ∈ S`." Since 4.11.0: constraint on inner `a` value generalised from `Monoid` to `Semigroup`. @since base-2.01
Instance details Defined in GHC.Internal.Base Methods mempty :: Maybe a # mappend :: Maybe a -> Maybe a -> Maybe a # mconcat :: [Maybe a] -> Maybe a #
Monoid a => Monoid (Solo a) | @since base-4.15
Instance details Defined in GHC.Internal.Base Methods mempty :: Solo a # mappend :: Solo a -> Solo a -> Solo a # mconcat :: [Solo a] -> Solo a #
Monoid [a] | @since base-2.01
Instance details Defined in GHC.Internal.Base Methods mempty :: [a] # mappend :: [a] -> [a] -> [a] # mconcat :: [[a]] -> [a] #
Monoid a => Monoid (Op a b) | ``mempty` @(Op a b)` without newtypes is `mempty @(b->a)` = `_ -> mempty`.
    mempty :: Op a b
    mempty = Op _ -> mempty
Instance details Defined in Data.Functor.Contravariant Methods mempty :: Op a b # mappend :: Op a b -> Op a b -> Op a b # mconcat :: [Op a b] -> Op a b #
Ord k => Monoid (Map k v) |
Instance details Defined in Data.Map.Internal Methods mempty :: Map k v # mappend :: Map k v -> Map k v -> Map k v # mconcat :: [Map k v] -> Map k v #
Monoid (Proxy s) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Proxy Methods mempty :: Proxy s # mappend :: Proxy s -> Proxy s -> Proxy s # mconcat :: [Proxy s] -> Proxy s #
Monoid (U1 p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: U1 p # mappend :: U1 p -> U1 p -> U1 p # mconcat :: [U1 p] -> U1 p #
(Eq k, Hashable k) => Monoid (HashMap k v) | `mempty` = `empty` `mappend` = `union` If a key occurs in both maps, the mapping from the first will be the mapping in the result. #### Examples Expand
    >>> mappend (fromList [(1,'a'),(2,'b')]) (fromList [(2,'c'),(3,'d')])
    fromList [(1,'a'),(2,'b'),(3,'d')]
Instance details Defined in Data.HashMap.Internal Methods mempty :: HashMap k v # mappend :: HashMap k v -> HashMap k v -> HashMap k v # mconcat :: [HashMap k v] -> HashMap k v #
(Monoid a, Monoid b) => Monoid (a, b) | @since base-2.01
Instance details Defined in GHC.Internal.Base Methods mempty :: (a, b) # mappend :: (a, b) -> (a, b) -> (a, b) # mconcat :: [(a, b)] -> (a, b) #
Monoid b => Monoid (a -> b) | @since base-2.01
Instance details Defined in GHC.Internal.Base Methods mempty :: a -> b # mappend :: (a -> b) -> (a -> b) -> a -> b # mconcat :: [a -> b] -> a -> b #
Monoid a => Monoid (Const a b) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Const Methods mempty :: Const a b # mappend :: Const a b -> Const a b -> Const a b # mconcat :: [Const a b] -> Const a b #
(Applicative f, Monoid a) => Monoid (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods mempty :: Ap f a # mappend :: Ap f a -> Ap f a -> Ap f a # mconcat :: [Ap f a] -> Ap f a #
Alternative f => Monoid (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Alt f a # mappend :: Alt f a -> Alt f a -> Alt f a # mconcat :: [Alt f a] -> Alt f a #
Monoid (f p) => Monoid (Rec1 f p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: Rec1 f p # mappend :: Rec1 f p -> Rec1 f p -> Rec1 f p # mconcat :: [Rec1 f p] -> Rec1 f p #
Monoid a => Monoid (Constant a b) |
Instance details Defined in Data.Functor.Constant Methods mempty :: Constant a b # mappend :: Constant a b -> Constant a b -> Constant a b # mconcat :: [Constant a b] -> Constant a b #
(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) | @since base-2.01
Instance details Defined in GHC.Internal.Base Methods mempty :: (a, b, c) # mappend :: (a, b, c) -> (a, b, c) -> (a, b, c) # mconcat :: [(a, b, c)] -> (a, b, c) #
(Monoid (f a), Monoid (g a)) => Monoid (Product f g a) | Since: base-4.16.0.0
Instance details Defined in Data.Functor.Product Methods mempty :: Product f g a # mappend :: Product f g a -> Product f g a -> Product f g a # mconcat :: [Product f g a] -> Product f g a #
(Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: (f :*: g) p # mappend :: (f :*: g) p -> (f :*: g) p -> (f :*: g) p # mconcat :: [(f :*: g) p] -> (f :*: g) p #
Monoid c => Monoid (K1 i c p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: K1 i c p # mappend :: K1 i c p -> K1 i c p -> K1 i c p # mconcat :: [K1 i c p] -> K1 i c p #
(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) | @since base-2.01
Instance details Defined in GHC.Internal.Base Methods mempty :: (a, b, c, d) # mappend :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) # mconcat :: [(a, b, c, d)] -> (a, b, c, d) #
Monoid (f (g a)) => Monoid (Compose f g a) | Since: base-4.16.0.0
Instance details Defined in Data.Functor.Compose Methods mempty :: Compose f g a # mappend :: Compose f g a -> Compose f g a -> Compose f g a # mconcat :: [Compose f g a] -> Compose f g a #
Monoid (f (g p)) => Monoid ((f :.: g) p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: (f :.: g) p # mappend :: (f :.: g) p -> (f :.: g) p -> (f :.: g) p # mconcat :: [(f :.: g) p] -> (f :.: g) p #
Monoid (f p) => Monoid (M1 i c f p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods mempty :: M1 i c f p # mappend :: M1 i c f p -> M1 i c f p -> M1 i c f p # mconcat :: [M1 i c f p] -> M1 i c f p #
(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) | @since base-2.01
Instance details Defined in GHC.Internal.Base Methods mempty :: (a, b, c, d, e) # mappend :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) # mconcat :: [(a, b, c, d, e)] -> (a, b, c, d, e) #

newtype Alt (f :: k -> Type) (a :: k) #

Monoid under `<|>`.

    Alt l <> Alt r == Alt (l <|> r)

#### Examples

Expand

    >>> Alt (Just 12) <> Alt (Just 24)
    Alt {getAlt = Just 12}

    >>> Alt Nothing <> Alt (Just 24)
    Alt {getAlt = Just 24}

@since base-4.8.0.0

Constructors

Alt |
Fields getAlt :: f a

#### Instances

Instances details

Generic1 (Alt f :: k -> Type) |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep1 (Alt f :: k -> Type) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep1 (Alt f :: k -> Type) = D1 ('MetaData "Alt" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Alt" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAlt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))
Methods from1 :: forall (a :: k). Alt f a -> Rep1 (Alt f) a # to1 :: forall (a :: k). Rep1 (Alt f) a -> Alt f a #
MonadZip f => MonadZip (Alt f) | Since: base-4.8.0.0
Instance details Defined in Control.Monad.Zip Methods mzip :: Alt f a -> Alt f b -> Alt f (a, b) # mzipWith :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c # munzip :: Alt f (a, b) -> (Alt f a, Alt f b) #
Foldable1 f => Foldable1 (Alt f) | Since: base-4.18.0.0
Instance details Defined in Data.Foldable1 Methods fold1 :: Semigroup m => Alt f m -> m # foldMap1 :: Semigroup m => (a -> m) -> Alt f a -> m # foldMap1' :: Semigroup m => (a -> m) -> Alt f a -> m # toNonEmpty :: Alt f a -> NonEmpty a # maximum :: Ord a => Alt f a -> a # minimum :: Ord a => Alt f a -> a # head :: Alt f a -> a # last :: Alt f a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Alt f a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Alt f a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Alt f a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Alt f a -> b #
Contravariant f => Contravariant (Alt f) |
Instance details Defined in Data.Functor.Contravariant Methods contramap :: (a' -> a) -> Alt f a -> Alt f a' # (>$) :: b -> Alt f b -> Alt f a #
Alternative f => Alternative (Alt f) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods empty :: Alt f a # (<|>) :: Alt f a -> Alt f a -> Alt f a # some :: Alt f a -> Alt f [a] # many :: Alt f a -> Alt f [a] #
Applicative f => Applicative (Alt f) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods pure :: a -> Alt f a # (<*>) :: Alt f (a -> b) -> Alt f a -> Alt f b # liftA2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c # (*>) :: Alt f a -> Alt f b -> Alt f b # (<*) :: Alt f a -> Alt f b -> Alt f a #
Functor f => Functor (Alt f) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods fmap :: (a -> b) -> Alt f a -> Alt f b # (<$) :: a -> Alt f b -> Alt f a #
Monad f => Monad (Alt f) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (>>=) :: Alt f a -> (a -> Alt f b) -> Alt f b # (>>) :: Alt f a -> Alt f b -> Alt f b # return :: a -> Alt f a #
MonadPlus f => MonadPlus (Alt f) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mzero :: Alt f a # mplus :: Alt f a -> Alt f a -> Alt f a #
Foldable f => Foldable (Alt f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Alt f m -> m # foldMap :: Monoid m => (a -> m) -> Alt f a -> m # foldMap' :: Monoid m => (a -> m) -> Alt f a -> m # foldr :: (a -> b -> b) -> b -> Alt f a -> b # foldr' :: (a -> b -> b) -> b -> Alt f a -> b # foldl :: (b -> a -> b) -> b -> Alt f a -> b # foldl' :: (b -> a -> b) -> b -> Alt f a -> b # foldr1 :: (a -> a -> a) -> Alt f a -> a # foldl1 :: (a -> a -> a) -> Alt f a -> a # toList :: Alt f a -> [a] # null :: Alt f a -> Bool # length :: Alt f a -> Int # elem :: Eq a => a -> Alt f a -> Bool # maximum :: Ord a => Alt f a -> a # minimum :: Ord a => Alt f a -> a # sum :: Num a => Alt f a -> a # product :: Num a => Alt f a -> a #
Traversable f => Traversable (Alt f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f0 => (a -> f0 b) -> Alt f a -> f0 (Alt f b) # sequenceA :: Applicative f0 => Alt f (f0 a) -> f0 (Alt f a) # mapM :: Monad m => (a -> m b) -> Alt f a -> m (Alt f b) # sequence :: Monad m => Alt f (m a) -> m (Alt f a) #
Alternative f => Monoid (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Alt f a # mappend :: Alt f a -> Alt f a -> Alt f a # mconcat :: [Alt f a] -> Alt f a #
Alternative f => Semigroup (Alt f a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Alt f a -> Alt f a -> Alt f a # sconcat :: NonEmpty (Alt f a) -> Alt f a # stimes :: Integral b => b -> Alt f a -> Alt f a #
(Data (f a), Data a, Typeable f) => Data (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Alt f a -> c (Alt f a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Alt f a) # toConstr :: Alt f a -> Constr # dataTypeOf :: Alt f a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Alt f a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Alt f a)) # gmapT :: (forall b. Data b => b -> b) -> Alt f a -> Alt f a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Alt f a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Alt f a -> r # gmapQ :: (forall d. Data d => d -> u) -> Alt f a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Alt f a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Alt f a -> m (Alt f a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Alt f a -> m (Alt f a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Alt f a -> m (Alt f a) #
Enum (f a) => Enum (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods succ :: Alt f a -> Alt f a # pred :: Alt f a -> Alt f a # toEnum :: Int -> Alt f a # fromEnum :: Alt f a -> Int # enumFrom :: Alt f a -> [Alt f a] # enumFromThen :: Alt f a -> Alt f a -> [Alt f a] # enumFromTo :: Alt f a -> Alt f a -> [Alt f a] # enumFromThenTo :: Alt f a -> Alt f a -> Alt f a -> [Alt f a] #
Generic (Alt f a) |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep (Alt f a) = D1 ('MetaData "Alt" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Alt" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAlt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))
Methods from :: Alt f a -> Rep (Alt f a) x # to :: Rep (Alt f a) x -> Alt f a #
Num (f a) => Num (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (+) :: Alt f a -> Alt f a -> Alt f a # (-) :: Alt f a -> Alt f a -> Alt f a # (*) :: Alt f a -> Alt f a -> Alt f a # negate :: Alt f a -> Alt f a # abs :: Alt f a -> Alt f a # signum :: Alt f a -> Alt f a # fromInteger :: Integer -> Alt f a #
Read (f a) => Read (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods readsPrec :: Int -> ReadS (Alt f a) # readList :: ReadS [Alt f a] # readPrec :: ReadPrec (Alt f a) # readListPrec :: ReadPrec [Alt f a] #
Show (f a) => Show (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods showsPrec :: Int -> Alt f a -> ShowS # show :: Alt f a -> String # showList :: [Alt f a] -> ShowS #
Eq (f a) => Eq (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (==) :: Alt f a -> Alt f a -> Bool # (/=) :: Alt f a -> Alt f a -> Bool #
Ord (f a) => Ord (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods compare :: Alt f a -> Alt f a -> Ordering # (<) :: Alt f a -> Alt f a -> Bool # (<=) :: Alt f a -> Alt f a -> Bool # (>) :: Alt f a -> Alt f a -> Bool # (>=) :: Alt f a -> Alt f a -> Bool # max :: Alt f a -> Alt f a -> Alt f a # min :: Alt f a -> Alt f a -> Alt f a #
type Rep1 (Alt f :: k -> Type) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep1 (Alt f :: k -> Type) = D1 ('MetaData "Alt" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Alt" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAlt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))
type Rep (Alt f a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep (Alt f a) = D1 ('MetaData "Alt" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Alt" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAlt") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))

newtype Product a #

Monoid under multiplication.

    Product x <> Product y == Product (x * y)

#### Examples

Expand

    >>> Product 3 <> Product 4 <> mempty
    Product {getProduct = 12}

    >>> mconcat [ Product n | n <- [2 .. 10]]
    Product {getProduct = 3628800}

Constructors

Product |
Fields getProduct :: a

#### Instances

Instances details

MonadZip Product | Since: base-4.8.0.0
Instance details Defined in Control.Monad.Zip Methods mzip :: Product a -> Product b -> Product (a, b) # mzipWith :: (a -> b -> c) -> Product a -> Product b -> Product c # munzip :: Product (a, b) -> (Product a, Product b) #
Foldable1 Product | Since: base-4.18.0.0
Instance details Defined in Data.Foldable1 Methods fold1 :: Semigroup m => Product m -> m # foldMap1 :: Semigroup m => (a -> m) -> Product a -> m # foldMap1' :: Semigroup m => (a -> m) -> Product a -> m # toNonEmpty :: Product a -> NonEmpty a # maximum :: Ord a => Product a -> a # minimum :: Ord a => Product a -> a # head :: Product a -> a # last :: Product a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Product a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Product a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Product a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Product a -> b #
NFData1 Product | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a -> ()) -> Product a -> () #
Applicative Product | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods pure :: a -> Product a # (<*>) :: Product (a -> b) -> Product a -> Product b # liftA2 :: (a -> b -> c) -> Product a -> Product b -> Product c # (*>) :: Product a -> Product b -> Product b # (<*) :: Product a -> Product b -> Product a #
Functor Product | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods fmap :: (a -> b) -> Product a -> Product b # (<$) :: a -> Product b -> Product a #
Monad Product | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (>>=) :: Product a -> (a -> Product b) -> Product b # (>>) :: Product a -> Product b -> Product b # return :: a -> Product a #
Foldable Product | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Product m -> m # foldMap :: Monoid m => (a -> m) -> Product a -> m # foldMap' :: Monoid m => (a -> m) -> Product a -> m # foldr :: (a -> b -> b) -> b -> Product a -> b # foldr' :: (a -> b -> b) -> b -> Product a -> b # foldl :: (b -> a -> b) -> b -> Product a -> b # foldl' :: (b -> a -> b) -> b -> Product a -> b # foldr1 :: (a -> a -> a) -> Product a -> a # foldl1 :: (a -> a -> a) -> Product a -> a # toList :: Product a -> [a] # null :: Product a -> Bool # length :: Product a -> Int # elem :: Eq a => a -> Product a -> Bool # maximum :: Ord a => Product a -> a # minimum :: Ord a => Product a -> a # sum :: Num a => Product a -> a # product :: Num a => Product a -> a #
Traversable Product | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Product a -> f (Product b) # sequenceA :: Applicative f => Product (f a) -> f (Product a) # mapM :: Monad m => (a -> m b) -> Product a -> m (Product b) # sequence :: Monad m => Product (m a) -> m (Product a) #
Generic1 Product |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep1 Product | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep1 Product = D1 ('MetaData "Product" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Product" 'PrefixI 'True) (S1 ('MetaSel ('Just "getProduct") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
Methods from1 :: Product a -> Rep1 Product a # to1 :: Rep1 Product a -> Product a #
NFData a => NFData (Product a) | Since: deepseq-1.4.0.0
Instance details Defined in Control.DeepSeq Methods rnf :: Product a -> () #
Num a => Monoid (Product a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Product a # mappend :: Product a -> Product a -> Product a # mconcat :: [Product a] -> Product a #
Num a => Semigroup (Product a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Product a -> Product a -> Product a # sconcat :: NonEmpty (Product a) -> Product a # stimes :: Integral b => b -> Product a -> Product a #
Data a => Data (Product a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Product a -> c (Product a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Product a) # toConstr :: Product a -> Constr # dataTypeOf :: Product a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Product a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Product a)) # gmapT :: (forall b. Data b => b -> b) -> Product a -> Product a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Product a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Product a -> r # gmapQ :: (forall d. Data d => d -> u) -> Product a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Product a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Product a -> m (Product a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Product a -> m (Product a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Product a -> m (Product a) #
Bounded a => Bounded (Product a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods minBound :: Product a # maxBound :: Product a #
Generic (Product a) |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep (Product a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep (Product a) = D1 ('MetaData "Product" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Product" 'PrefixI 'True) (S1 ('MetaSel ('Just "getProduct") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
Methods from :: Product a -> Rep (Product a) x # to :: Rep (Product a) x -> Product a #
Num a => Num (Product a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (+) :: Product a -> Product a -> Product a # (-) :: Product a -> Product a -> Product a # (*) :: Product a -> Product a -> Product a # negate :: Product a -> Product a # abs :: Product a -> Product a # signum :: Product a -> Product a # fromInteger :: Integer -> Product a #
Read a => Read (Product a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods readsPrec :: Int -> ReadS (Product a) # readList :: ReadS [Product a] # readPrec :: ReadPrec (Product a) # readListPrec :: ReadPrec [Product a] #
Show a => Show (Product a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods showsPrec :: Int -> Product a -> ShowS # show :: Product a -> String # showList :: [Product a] -> ShowS #
Eq a => Eq (Product a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (==) :: Product a -> Product a -> Bool # (/=) :: Product a -> Product a -> Bool #
Ord a => Ord (Product a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods compare :: Product a -> Product a -> Ordering # (<) :: Product a -> Product a -> Bool # (<=) :: Product a -> Product a -> Bool # (>) :: Product a -> Product a -> Bool # (>=) :: Product a -> Product a -> Bool # max :: Product a -> Product a -> Product a # min :: Product a -> Product a -> Product a #
type Rep1 Product | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep1 Product = D1 ('MetaData "Product" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Product" 'PrefixI 'True) (S1 ('MetaSel ('Just "getProduct") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Product a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep (Product a) = D1 ('MetaData "Product" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Product" 'PrefixI 'True) (S1 ('MetaSel ('Just "getProduct") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

newtype Sum a #

Monoid under addition.

    Sum a <> Sum b = Sum (a + b)

#### Examples

Expand

    >>> Sum 1 <> Sum 2 <> mempty
    Sum {getSum = 3}

    >>> mconcat [ Sum n | n <- [3 .. 9]]
    Sum {getSum = 42}

Constructors

Sum |
Fields getSum :: a

#### Instances

Instances details

MonadZip Sum | Since: base-4.8.0.0
Instance details Defined in Control.Monad.Zip Methods mzip :: Sum a -> Sum b -> Sum (a, b) # mzipWith :: (a -> b -> c) -> Sum a -> Sum b -> Sum c # munzip :: Sum (a, b) -> (Sum a, Sum b) #
Foldable1 Sum | Since: base-4.18.0.0
Instance details Defined in Data.Foldable1 Methods fold1 :: Semigroup m => Sum m -> m # foldMap1 :: Semigroup m => (a -> m) -> Sum a -> m # foldMap1' :: Semigroup m => (a -> m) -> Sum a -> m # toNonEmpty :: Sum a -> NonEmpty a # maximum :: Ord a => Sum a -> a # minimum :: Ord a => Sum a -> a # head :: Sum a -> a # last :: Sum a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Sum a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Sum a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Sum a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Sum a -> b #
NFData1 Sum | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a -> ()) -> Sum a -> () #
Applicative Sum | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods pure :: a -> Sum a # (<*>) :: Sum (a -> b) -> Sum a -> Sum b # liftA2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c # (*>) :: Sum a -> Sum b -> Sum b # (<*) :: Sum a -> Sum b -> Sum a #
Functor Sum | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods fmap :: (a -> b) -> Sum a -> Sum b # (<$) :: a -> Sum b -> Sum a #
Monad Sum | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (>>=) :: Sum a -> (a -> Sum b) -> Sum b # (>>) :: Sum a -> Sum b -> Sum b # return :: a -> Sum a #
Foldable Sum | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Sum m -> m # foldMap :: Monoid m => (a -> m) -> Sum a -> m # foldMap' :: Monoid m => (a -> m) -> Sum a -> m # foldr :: (a -> b -> b) -> b -> Sum a -> b # foldr' :: (a -> b -> b) -> b -> Sum a -> b # foldl :: (b -> a -> b) -> b -> Sum a -> b # foldl' :: (b -> a -> b) -> b -> Sum a -> b # foldr1 :: (a -> a -> a) -> Sum a -> a # foldl1 :: (a -> a -> a) -> Sum a -> a # toList :: Sum a -> [a] # null :: Sum a -> Bool # length :: Sum a -> Int # elem :: Eq a => a -> Sum a -> Bool # maximum :: Ord a => Sum a -> a # minimum :: Ord a => Sum a -> a # sum :: Num a => Sum a -> a # product :: Num a => Sum a -> a #
Traversable Sum | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Sum a -> f (Sum b) # sequenceA :: Applicative f => Sum (f a) -> f (Sum a) # mapM :: Monad m => (a -> m b) -> Sum a -> m (Sum b) # sequence :: Monad m => Sum (m a) -> m (Sum a) #
Generic1 Sum |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep1 Sum | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep1 Sum = D1 ('MetaData "Sum" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Sum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
Methods from1 :: Sum a -> Rep1 Sum a # to1 :: Rep1 Sum a -> Sum a #
NFData a => NFData (Sum a) | Since: deepseq-1.4.0.0
Instance details Defined in Control.DeepSeq Methods rnf :: Sum a -> () #
Num a => Monoid (Sum a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Sum a # mappend :: Sum a -> Sum a -> Sum a # mconcat :: [Sum a] -> Sum a #
Num a => Semigroup (Sum a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Sum a -> Sum a -> Sum a # sconcat :: NonEmpty (Sum a) -> Sum a # stimes :: Integral b => b -> Sum a -> Sum a #
Data a => Data (Sum a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Sum a -> c (Sum a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Sum a) # toConstr :: Sum a -> Constr # dataTypeOf :: Sum a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Sum a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Sum a)) # gmapT :: (forall b. Data b => b -> b) -> Sum a -> Sum a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Sum a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Sum a -> r # gmapQ :: (forall d. Data d => d -> u) -> Sum a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Sum a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Sum a -> m (Sum a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Sum a -> m (Sum a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Sum a -> m (Sum a) #
Bounded a => Bounded (Sum a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods minBound :: Sum a # maxBound :: Sum a #
Generic (Sum a) |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep (Sum a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep (Sum a) = D1 ('MetaData "Sum" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Sum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
Methods from :: Sum a -> Rep (Sum a) x # to :: Rep (Sum a) x -> Sum a #
Num a => Num (Sum a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (+) :: Sum a -> Sum a -> Sum a # (-) :: Sum a -> Sum a -> Sum a # (*) :: Sum a -> Sum a -> Sum a # negate :: Sum a -> Sum a # abs :: Sum a -> Sum a # signum :: Sum a -> Sum a # fromInteger :: Integer -> Sum a #
Read a => Read (Sum a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods readsPrec :: Int -> ReadS (Sum a) # readList :: ReadS [Sum a] # readPrec :: ReadPrec (Sum a) # readListPrec :: ReadPrec [Sum a] #
Show a => Show (Sum a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods showsPrec :: Int -> Sum a -> ShowS # show :: Sum a -> String # showList :: [Sum a] -> ShowS #
Eq a => Eq (Sum a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (==) :: Sum a -> Sum a -> Bool # (/=) :: Sum a -> Sum a -> Bool #
Ord a => Ord (Sum a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods compare :: Sum a -> Sum a -> Ordering # (<) :: Sum a -> Sum a -> Bool # (<=) :: Sum a -> Sum a -> Bool # (>) :: Sum a -> Sum a -> Bool # (>=) :: Sum a -> Sum a -> Bool # max :: Sum a -> Sum a -> Sum a # min :: Sum a -> Sum a -> Sum a #
type Rep1 Sum | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep1 Sum = D1 ('MetaData "Sum" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Sum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Sum a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep (Sum a) = D1 ('MetaData "Sum" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Sum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getSum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

newtype All #

Boolean monoid under conjunction `(&&)`.

    All x <> All y = All (x && y)

#### Examples

Expand

    >>> All True <> mempty <> All False)
    All {getAll = False}

    >>> mconcat (map (\x -> All (even x)) [2,4,6,7,8])
    All {getAll = False}

    >>> All True <> mempty
    All {getAll = True}

Constructors

All |
Fields getAll :: Bool

#### Instances

Instances details

NFData All | Since: deepseq-1.4.0.0
Instance details Defined in Control.DeepSeq Methods rnf :: All -> () #
Monoid All | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: All # mappend :: All -> All -> All # mconcat :: [All] -> All #
Semigroup All | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: All -> All -> All # sconcat :: NonEmpty All -> All # stimes :: Integral b => b -> All -> All #
Data All | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> All -> c All # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c All # toConstr :: All -> Constr # dataTypeOf :: All -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c All) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c All) # gmapT :: (forall b. Data b => b -> b) -> All -> All # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> All -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> All -> r # gmapQ :: (forall d. Data d => d -> u) -> All -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> All -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> All -> m All # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> All -> m All # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> All -> m All #
Bounded All | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods minBound :: All # maxBound :: All #
Generic All |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep All | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep All = D1 ('MetaData "All" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "All" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAll") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))
Methods from :: All -> Rep All x # to :: Rep All x -> All #
Read All | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods readsPrec :: Int -> ReadS All # readList :: ReadS [All] # readPrec :: ReadPrec All # readListPrec :: ReadPrec [All] #
Show All | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods showsPrec :: Int -> All -> ShowS # show :: All -> String # showList :: [All] -> ShowS #
Eq All | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (==) :: All -> All -> Bool # (/=) :: All -> All -> Bool #
Ord All | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods compare :: All -> All -> Ordering # (<) :: All -> All -> Bool # (<=) :: All -> All -> Bool # (>) :: All -> All -> Bool # (>=) :: All -> All -> Bool # max :: All -> All -> All # min :: All -> All -> All #
type Rep All | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep All = D1 ('MetaData "All" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "All" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAll") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

newtype Endo a #

The monoid of endomorphisms under composition.

    Endo f <> Endo g == Endo (f . g)

#### Examples

Expand

    >>> let computation = Endo ("Hello, " ++) <> Endo (++ "!")
    >>> appEndo computation "Haskell"
    "Hello, Haskell!"

    >>> let computation = Endo (*3) <> Endo (+1)
    >>> appEndo computation 1
    6

Constructors

Endo |
Fields appEndo :: a -> a

#### Instances

Instances details

Monoid (Endo a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Endo a # mappend :: Endo a -> Endo a -> Endo a # mconcat :: [Endo a] -> Endo a #
Semigroup (Endo a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Endo a -> Endo a -> Endo a # sconcat :: NonEmpty (Endo a) -> Endo a # stimes :: Integral b => b -> Endo a -> Endo a #
Generic (Endo a) |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep (Endo a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep (Endo a) = D1 ('MetaData "Endo" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Endo" 'PrefixI 'True) (S1 ('MetaSel ('Just "appEndo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (a -> a))))
Methods from :: Endo a -> Rep (Endo a) x # to :: Rep (Endo a) x -> Endo a #
type Rep (Endo a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep (Endo a) = D1 ('MetaData "Endo" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Endo" 'PrefixI 'True) (S1 ('MetaSel ('Just "appEndo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (a -> a))))

newtype Dual a #

The dual of a `Monoid`, obtained by swapping the arguments of `(<>)`.

    Dual a <> Dual b == Dual (b <> a)

#### Examples

Expand

    >>> Dual "Hello" <> Dual "World"
    Dual {getDual = "WorldHello"}

    >>> Dual (Dual "Hello") <> Dual (Dual "World")
    Dual {getDual = Dual {getDual = "HelloWorld"}}

Constructors

Dual |
Fields getDual :: a

#### Instances

Instances details

MonadZip Dual | Since: base-4.8.0.0
Instance details Defined in Control.Monad.Zip Methods mzip :: Dual a -> Dual b -> Dual (a, b) # mzipWith :: (a -> b -> c) -> Dual a -> Dual b -> Dual c # munzip :: Dual (a, b) -> (Dual a, Dual b) #
Foldable1 Dual | Since: base-4.18.0.0
Instance details Defined in Data.Foldable1 Methods fold1 :: Semigroup m => Dual m -> m # foldMap1 :: Semigroup m => (a -> m) -> Dual a -> m # foldMap1' :: Semigroup m => (a -> m) -> Dual a -> m # toNonEmpty :: Dual a -> NonEmpty a # maximum :: Ord a => Dual a -> a # minimum :: Ord a => Dual a -> a # head :: Dual a -> a # last :: Dual a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Dual a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Dual a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Dual a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Dual a -> b #
NFData1 Dual | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a -> ()) -> Dual a -> () #
Applicative Dual | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods pure :: a -> Dual a # (<*>) :: Dual (a -> b) -> Dual a -> Dual b # liftA2 :: (a -> b -> c) -> Dual a -> Dual b -> Dual c # (*>) :: Dual a -> Dual b -> Dual b # (<*) :: Dual a -> Dual b -> Dual a #
Functor Dual | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods fmap :: (a -> b) -> Dual a -> Dual b # (<$) :: a -> Dual b -> Dual a #
Monad Dual | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (>>=) :: Dual a -> (a -> Dual b) -> Dual b # (>>) :: Dual a -> Dual b -> Dual b # return :: a -> Dual a #
Foldable Dual | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Dual m -> m # foldMap :: Monoid m => (a -> m) -> Dual a -> m # foldMap' :: Monoid m => (a -> m) -> Dual a -> m # foldr :: (a -> b -> b) -> b -> Dual a -> b # foldr' :: (a -> b -> b) -> b -> Dual a -> b # foldl :: (b -> a -> b) -> b -> Dual a -> b # foldl' :: (b -> a -> b) -> b -> Dual a -> b # foldr1 :: (a -> a -> a) -> Dual a -> a # foldl1 :: (a -> a -> a) -> Dual a -> a # toList :: Dual a -> [a] # null :: Dual a -> Bool # length :: Dual a -> Int # elem :: Eq a => a -> Dual a -> Bool # maximum :: Ord a => Dual a -> a # minimum :: Ord a => Dual a -> a # sum :: Num a => Dual a -> a # product :: Num a => Dual a -> a #
Traversable Dual | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> Dual a -> f (Dual b) # sequenceA :: Applicative f => Dual (f a) -> f (Dual a) # mapM :: Monad m => (a -> m b) -> Dual a -> m (Dual b) # sequence :: Monad m => Dual (m a) -> m (Dual a) #
Generic1 Dual |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep1 Dual | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep1 Dual = D1 ('MetaData "Dual" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Dual" 'PrefixI 'True) (S1 ('MetaSel ('Just "getDual") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
Methods from1 :: Dual a -> Rep1 Dual a # to1 :: Rep1 Dual a -> Dual a #
NFData a => NFData (Dual a) | Since: deepseq-1.4.0.0
Instance details Defined in Control.DeepSeq Methods rnf :: Dual a -> () #
Monoid a => Monoid (Dual a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods mempty :: Dual a # mappend :: Dual a -> Dual a -> Dual a # mconcat :: [Dual a] -> Dual a #
Semigroup a => Semigroup (Dual a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Dual a -> Dual a -> Dual a # sconcat :: NonEmpty (Dual a) -> Dual a # stimes :: Integral b => b -> Dual a -> Dual a #
Data a => Data (Dual a) | @since base-4.8.0.0
Instance details Defined in GHC.Internal.Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Dual a -> c (Dual a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Dual a) # toConstr :: Dual a -> Constr # dataTypeOf :: Dual a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Dual a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Dual a)) # gmapT :: (forall b. Data b => b -> b) -> Dual a -> Dual a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Dual a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Dual a -> r # gmapQ :: (forall d. Data d => d -> u) -> Dual a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Dual a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Dual a -> m (Dual a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Dual a -> m (Dual a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Dual a -> m (Dual a) #
Bounded a => Bounded (Dual a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods minBound :: Dual a # maxBound :: Dual a #
Generic (Dual a) |
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Associated Types
type Rep (Dual a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep (Dual a) = D1 ('MetaData "Dual" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Dual" 'PrefixI 'True) (S1 ('MetaSel ('Just "getDual") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
Methods from :: Dual a -> Rep (Dual a) x # to :: Rep (Dual a) x -> Dual a #
Read a => Read (Dual a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods readsPrec :: Int -> ReadS (Dual a) # readList :: ReadS [Dual a] # readPrec :: ReadPrec (Dual a) # readListPrec :: ReadPrec [Dual a] #
Show a => Show (Dual a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods showsPrec :: Int -> Dual a -> ShowS # show :: Dual a -> String # showList :: [Dual a] -> ShowS #
Eq a => Eq (Dual a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (==) :: Dual a -> Dual a -> Bool # (/=) :: Dual a -> Dual a -> Bool #
Ord a => Ord (Dual a) | @since base-2.01
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods compare :: Dual a -> Dual a -> Ordering # (<) :: Dual a -> Dual a -> Bool # (<=) :: Dual a -> Dual a -> Bool # (>) :: Dual a -> Dual a -> Bool # (>=) :: Dual a -> Dual a -> Bool # max :: Dual a -> Dual a -> Dual a # min :: Dual a -> Dual a -> Dual a #
type Rep1 Dual | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep1 Dual = D1 ('MetaData "Dual" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Dual" 'PrefixI 'True) (S1 ('MetaSel ('Just "getDual") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Dual a) | @since base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal type Rep (Dual a) = D1 ('MetaData "Dual" "GHC.Internal.Data.Semigroup.Internal" "ghc-internal" 'True) (C1 ('MetaCons "Dual" 'PrefixI 'True) (S1 ('MetaSel ('Just "getDual") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

newtype Ap (f :: k -> Type) (a :: k) #

This data type witnesses the lifting of a `Monoid` into an `Applicative` pointwise.

#### Examples

Expand

    >>> Ap (Just [1, 2, 3]) <> Ap Nothing
    Ap {getAp = Nothing}

    >>> Ap [Sum 10, Sum 20] <> Ap [Sum 1, Sum 2]
    Ap {getAp = [Sum {getSum = 11},Sum {getSum = 12},Sum {getSum = 21},Sum {getSum = 22}]}

@since base-4.12.0.0

Constructors

Ap |
Fields getAp :: f a

#### Instances

Instances details

Generic1 (Ap f :: k -> Type) |
Instance details Defined in GHC.Internal.Data.Monoid Associated Types
type Rep1 (Ap f :: k -> Type) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep1 (Ap f :: k -> Type) = D1 ('MetaData "Ap" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Ap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))
Methods from1 :: forall (a :: k). Ap f a -> Rep1 (Ap f) a # to1 :: forall (a :: k). Rep1 (Ap f) a -> Ap f a #
Foldable1 f => Foldable1 (Ap f) | Since: base-4.18.0.0
Instance details Defined in Data.Foldable1 Methods fold1 :: Semigroup m => Ap f m -> m # foldMap1 :: Semigroup m => (a -> m) -> Ap f a -> m # foldMap1' :: Semigroup m => (a -> m) -> Ap f a -> m # toNonEmpty :: Ap f a -> NonEmpty a # maximum :: Ord a => Ap f a -> a # minimum :: Ord a => Ap f a -> a # head :: Ap f a -> a # last :: Ap f a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Ap f a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Ap f a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Ap f a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Ap f a -> b #
Alternative f => Alternative (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods empty :: Ap f a # (<|>) :: Ap f a -> Ap f a -> Ap f a # some :: Ap f a -> Ap f [a] # many :: Ap f a -> Ap f [a] #
Applicative f => Applicative (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods pure :: a -> Ap f a # (<*>) :: Ap f (a -> b) -> Ap f a -> Ap f b # liftA2 :: (a -> b -> c) -> Ap f a -> Ap f b -> Ap f c # (*>) :: Ap f a -> Ap f b -> Ap f b # (<*) :: Ap f a -> Ap f b -> Ap f a #
Functor f => Functor (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods fmap :: (a -> b) -> Ap f a -> Ap f b # (<$) :: a -> Ap f b -> Ap f a #
Monad f => Monad (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (>>=) :: Ap f a -> (a -> Ap f b) -> Ap f b # (>>) :: Ap f a -> Ap f b -> Ap f b # return :: a -> Ap f a #
MonadPlus f => MonadPlus (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods mzero :: Ap f a # mplus :: Ap f a -> Ap f a -> Ap f a #
MonadFail f => MonadFail (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods fail :: String -> Ap f a #
Foldable f => Foldable (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Ap f m -> m # foldMap :: Monoid m => (a -> m) -> Ap f a -> m # foldMap' :: Monoid m => (a -> m) -> Ap f a -> m # foldr :: (a -> b -> b) -> b -> Ap f a -> b # foldr' :: (a -> b -> b) -> b -> Ap f a -> b # foldl :: (b -> a -> b) -> b -> Ap f a -> b # foldl' :: (b -> a -> b) -> b -> Ap f a -> b # foldr1 :: (a -> a -> a) -> Ap f a -> a # foldl1 :: (a -> a -> a) -> Ap f a -> a # toList :: Ap f a -> [a] # null :: Ap f a -> Bool # length :: Ap f a -> Int # elem :: Eq a => a -> Ap f a -> Bool # maximum :: Ord a => Ap f a -> a # minimum :: Ord a => Ap f a -> a # sum :: Num a => Ap f a -> a # product :: Num a => Ap f a -> a #
Traversable f => Traversable (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f0 => (a -> f0 b) -> Ap f a -> f0 (Ap f b) # sequenceA :: Applicative f0 => Ap f (f0 a) -> f0 (Ap f a) # mapM :: Monad m => (a -> m b) -> Ap f a -> m (Ap f b) # sequence :: Monad m => Ap f (m a) -> m (Ap f a) #
(Applicative f, Monoid a) => Monoid (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods mempty :: Ap f a # mappend :: Ap f a -> Ap f a -> Ap f a # mconcat :: [Ap f a] -> Ap f a #
(Applicative f, Semigroup a) => Semigroup (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (<>) :: Ap f a -> Ap f a -> Ap f a # sconcat :: NonEmpty (Ap f a) -> Ap f a # stimes :: Integral b => b -> Ap f a -> Ap f a #
(Data (f a), Data a, Typeable f) => Data (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Ap f a -> c (Ap f a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Ap f a) # toConstr :: Ap f a -> Constr # dataTypeOf :: Ap f a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Ap f a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ap f a)) # gmapT :: (forall b. Data b => b -> b) -> Ap f a -> Ap f a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ap f a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ap f a -> r # gmapQ :: (forall d. Data d => d -> u) -> Ap f a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Ap f a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ap f a -> m (Ap f a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ap f a -> m (Ap f a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ap f a -> m (Ap f a) #
(Applicative f, Bounded a) => Bounded (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods minBound :: Ap f a # maxBound :: Ap f a #
Enum (f a) => Enum (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods succ :: Ap f a -> Ap f a # pred :: Ap f a -> Ap f a # toEnum :: Int -> Ap f a # fromEnum :: Ap f a -> Int # enumFrom :: Ap f a -> [Ap f a] # enumFromThen :: Ap f a -> Ap f a -> [Ap f a] # enumFromTo :: Ap f a -> Ap f a -> [Ap f a] # enumFromThenTo :: Ap f a -> Ap f a -> Ap f a -> [Ap f a] #
Generic (Ap f a) |
Instance details Defined in GHC.Internal.Data.Monoid Associated Types
type Rep (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep (Ap f a) = D1 ('MetaData "Ap" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Ap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))
Methods from :: Ap f a -> Rep (Ap f a) x # to :: Rep (Ap f a) x -> Ap f a #
(Applicative f, Num a) => Num (Ap f a) | Note that even if the underlying `Num` and `Applicative` instances are lawful, for most `Applicative`s, this instance will not be lawful. If you use this instance with the list `Applicative`, the following customary laws will not hold: Commutativity:
    >>> Ap [10,20] + Ap [1,2]
    Ap {getAp = [11,12,21,22]}
    >>> Ap [1,2] + Ap [10,20]
    Ap {getAp = [11,21,12,22]}
Additive inverse:
    >>> Ap [] + negate (Ap [])
    Ap {getAp = []}
    >>> fromInteger 0 :: Ap [] Int
    Ap {getAp = [0]}
Distributivity:
    >>> Ap [1,2] * (3 + 4)
    Ap {getAp = [7,14]}
    >>> (Ap [1,2] * 3) + (Ap [1,2] * 4)
    Ap {getAp = [7,11,10,14]}
@since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (+) :: Ap f a -> Ap f a -> Ap f a # (-) :: Ap f a -> Ap f a -> Ap f a # (*) :: Ap f a -> Ap f a -> Ap f a # negate :: Ap f a -> Ap f a # abs :: Ap f a -> Ap f a # signum :: Ap f a -> Ap f a # fromInteger :: Integer -> Ap f a #
Read (f a) => Read (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods readsPrec :: Int -> ReadS (Ap f a) # readList :: ReadS [Ap f a] # readPrec :: ReadPrec (Ap f a) # readListPrec :: ReadPrec [Ap f a] #
Show (f a) => Show (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods showsPrec :: Int -> Ap f a -> ShowS # show :: Ap f a -> String # showList :: [Ap f a] -> ShowS #
Eq (f a) => Eq (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (==) :: Ap f a -> Ap f a -> Bool # (/=) :: Ap f a -> Ap f a -> Bool #
Ord (f a) => Ord (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods compare :: Ap f a -> Ap f a -> Ordering # (<) :: Ap f a -> Ap f a -> Bool # (<=) :: Ap f a -> Ap f a -> Bool # (>) :: Ap f a -> Ap f a -> Bool # (>=) :: Ap f a -> Ap f a -> Bool # max :: Ap f a -> Ap f a -> Ap f a # min :: Ap f a -> Ap f a -> Ap f a #
type Rep1 (Ap f :: k -> Type) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep1 (Ap f :: k -> Type) = D1 ('MetaData "Ap" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Ap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))
type Rep (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep (Ap f a) = D1 ('MetaData "Ap" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Ap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))

class Semigroup a where #

The class of semigroups (types with an associative binary operation).

Instances should satisfy the following:

Associativity
  `x `<>` (y `<>` z) = (x `<>` y) `<>` z`

You can alternatively define `sconcat` instead of (`<>`), in which case the laws are:

Unit
  ``sconcat` (`pure` x) = x`
Multiplication
  ``sconcat` (`join` xss) = `sconcat` (`fmap` `sconcat` xss)`

@since base-4.9.0.0

Minimal complete definition

(<>) | sconcat

Methods

(<>) :: a -> a -> a infixr 6 #

An associative operation.

#### Examples

Expand

    >>> [1,2,3] <> [4,5,6]
    [1,2,3,4,5,6]

    >>> Just [1, 2, 3] <> Just [4, 5, 6]
    Just [1,2,3,4,5,6]

    >>> putStr "Hello, " <> putStrLn "World!"
    Hello, World!

sconcat :: NonEmpty a -> a #

Reduce a non-empty list with `<>`

The default definition should be sufficient, but this can be overridden for efficiency.

#### Examples

Expand

For the following examples, we will assume that we have:

    >>> import Data.List.NonEmpty (NonEmpty (..))

    >>> sconcat $ "Hello" :| [" ", "Haskell", "!"]
    "Hello Haskell!"

    >>> sconcat $ Just [1, 2, 3] :| [Nothing, Just [4, 5, 6]]
    Just [1,2,3,4,5,6]

    >>> sconcat $ Left 1 :| [Right 2, Left 3, Right 4]
    Right 2

stimes :: Integral b => b -> a -> a #

Repeat a value `n` times.

The default definition will raise an exception for a multiplier that is `<= 0`. This may be overridden with an implementation that is total. For monoids it is preferred to use `stimesMonoid`.

By making this a member of the class, idempotent semigroups and monoids can upgrade this to execute in \(\mathcal{O}(1)\) by picking `stimes = `stimesIdempotent`` or `stimes = `stimesIdempotentMonoid`` respectively.

#### Examples

Expand

    >>> stimes 4 [1]
    [1,1,1,1]

    >>> stimes 5 (putStr "hi!")
    hi!hi!hi!hi!hi!

    >>> stimes 3 (Right ":)")
    Right ":)"

#### Instances

Instances details

Semigroup ByteArray | Since: base-4.17.0.0
Instance details Defined in Data.Array.Byte Methods (<>) :: ByteArray -> ByteArray -> ByteArray # sconcat :: NonEmpty ByteArray -> ByteArray # stimes :: Integral b => b -> ByteArray -> ByteArray #
Semigroup Builder |
Instance details Defined in Data.ByteString.Builder.Internal Methods (<>) :: Builder -> Builder -> Builder # sconcat :: NonEmpty Builder -> Builder # stimes :: Integral b => b -> Builder -> Builder #
Semigroup ByteString |
Instance details Defined in Data.ByteString.Internal.Type Methods (<>) :: ByteString -> ByteString -> ByteString # sconcat :: NonEmpty ByteString -> ByteString # stimes :: Integral b => b -> ByteString -> ByteString #
Semigroup ByteString |
Instance details Defined in Data.ByteString.Lazy.Internal Methods (<>) :: ByteString -> ByteString -> ByteString # sconcat :: NonEmpty ByteString -> ByteString # stimes :: Integral b => b -> ByteString -> ByteString #
Semigroup ShortByteString |
Instance details Defined in Data.ByteString.Short.Internal Methods (<>) :: ShortByteString -> ShortByteString -> ShortByteString # sconcat :: NonEmpty ShortByteString -> ShortByteString # stimes :: Integral b => b -> ShortByteString -> ShortByteString #
Semigroup IntSet | Since: containers-0.5.7
Instance details Defined in Data.IntSet.Internal Methods (<>) :: IntSet -> IntSet -> IntSet # sconcat :: NonEmpty IntSet -> IntSet # stimes :: Integral b => b -> IntSet -> IntSet #
Semigroup Void | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: Void -> Void -> Void # sconcat :: NonEmpty Void -> Void # stimes :: Integral b => b -> Void -> Void #
Semigroup All | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: All -> All -> All # sconcat :: NonEmpty All -> All # stimes :: Integral b => b -> All -> All #
Semigroup Any | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Any -> Any -> Any # sconcat :: NonEmpty Any -> Any # stimes :: Integral b => b -> Any -> Any #
Semigroup Ordering | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: Ordering -> Ordering -> Ordering # sconcat :: NonEmpty Ordering -> Ordering # stimes :: Integral b => b -> Ordering -> Ordering #
Semigroup OsString |
Instance details Defined in System.OsString.Internal.Types Methods (<>) :: OsString -> OsString -> OsString # sconcat :: NonEmpty OsString -> OsString # stimes :: Integral b => b -> OsString -> OsString #
Semigroup PosixString |
Instance details Defined in System.OsString.Internal.Types Methods (<>) :: PosixString -> PosixString -> PosixString # sconcat :: NonEmpty PosixString -> PosixString # stimes :: Integral b => b -> PosixString -> PosixString #
Semigroup WindowsString |
Instance details Defined in System.OsString.Internal.Types Methods (<>) :: WindowsString -> WindowsString -> WindowsString # sconcat :: NonEmpty WindowsString -> WindowsString # stimes :: Integral b => b -> WindowsString -> WindowsString #
Semigroup Doc |
Instance details Defined in Text.PrettyPrint.HughesPJ Methods (<>) :: Doc -> Doc -> Doc # sconcat :: NonEmpty Doc -> Doc # stimes :: Integral b => b -> Doc -> Doc #
Semigroup Builder |
Instance details Defined in Data.Text.Internal.Builder Methods (<>) :: Builder -> Builder -> Builder # sconcat :: NonEmpty Builder -> Builder # stimes :: Integral b => b -> Builder -> Builder #
Semigroup StrictBuilder | Concatenation of `StrictBuilder` is right-biased: the right builder will be run first. This allows a builder to run tail-recursively when it was accumulated left-to-right.
Instance details Defined in Data.Text.Internal.StrictBuilder Methods (<>) :: StrictBuilder -> StrictBuilder -> StrictBuilder # sconcat :: NonEmpty StrictBuilder -> StrictBuilder # stimes :: Integral b => b -> StrictBuilder -> StrictBuilder #
Semigroup () | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: () -> () -> () # sconcat :: NonEmpty () -> () # stimes :: Integral b => b -> () -> () #
Semigroup (FromMaybe b) |
Instance details Defined in Data.Foldable1 Methods (<>) :: FromMaybe b -> FromMaybe b -> FromMaybe b # sconcat :: NonEmpty (FromMaybe b) -> FromMaybe b # stimes :: Integral b0 => b0 -> FromMaybe b -> FromMaybe b #
Semigroup a => Semigroup (JoinWith a) |
Instance details Defined in Data.Foldable1 Methods (<>) :: JoinWith a -> JoinWith a -> JoinWith a # sconcat :: NonEmpty (JoinWith a) -> JoinWith a # stimes :: Integral b => b -> JoinWith a -> JoinWith a #
Semigroup (NonEmptyDList a) |
Instance details Defined in Data.Foldable1 Methods (<>) :: NonEmptyDList a -> NonEmptyDList a -> NonEmptyDList a # sconcat :: NonEmpty (NonEmptyDList a) -> NonEmptyDList a # stimes :: Integral b => b -> NonEmptyDList a -> NonEmptyDList a #
Semigroup (Comparison a) | `(`<>`)` on comparisons combines results with `(`<>`) @Ordering`. Without newtypes this equals ``liftA2` (`liftA2` (`<>`))`.
    (<>) :: Comparison a -> Comparison a -> Comparison a
    Comparison cmp <> Comparison cmp' = Comparison a a' ->
      cmp a a' <> cmp a a'
Instance details Defined in Data.Functor.Contravariant Methods (<>) :: Comparison a -> Comparison a -> Comparison a # sconcat :: NonEmpty (Comparison a) -> Comparison a # stimes :: Integral b => b -> Comparison a -> Comparison a #
Semigroup (Equivalence a) | `(`<>`)` on equivalences uses logical conjunction `(`&&`)` on the results. Without newtypes this equals ``liftA2` (`liftA2` (&&))`.
    (<>) :: Equivalence a -> Equivalence a -> Equivalence a
    Equivalence equiv <> Equivalence equiv' = Equivalence a b ->
      equiv a b && equiv' a b
Instance details Defined in Data.Functor.Contravariant Methods (<>) :: Equivalence a -> Equivalence a -> Equivalence a # sconcat :: NonEmpty (Equivalence a) -> Equivalence a # stimes :: Integral b => b -> Equivalence a -> Equivalence a #
Semigroup (Predicate a) | `(`<>`)` on predicates uses logical conjunction `(`&&`)` on the results. Without newtypes this equals ``liftA2` (&&)`.
    (<>) :: Predicate a -> Predicate a -> Predicate a
    Predicate pred <> Predicate pred' = Predicate a ->
      pred a && pred' a
Instance details Defined in Data.Functor.Contravariant Methods (<>) :: Predicate a -> Predicate a -> Predicate a # sconcat :: NonEmpty (Predicate a) -> Predicate a # stimes :: Integral b => b -> Predicate a -> Predicate a #
Semigroup (First a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: First a -> First a -> First a # sconcat :: NonEmpty (First a) -> First a # stimes :: Integral b => b -> First a -> First a #
Semigroup (Last a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: Last a -> Last a -> Last a # sconcat :: NonEmpty (Last a) -> Last a # stimes :: Integral b => b -> Last a -> Last a #
Ord a => Semigroup (Max a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: Max a -> Max a -> Max a # sconcat :: NonEmpty (Max a) -> Max a # stimes :: Integral b => b -> Max a -> Max a #
Ord a => Semigroup (Min a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: Min a -> Min a -> Min a # sconcat :: NonEmpty (Min a) -> Min a # stimes :: Integral b => b -> Min a -> Min a #
Monoid m => Semigroup (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m # sconcat :: NonEmpty (WrappedMonoid m) -> WrappedMonoid m # stimes :: Integral b => b -> WrappedMonoid m -> WrappedMonoid m #
Semigroup (IntMap a) | Since: containers-0.5.7
Instance details Defined in Data.IntMap.Internal Methods (<>) :: IntMap a -> IntMap a -> IntMap a # sconcat :: NonEmpty (IntMap a) -> IntMap a # stimes :: Integral b => b -> IntMap a -> IntMap a #
Semigroup (Seq a) | Since: containers-0.5.7
Instance details Defined in Data.Sequence.Internal Methods (<>) :: Seq a -> Seq a -> Seq a # sconcat :: NonEmpty (Seq a) -> Seq a # stimes :: Integral b => b -> Seq a -> Seq a #
Ord a => Semigroup (Intersection a) |
Instance details Defined in Data.Set.Internal Methods (<>) :: Intersection a -> Intersection a -> Intersection a # sconcat :: NonEmpty (Intersection a) -> Intersection a # stimes :: Integral b => b -> Intersection a -> Intersection a #
Semigroup (MergeSet a) |
Instance details Defined in Data.Set.Internal Methods (<>) :: MergeSet a -> MergeSet a -> MergeSet a # sconcat :: NonEmpty (MergeSet a) -> MergeSet a # stimes :: Integral b => b -> MergeSet a -> MergeSet a #
Ord a => Semigroup (Set a) | Since: containers-0.5.7
Instance details Defined in Data.Set.Internal Methods (<>) :: Set a -> Set a -> Set a # sconcat :: NonEmpty (Set a) -> Set a # stimes :: Integral b => b -> Set a -> Set a #
Semigroup (NonEmpty a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: NonEmpty a -> NonEmpty a -> NonEmpty a # sconcat :: NonEmpty (NonEmpty a) -> NonEmpty a # stimes :: Integral b => b -> NonEmpty a -> NonEmpty a #
Semigroup a => Semigroup (STM a) | @since base-4.17.0.0
Instance details Defined in GHC.Internal.Conc.Sync Methods (<>) :: STM a -> STM a -> STM a # sconcat :: NonEmpty (STM a) -> STM a # stimes :: Integral b => b -> STM a -> STM a #
Semigroup a => Semigroup (Identity a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Identity Methods (<>) :: Identity a -> Identity a -> Identity a # sconcat :: NonEmpty (Identity a) -> Identity a # stimes :: Integral b => b -> Identity a -> Identity a #
Semigroup (First a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (<>) :: First a -> First a -> First a # sconcat :: NonEmpty (First a) -> First a # stimes :: Integral b => b -> First a -> First a #
Semigroup (Last a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (<>) :: Last a -> Last a -> Last a # sconcat :: NonEmpty (Last a) -> Last a # stimes :: Integral b => b -> Last a -> Last a #
Semigroup a => Semigroup (Down a) | @since base-4.11.0.0
Instance details Defined in GHC.Internal.Data.Ord Methods (<>) :: Down a -> Down a -> Down a # sconcat :: NonEmpty (Down a) -> Down a # stimes :: Integral b => b -> Down a -> Down a #
Semigroup a => Semigroup (Dual a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Dual a -> Dual a -> Dual a # sconcat :: NonEmpty (Dual a) -> Dual a # stimes :: Integral b => b -> Dual a -> Dual a #
Semigroup (Endo a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Endo a -> Endo a -> Endo a # sconcat :: NonEmpty (Endo a) -> Endo a # stimes :: Integral b => b -> Endo a -> Endo a #
Num a => Semigroup (Product a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Product a -> Product a -> Product a # sconcat :: NonEmpty (Product a) -> Product a # stimes :: Integral b => b -> Product a -> Product a #
Num a => Semigroup (Sum a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Sum a -> Sum a -> Sum a # sconcat :: NonEmpty (Sum a) -> Sum a # stimes :: Integral b => b -> Sum a -> Sum a #
(Generic a, Semigroup (Rep a ())) => Semigroup (Generically a) | @since base-4.17.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: Generically a -> Generically a -> Generically a # sconcat :: NonEmpty (Generically a) -> Generically a # stimes :: Integral b => b -> Generically a -> Generically a #
Semigroup p => Semigroup (Par1 p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: Par1 p -> Par1 p -> Par1 p # sconcat :: NonEmpty (Par1 p) -> Par1 p # stimes :: Integral b => b -> Par1 p -> Par1 p #
Semigroup a => Semigroup (IO a) | @since base-4.10.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: IO a -> IO a -> IO a # sconcat :: NonEmpty (IO a) -> IO a # stimes :: Integral b => b -> IO a -> IO a #
Semigroup (Doc a) |
Instance details Defined in Text.PrettyPrint.Annotated.HughesPJ Methods (<>) :: Doc a -> Doc a -> Doc a # sconcat :: NonEmpty (Doc a) -> Doc a # stimes :: Integral b => b -> Doc a -> Doc a #
Semigroup a => Semigroup (Q a) | Since: template-haskell-2.17.0.0
Instance details Defined in Language.Haskell.TH.Syntax Methods (<>) :: Q a -> Q a -> Q a # sconcat :: NonEmpty (Q a) -> Q a # stimes :: Integral b => b -> Q a -> Q a #
Semigroup (Validity k) |
Instance details Defined in Data.HashMap.Internal.Debug Methods (<>) :: Validity k -> Validity k -> Validity k # sconcat :: NonEmpty (Validity k) -> Validity k # stimes :: Integral b => b -> Validity k -> Validity k #
(Hashable a, Eq a) => Semigroup (HashSet a) | `<>` = `union` \(O(n+m)\) To obtain good performance, the smaller set must be presented as the first argument. #### Examples Expand
    >>> fromList [1,2] <> fromList [2,3]
    fromList [1,2,3]
Instance details Defined in Data.HashSet.Internal Methods (<>) :: HashSet a -> HashSet a -> HashSet a # sconcat :: NonEmpty (HashSet a) -> HashSet a # stimes :: Integral b => b -> HashSet a -> HashSet a #
Semigroup a => Semigroup (Maybe a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: Maybe a -> Maybe a -> Maybe a # sconcat :: NonEmpty (Maybe a) -> Maybe a # stimes :: Integral b => b -> Maybe a -> Maybe a #
Semigroup a => Semigroup (Solo a) | @since base-4.15
Instance details Defined in GHC.Internal.Base Methods (<>) :: Solo a -> Solo a -> Solo a # sconcat :: NonEmpty (Solo a) -> Solo a # stimes :: Integral b => b -> Solo a -> Solo a #
Semigroup [a] | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: [a] -> [a] -> [a] # sconcat :: NonEmpty [a] -> [a] # stimes :: Integral b => b -> [a] -> [a] #
Semigroup a => Semigroup (Op a b) | `(`<>`) @(Op a b)` without newtypes is `(`<>`) @(b->a)` = `liftA2 (`<>`)`. This lifts the `Semigroup` operation `(`<>`)` over the output of `a`.
    (<>) :: Op a b -> Op a b -> Op a b
    Op f <> Op g = Op a -> f a <> g a
Instance details Defined in Data.Functor.Contravariant Methods (<>) :: Op a b -> Op a b -> Op a b # sconcat :: NonEmpty (Op a b) -> Op a b # stimes :: Integral b0 => b0 -> Op a b -> Op a b #
Ord k => Semigroup (Map k v) |
Instance details Defined in Data.Map.Internal Methods (<>) :: Map k v -> Map k v -> Map k v # sconcat :: NonEmpty (Map k v) -> Map k v # stimes :: Integral b => b -> Map k v -> Map k v #
Semigroup (Either a b) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Either Methods (<>) :: Either a b -> Either a b -> Either a b # sconcat :: NonEmpty (Either a b) -> Either a b # stimes :: Integral b0 => b0 -> Either a b -> Either a b #
Semigroup (Proxy s) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Proxy Methods (<>) :: Proxy s -> Proxy s -> Proxy s # sconcat :: NonEmpty (Proxy s) -> Proxy s # stimes :: Integral b => b -> Proxy s -> Proxy s #
Semigroup (U1 p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: U1 p -> U1 p -> U1 p # sconcat :: NonEmpty (U1 p) -> U1 p # stimes :: Integral b => b -> U1 p -> U1 p #
Semigroup (V1 p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: V1 p -> V1 p -> V1 p # sconcat :: NonEmpty (V1 p) -> V1 p # stimes :: Integral b => b -> V1 p -> V1 p #
(Eq k, Hashable k) => Semigroup (HashMap k v) | `<>` = `union` If a key occurs in both maps, the mapping from the first will be the mapping in the result. #### Examples Expand
    >>> fromList [(1,'a'),(2,'b')] <> fromList [(2,'c'),(3,'d')]
    fromList [(1,'a'),(2,'b'),(3,'d')]
Instance details Defined in Data.HashMap.Internal Methods (<>) :: HashMap k v -> HashMap k v -> HashMap k v # sconcat :: NonEmpty (HashMap k v) -> HashMap k v # stimes :: Integral b => b -> HashMap k v -> HashMap k v #
(Semigroup a, Semigroup b) => Semigroup (a, b) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: (a, b) -> (a, b) -> (a, b) # sconcat :: NonEmpty (a, b) -> (a, b) # stimes :: Integral b0 => b0 -> (a, b) -> (a, b) #
Semigroup b => Semigroup (a -> b) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: (a -> b) -> (a -> b) -> a -> b # sconcat :: NonEmpty (a -> b) -> a -> b # stimes :: Integral b0 => b0 -> (a -> b) -> a -> b #
Semigroup a => Semigroup (Const a b) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Functor.Const Methods (<>) :: Const a b -> Const a b -> Const a b # sconcat :: NonEmpty (Const a b) -> Const a b # stimes :: Integral b0 => b0 -> Const a b -> Const a b #
(Applicative f, Semigroup a) => Semigroup (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (<>) :: Ap f a -> Ap f a -> Ap f a # sconcat :: NonEmpty (Ap f a) -> Ap f a # stimes :: Integral b => b -> Ap f a -> Ap f a #
Alternative f => Semigroup (Alt f a) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Data.Semigroup.Internal Methods (<>) :: Alt f a -> Alt f a -> Alt f a # sconcat :: NonEmpty (Alt f a) -> Alt f a # stimes :: Integral b => b -> Alt f a -> Alt f a #
Semigroup (f p) => Semigroup (Rec1 f p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: Rec1 f p -> Rec1 f p -> Rec1 f p # sconcat :: NonEmpty (Rec1 f p) -> Rec1 f p # stimes :: Integral b => b -> Rec1 f p -> Rec1 f p #
Semigroup a => Semigroup (Constant a b) |
Instance details Defined in Data.Functor.Constant Methods (<>) :: Constant a b -> Constant a b -> Constant a b # sconcat :: NonEmpty (Constant a b) -> Constant a b # stimes :: Integral b0 => b0 -> Constant a b -> Constant a b #
(Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: (a, b, c) -> (a, b, c) -> (a, b, c) # sconcat :: NonEmpty (a, b, c) -> (a, b, c) # stimes :: Integral b0 => b0 -> (a, b, c) -> (a, b, c) #
(Semigroup (f a), Semigroup (g a)) => Semigroup (Product f g a) | Since: base-4.16.0.0
Instance details Defined in Data.Functor.Product Methods (<>) :: Product f g a -> Product f g a -> Product f g a # sconcat :: NonEmpty (Product f g a) -> Product f g a # stimes :: Integral b => b -> Product f g a -> Product f g a #
(Semigroup (f p), Semigroup (g p)) => Semigroup ((f :*: g) p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: (f :*: g) p -> (f :*: g) p -> (f :*: g) p # sconcat :: NonEmpty ((f :*: g) p) -> (f :*: g) p # stimes :: Integral b => b -> (f :*: g) p -> (f :*: g) p #
Semigroup c => Semigroup (K1 i c p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: K1 i c p -> K1 i c p -> K1 i c p # sconcat :: NonEmpty (K1 i c p) -> K1 i c p # stimes :: Integral b => b -> K1 i c p -> K1 i c p #
(Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) # sconcat :: NonEmpty (a, b, c, d) -> (a, b, c, d) # stimes :: Integral b0 => b0 -> (a, b, c, d) -> (a, b, c, d) #
Semigroup (f (g a)) => Semigroup (Compose f g a) | Since: base-4.16.0.0
Instance details Defined in Data.Functor.Compose Methods (<>) :: Compose f g a -> Compose f g a -> Compose f g a # sconcat :: NonEmpty (Compose f g a) -> Compose f g a # stimes :: Integral b => b -> Compose f g a -> Compose f g a #
Semigroup (f (g p)) => Semigroup ((f :.: g) p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: (f :.: g) p -> (f :.: g) p -> (f :.: g) p # sconcat :: NonEmpty ((f :.: g) p) -> (f :.: g) p # stimes :: Integral b => b -> (f :.: g) p -> (f :.: g) p #
Semigroup (f p) => Semigroup (M1 i c f p) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Generics Methods (<>) :: M1 i c f p -> M1 i c f p -> M1 i c f p # sconcat :: NonEmpty (M1 i c f p) -> M1 i c f p # stimes :: Integral b => b -> M1 i c f p -> M1 i c f p #
(Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e) | @since base-4.9.0.0
Instance details Defined in GHC.Internal.Base Methods (<>) :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) # sconcat :: NonEmpty (a, b, c, d, e) -> (a, b, c, d, e) # stimes :: Integral b0 => b0 -> (a, b, c, d, e) -> (a, b, c, d, e) #

stimesIdempotent :: Integral b => b -> a -> a #

This is a valid definition of `stimes` for an idempotent `Semigroup`.

When `x <> x = x`, this definition should be preferred, because it works in \(\mathcal{O}(1)\) rather than \(\mathcal{O}(\log n)\).

stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> a #

This is a valid definition of `stimes` for an idempotent `Monoid`.

When `x <> x = x`, this definition should be preferred, because it works in \(\mathcal{O}(1)\) rather than \(\mathcal{O}(\log n)\)

stimesMonoid :: (Integral b, Monoid a) => b -> a -> a #

This is a valid definition of `stimes` for a `Monoid`.

Unlike the default definition of `stimes`, it is defined for 0 and so it should be preferred where possible.

data WrappedMonoid m #

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.

#### Instances

Instances details

NFData1 WrappedMonoid | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a -> ()) -> WrappedMonoid a -> () #
Generic1 WrappedMonoid |
Instance details Defined in Data.Semigroup Associated Types
type Rep1 WrappedMonoid | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup type Rep1 WrappedMonoid = D1 ('MetaData "WrappedMonoid" "Data.Semigroup" "base" 'True) (C1 ('MetaCons "WrapMonoid" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapMonoid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
Methods from1 :: WrappedMonoid a -> Rep1 WrappedMonoid a # to1 :: Rep1 WrappedMonoid a -> WrappedMonoid a #
NFData m => NFData (WrappedMonoid m) | Since: deepseq-1.4.2.0
Instance details Defined in Control.DeepSeq Methods rnf :: WrappedMonoid m -> () #
Monoid m => Monoid (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods mempty :: WrappedMonoid m # mappend :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m # mconcat :: [WrappedMonoid m] -> WrappedMonoid m #
Monoid m => Semigroup (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (<>) :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m # sconcat :: NonEmpty (WrappedMonoid m) -> WrappedMonoid m # stimes :: Integral b => b -> WrappedMonoid m -> WrappedMonoid m #
Data m => Data (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> WrappedMonoid m -> c (WrappedMonoid m) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (WrappedMonoid m) # toConstr :: WrappedMonoid m -> Constr # dataTypeOf :: WrappedMonoid m -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (WrappedMonoid m)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (WrappedMonoid m)) # gmapT :: (forall b. Data b => b -> b) -> WrappedMonoid m -> WrappedMonoid m # gmapQl :: (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 # gmapQ :: (forall d. Data d => d -> u) -> WrappedMonoid m -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> WrappedMonoid m -> u # gmapM :: Monad m0 => (forall d. Data d => d -> m0 d) -> WrappedMonoid m -> m0 (WrappedMonoid m) # gmapMp :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> WrappedMonoid m -> m0 (WrappedMonoid m) # gmapMo :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> WrappedMonoid m -> m0 (WrappedMonoid m) #
Bounded m => Bounded (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods minBound :: WrappedMonoid m # maxBound :: WrappedMonoid m #
Enum a => Enum (WrappedMonoid a) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods succ :: WrappedMonoid a -> WrappedMonoid a # pred :: WrappedMonoid a -> WrappedMonoid a # toEnum :: Int -> WrappedMonoid a # fromEnum :: WrappedMonoid a -> Int # enumFrom :: WrappedMonoid a -> [WrappedMonoid a] # enumFromThen :: WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a] # enumFromTo :: WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a] # enumFromThenTo :: WrappedMonoid a -> WrappedMonoid a -> WrappedMonoid a -> [WrappedMonoid a] #
Generic (WrappedMonoid m) |
Instance details Defined in Data.Semigroup Associated Types
type Rep (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup type Rep (WrappedMonoid m) = D1 ('MetaData "WrappedMonoid" "Data.Semigroup" "base" 'True) (C1 ('MetaCons "WrapMonoid" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapMonoid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 m)))
Methods from :: WrappedMonoid m -> Rep (WrappedMonoid m) x # to :: Rep (WrappedMonoid m) x -> WrappedMonoid m #
Read m => Read (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods readsPrec :: Int -> ReadS (WrappedMonoid m) # readList :: ReadS [WrappedMonoid m] # readPrec :: ReadPrec (WrappedMonoid m) # readListPrec :: ReadPrec [WrappedMonoid m] #
Show m => Show (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods showsPrec :: Int -> WrappedMonoid m -> ShowS # show :: WrappedMonoid m -> String # showList :: [WrappedMonoid m] -> ShowS #
Eq m => Eq (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods (==) :: WrappedMonoid m -> WrappedMonoid m -> Bool # (/=) :: WrappedMonoid m -> WrappedMonoid m -> Bool #
Ord m => Ord (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup Methods compare :: 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 # max :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m # min :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m #
Hashable a => Hashable (WrappedMonoid a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> WrappedMonoid a -> Int # hash :: WrappedMonoid a -> Int #
type Rep1 WrappedMonoid | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup type Rep1 WrappedMonoid = D1 ('MetaData "WrappedMonoid" "Data.Semigroup" "base" 'True) (C1 ('MetaCons "WrapMonoid" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapMonoid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (WrappedMonoid m) | Since: base-4.9.0.0
Instance details Defined in Data.Semigroup type Rep (WrappedMonoid m) = D1 ('MetaData "WrappedMonoid" "Data.Semigroup" "base" 'True) (C1 ('MetaCons "WrapMonoid" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapMonoid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 m)))

cycle1 :: Semigroup m => m -> m #

A generalization of `cycle` to an arbitrary `Semigroup`. May fail to terminate for some values in some semigroups.

#### Examples

Expand

    >>> take 10 $ cycle1 [1, 2, 3]
    [1,2,3,1,2,3,1,2,3,1]

    >>> cycle1 (Right 1)
    Right 1

    >>> cycle1 (Left 1)
    * hangs forever *

mtimesDefault :: (Integral b, Monoid a) => b -> a -> a #

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.

#### Examples

Expand

    >>> mtimesDefault 0 "bark"
    []

    >>> mtimesDefault 3 "meow"
    "meowmeowmeow"

newtype Ap (f :: k -> Type) (a :: k) #

This data type witnesses the lifting of a `Monoid` into an `Applicative` pointwise.

#### Examples

Expand

    >>> Ap (Just [1, 2, 3]) <> Ap Nothing
    Ap {getAp = Nothing}

    >>> Ap [Sum 10, Sum 20] <> Ap [Sum 1, Sum 2]
    Ap {getAp = [Sum {getSum = 11},Sum {getSum = 12},Sum {getSum = 21},Sum {getSum = 22}]}

@since base-4.12.0.0

Constructors

Ap |
Fields getAp :: f a

#### Instances

Instances details

Generic1 (Ap f :: k -> Type) |
Instance details Defined in GHC.Internal.Data.Monoid Associated Types
type Rep1 (Ap f :: k -> Type) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep1 (Ap f :: k -> Type) = D1 ('MetaData "Ap" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Ap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))
Methods from1 :: forall (a :: k). Ap f a -> Rep1 (Ap f) a # to1 :: forall (a :: k). Rep1 (Ap f) a -> Ap f a #
Foldable1 f => Foldable1 (Ap f) | Since: base-4.18.0.0
Instance details Defined in Data.Foldable1 Methods fold1 :: Semigroup m => Ap f m -> m # foldMap1 :: Semigroup m => (a -> m) -> Ap f a -> m # foldMap1' :: Semigroup m => (a -> m) -> Ap f a -> m # toNonEmpty :: Ap f a -> NonEmpty a # maximum :: Ord a => Ap f a -> a # minimum :: Ord a => Ap f a -> a # head :: Ap f a -> a # last :: Ap f a -> a # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Ap f a -> b # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Ap f a -> b # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Ap f a -> b # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Ap f a -> b #
Alternative f => Alternative (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods empty :: Ap f a # (<|>) :: Ap f a -> Ap f a -> Ap f a # some :: Ap f a -> Ap f [a] # many :: Ap f a -> Ap f [a] #
Applicative f => Applicative (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods pure :: a -> Ap f a # (<*>) :: Ap f (a -> b) -> Ap f a -> Ap f b # liftA2 :: (a -> b -> c) -> Ap f a -> Ap f b -> Ap f c # (*>) :: Ap f a -> Ap f b -> Ap f b # (<*) :: Ap f a -> Ap f b -> Ap f a #
Functor f => Functor (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods fmap :: (a -> b) -> Ap f a -> Ap f b # (<$) :: a -> Ap f b -> Ap f a #
Monad f => Monad (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (>>=) :: Ap f a -> (a -> Ap f b) -> Ap f b # (>>) :: Ap f a -> Ap f b -> Ap f b # return :: a -> Ap f a #
MonadPlus f => MonadPlus (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods mzero :: Ap f a # mplus :: Ap f a -> Ap f a -> Ap f a #
MonadFail f => MonadFail (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods fail :: String -> Ap f a #
Foldable f => Foldable (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Foldable Methods fold :: Monoid m => Ap f m -> m # foldMap :: Monoid m => (a -> m) -> Ap f a -> m # foldMap' :: Monoid m => (a -> m) -> Ap f a -> m # foldr :: (a -> b -> b) -> b -> Ap f a -> b # foldr' :: (a -> b -> b) -> b -> Ap f a -> b # foldl :: (b -> a -> b) -> b -> Ap f a -> b # foldl' :: (b -> a -> b) -> b -> Ap f a -> b # foldr1 :: (a -> a -> a) -> Ap f a -> a # foldl1 :: (a -> a -> a) -> Ap f a -> a # toList :: Ap f a -> [a] # null :: Ap f a -> Bool # length :: Ap f a -> Int # elem :: Eq a => a -> Ap f a -> Bool # maximum :: Ord a => Ap f a -> a # minimum :: Ord a => Ap f a -> a # sum :: Num a => Ap f a -> a # product :: Num a => Ap f a -> a #
Traversable f => Traversable (Ap f) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Traversable Methods traverse :: Applicative f0 => (a -> f0 b) -> Ap f a -> f0 (Ap f b) # sequenceA :: Applicative f0 => Ap f (f0 a) -> f0 (Ap f a) # mapM :: Monad m => (a -> m b) -> Ap f a -> m (Ap f b) # sequence :: Monad m => Ap f (m a) -> m (Ap f a) #
(Applicative f, Monoid a) => Monoid (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods mempty :: Ap f a # mappend :: Ap f a -> Ap f a -> Ap f a # mconcat :: [Ap f a] -> Ap f a #
(Applicative f, Semigroup a) => Semigroup (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (<>) :: Ap f a -> Ap f a -> Ap f a # sconcat :: NonEmpty (Ap f a) -> Ap f a # stimes :: Integral b => b -> Ap f a -> Ap f a #
(Data (f a), Data a, Typeable f) => Data (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Ap f a -> c (Ap f a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Ap f a) # toConstr :: Ap f a -> Constr # dataTypeOf :: Ap f a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Ap f a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Ap f a)) # gmapT :: (forall b. Data b => b -> b) -> Ap f a -> Ap f a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ap f a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ap f a -> r # gmapQ :: (forall d. Data d => d -> u) -> Ap f a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Ap f a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ap f a -> m (Ap f a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ap f a -> m (Ap f a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ap f a -> m (Ap f a) #
(Applicative f, Bounded a) => Bounded (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods minBound :: Ap f a # maxBound :: Ap f a #
Enum (f a) => Enum (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods succ :: Ap f a -> Ap f a # pred :: Ap f a -> Ap f a # toEnum :: Int -> Ap f a # fromEnum :: Ap f a -> Int # enumFrom :: Ap f a -> [Ap f a] # enumFromThen :: Ap f a -> Ap f a -> [Ap f a] # enumFromTo :: Ap f a -> Ap f a -> [Ap f a] # enumFromThenTo :: Ap f a -> Ap f a -> Ap f a -> [Ap f a] #
Generic (Ap f a) |
Instance details Defined in GHC.Internal.Data.Monoid Associated Types
type Rep (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep (Ap f a) = D1 ('MetaData "Ap" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Ap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))
Methods from :: Ap f a -> Rep (Ap f a) x # to :: Rep (Ap f a) x -> Ap f a #
(Applicative f, Num a) => Num (Ap f a) | Note that even if the underlying `Num` and `Applicative` instances are lawful, for most `Applicative`s, this instance will not be lawful. If you use this instance with the list `Applicative`, the following customary laws will not hold: Commutativity:
    >>> Ap [10,20] + Ap [1,2]
    Ap {getAp = [11,12,21,22]}
    >>> Ap [1,2] + Ap [10,20]
    Ap {getAp = [11,21,12,22]}
Additive inverse:
    >>> Ap [] + negate (Ap [])
    Ap {getAp = []}
    >>> fromInteger 0 :: Ap [] Int
    Ap {getAp = [0]}
Distributivity:
    >>> Ap [1,2] * (3 + 4)
    Ap {getAp = [7,14]}
    >>> (Ap [1,2] * 3) + (Ap [1,2] * 4)
    Ap {getAp = [7,11,10,14]}
@since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (+) :: Ap f a -> Ap f a -> Ap f a # (-) :: Ap f a -> Ap f a -> Ap f a # (*) :: Ap f a -> Ap f a -> Ap f a # negate :: Ap f a -> Ap f a # abs :: Ap f a -> Ap f a # signum :: Ap f a -> Ap f a # fromInteger :: Integer -> Ap f a #
Read (f a) => Read (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods readsPrec :: Int -> ReadS (Ap f a) # readList :: ReadS [Ap f a] # readPrec :: ReadPrec (Ap f a) # readListPrec :: ReadPrec [Ap f a] #
Show (f a) => Show (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods showsPrec :: Int -> Ap f a -> ShowS # show :: Ap f a -> String # showList :: [Ap f a] -> ShowS #
Eq (f a) => Eq (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods (==) :: Ap f a -> Ap f a -> Bool # (/=) :: Ap f a -> Ap f a -> Bool #
Ord (f a) => Ord (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid Methods compare :: Ap f a -> Ap f a -> Ordering # (<) :: Ap f a -> Ap f a -> Bool # (<=) :: Ap f a -> Ap f a -> Bool # (>) :: Ap f a -> Ap f a -> Bool # (>=) :: Ap f a -> Ap f a -> Bool # max :: Ap f a -> Ap f a -> Ap f a # min :: Ap f a -> Ap f a -> Ap f a #
type Rep1 (Ap f :: k -> Type) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep1 (Ap f :: k -> Type) = D1 ('MetaData "Ap" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Ap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))
type Rep (Ap f a) | @since base-4.12.0.0
Instance details Defined in GHC.Internal.Data.Monoid type Rep (Ap f a) = D1 ('MetaData "Ap" "GHC.Internal.Data.Monoid" "ghc-internal" 'True) (C1 ('MetaCons "Ap" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f a))))

# Combinators

maybeToMonoid :: Monoid m => Maybe m -> m #

Extracts `Monoid` value from `Maybe` returning `mempty` if `Nothing`.

    >>> maybeToMonoid (Just [1,2,3] :: Maybe [Int])
    [1,2,3]
    >>> maybeToMonoid (Nothing :: Maybe [Int])
    []

memptyIfFalse :: Monoid m => Bool -> m -> m #

Returns the given value in case of the given predicate is satisfied (is `True`). Otherwise, it returns `mempty`.

    >>> memptyIfFalse True (Just "Hello")
    Just "Hello"
    >>> memptyIfFalse False "Doesn't matter"
    ""

Since: 0.7.0.0

memptyIfTrue :: Monoid m => Bool -> m -> m #

Returns the given value in case of the given predicate is unsatisfied (is `False`). Otherwise, it returns `mempty`.

    >>> memptyIfTrue True (Just "Hello")
    Nothing
    >>> memptyIfTrue False "Does matter"
    "Does matter"

Since: 0.7.0.0