HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Modulelinear-base-0.8.1

Data.Monoid.Linear.Internal.Semigroup

  • 9 types
  • 1 class
  • 2 values
newtypenewtype First a
#

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

Examples
Example1 expression
First 0 <> First 10First {getFirst = 0}
Example1 expression
sconcat $ First 1 :| [ First n | n <- [2 ..] ]First {getFirst = 1}

Constructors

Instances38Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype Last a
#

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

Examples
Example1 expression
Last 0 <> Last 10Last {getLast = 10}
Example1 expression
sconcat $ Last 1 :| [ Last n | n <- [2..]]* Hangs forever *

Constructors

Instances38Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype All
#

Boolean monoid under conjunction (&&).

All x <> All y = All (x && y)
Examples
Example1 expression
All True <> mempty <> All False)All {getAll = False}
Example1 expression
mconcat (map (\x -> All (even x)) [2,4,6,7,8])All {getAll = False}
Example1 expression
All True <> memptyAll {getAll = True}

Constructors

Instances27Bounded, Eq, Data, Ord, Read, Show, …
newtypenewtype Any
#

Boolean monoid under disjunction (||).

Any x <> Any y = Any (x || y)
Examples
Example1 expression
Any True <> mempty <> Any FalseAny {getAny = True}
Example1 expression
mconcat (map (\x -> Any (even x)) [2,4,6,7,8])Any {getAny = True}
Example1 expression
Any False <> memptyAny {getAny = False}

Constructors

Instances27Bounded, Eq, Data, Ord, Read, Show, …
newtypenewtype Dual a
#

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

Dual a <> Dual b == Dual (b <> a)
Examples
Example1 expression
Dual "Hello" <> Dual "World"Dual {getDual = "WorldHello"}
Example1 expression
Dual (Dual "Hello") <> Dual (Dual "World")Dual {getDual = Dual {getDual = "HelloWorld"}}

Constructors

Instances39Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype Product a
#

Monoid under multiplication.

Product x <> Product y == Product (x * y)
Examples
Example1 expression
Product 3 <> Product 4 <> memptyProduct {getProduct = 12}
Example1 expression
mconcat [ Product n | n <- [2 .. 10]]Product {getProduct = 3628800}

Constructors

Instances42Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype Sum a
#

Monoid under addition.

Sum a <> Sum b = Sum (a + b)
Examples
Example1 expression
Sum 1 <> Sum 2 <> memptySum {getSum = 3}
Example1 expression
mconcat [ Sum n | n <- [3 .. 9]]Sum {getSum = 42}

Constructors

Instances42Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
newtypenewtype Endo a
#

Constructors

Instances4Monoid, Semigroup
  • Semigroup (Endo a)Defined in linear-base-0.8.1 · Data.Monoid.Linear.Internal.Semigroup
  • Monoid (Endo a)Defined in linear-base-0.8.1 · Data.Monoid.Linear.Internal.Monoid · orphan
  • Monoid (Endo a)Defined in linear-base-0.8.1 · Data.Monoid.Linear.Internal.Monoid
  • Semigroup (Endo a)Defined in linear-base-0.8.1 · Data.Monoid.Linear.Internal.Semigroup
classclass Semigroup a where
#

Methods

  • (<>) :: a %1 -> a %1 -> ainfixr 6
Instances41Semigroup, …