Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
class Monoid a where
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following laws:
mappend mempty x = x
mappend x mempty = x
mappend x (mappend y z) = mappend (mappend x y) z
mconcat =
foldr
mappend mempty
The method names refer to the monoid of lists under concatenation, but there are many other instances.
Minimal complete definition: mempty
and mappend
.
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
.
mempty :: a
Identity of mappend
mappend :: a -> a -> a
An associative operation
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.
Monoid Ordering | |
Monoid () | |
Monoid All | |
Monoid Any | |
Monoid Builder | |
Monoid ByteString | |
Monoid ByteString | |
Monoid IntSet | |
Monoid Text | |
Monoid Text | |
Monoid More | |
Monoid RequestBody | |
Monoid CookieJar | |
Monoid Builder | |
Monoid CertificateStore | |
Monoid Filter | |
Monoid [a] | |
Monoid a => Monoid (Dual a) | |
Monoid (Endo a) | |
Num a => Monoid (Sum a) | |
Num a => Monoid (Product a) | |
Monoid (First a) | |
Monoid (Last a) | |
Monoid a => Monoid (Maybe a) | Lift a semigroup into |
Monoid (IntMap a) | |
Ord a => Monoid (Set a) | |
Monoid (Result a) | |
Monoid (Vector a) | |
Monoid (Parser a) | |
Storable a => Monoid (Vector a) | |
Prim a => Monoid (Vector a) | |
Unbox a => Monoid (Vector a) | |
(Hashable a, Eq a) => Monoid (HashSet a) | |
Monoid t => Monoid (Added t) | |
Monoid t => Monoid (Input t) | |
Monoid m => Monoid (WrappedMonoid m) | |
Semigroup a => Monoid (Option a) | |
(Ord a, Bounded a) => Monoid (Min a) | |
(Ord a, Bounded a) => Monoid (Max a) | |
Monoid b => Monoid (a -> b) | |
(Monoid a, Monoid b) => Monoid (a, b) | |
Monoid a => Monoid (Const a b) | |
Monoid (Proxy * s) | |
Ord k => Monoid (Map k v) | |
(Eq k, Hashable k) => Monoid (HashMap k v) | |
Monoid t => Monoid (Parser t a) | |
Typeable (* -> Constraint) Monoid | |
(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) | |
(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) | |
(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) |
class Monoid a => Seminearring a where Source
class ToJSON a where
Nothing
toJSON :: a -> Value