Data.Monoid
- Package
- purescript-prelude
- Repository
- purescript/purescript-prelude
#Monoid Source
class (Semigroup m) <= Monoid m whereA Monoid is a Semigroup with a value mempty, which is both a
left and right unit for the associative operation <>:
forall x. mempty <> x = x <> mempty = x
Monoids are commonly used as the result of fold operations, where
<> is used to combine individual results, and mempty gives the result
of folding an empty collection of elements.
Members
mempty :: m
Instances
#power Source
power :: forall m. Monoid m => m -> Int -> mAppend a value to itself a certain number of times. For the
Multiplicative type, and for a non-negative power, this is the same as
normal number exponentiation.
If the second argument is negative this function will return mempty
(unlike normal number exponentiation). The Monoid constraint alone
is not enough to write a power function with the property that power x
n cancels with power x (-n), i.e. power x n <> power x (-n) = mempty.
For that, we would additionally need the ability to invert elements, i.e.
a Group.
#MonoidRecord Source
class (SemigroupRecord rowlist row subrow) <= MonoidRecord rowlist row subrow | rowlist -> row subrow whereA class for records where all fields have Monoid instances, used to
implement the Monoid instance for records.
Members
memptyRecord :: RLProxy rowlist -> Record subrow
Instances
MonoidRecord Nil row ()(IsSymbol key, Monoid focus, Cons key focus subrowTail subrow, MonoidRecord rowlistTail row subrowTail) => MonoidRecord (Cons key focus rowlistTail) row subrow
Re-exports from Data.Semigroup
#Semigroup Source
class Semigroup a The Semigroup type class identifies an associative operation on a type.
Instances are required to satisfy the following law:
- Associativity:
(x <> y) <> z = x <> (y <> z)
One example of a Semigroup is String, with (<>) defined as string
concatenation.
Instances
#SemigroupRecord Source
class SemigroupRecord rowlist row subrow | rowlist -> subrowA class for records where all fields have Semigroup instances, used to
implement the Semigroup instance for records.
Instances
SemigroupRecord Nil row ()(IsSymbol key, Cons key focus subrowTail subrow, SemigroupRecord rowlistTail row subrowTail, Semigroup focus) => SemigroupRecord (Cons key focus rowlistTail) row subrow
- Modules
- Control.
Applicative - Control.
Apply - Control.
Bind - Control.
Category - Control.
Monad - Control.
Semigroupoid - Data.
Boolean - Data.
BooleanAlgebra - Data.
Bounded - Data.
CommutativeRing - Data.
DivisionRing - Data.
Eq - Data.
EuclideanRing - Data.
Field - Data.
Function - Data.
Functor - Data.
HeytingAlgebra - Data.
Monoid - Data.
Monoid. Additive - Data.
Monoid. Conj - Data.
Monoid. Disj - Data.
Monoid. Dual - Data.
Monoid. Endo - Data.
Monoid. Multiplicative - Data.
NaturalTransformation - Data.
Ord - Data.
Ord. Unsafe - Data.
Ordering - Data.
Ring - Data.
Semigroup - Data.
Semigroup. First - Data.
Semigroup. Last - Data.
Semiring - Data.
Show - Data.
Symbol - Data.
Unit - Data.
Void - Prelude
- Record.
Unsafe - Type.
Data. Row - Type.
Data. RowList