| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Basement.Compat.Semigroup
- class Semigroup a where
- type ListNonEmpty = NonEmpty
Documentation
The class of semigroups (types with an associative binary operation).
Since: 4.9.0.0
Methods
(<>) :: a -> a -> a infixr 6 #
An associative operation.
(a<>b)<>c = a<>(b<>c)
If a is also a Monoid we further require
(<>) =mappend
Reduce a non-empty list with <>
The default definition should be sufficient, but this can be overridden for efficiency.
stimes :: Integral b => b -> a -> a #
Repeat a value n times.
Given that this works on a Semigroup it is allowed to fail if
you request 0 or fewer repetitions, and the default definition
will do so.
By making this a member of the class, idempotent semigroups and monoids can
upgrade this to execute in O(1) by picking
stimes = stimesIdempotent or stimes = stimesIdempotentMonoid
respectively.
Instances
| Semigroup Ordering | |
| Semigroup () | |
| Semigroup Void | |
| Semigroup All | |
| Semigroup Any | |
| Semigroup [a] | |
| Semigroup a => Semigroup (Maybe a) | |
| Semigroup a => Semigroup (Identity a) | |
| Ord a => Semigroup (Min a) | |
| Ord a => Semigroup (Max a) | |
| Semigroup (First a) | |
| Semigroup (Last a) | |
| Monoid m => Semigroup (WrappedMonoid m) | |
| Semigroup a => Semigroup (Option a) | |
| Semigroup (NonEmpty a) | |
| Semigroup a => Semigroup (Dual a) | |
| Semigroup (Endo a) | |
| Num a => Semigroup (Sum a) | |
| Num a => Semigroup (Product a) | |
| Semigroup (First a) | |
| Semigroup (Last a) | |
| Semigroup b => Semigroup (a -> b) | |
| Semigroup (Either a b) | |
| (Semigroup a, Semigroup b) => Semigroup (a, b) | |
| Semigroup (Proxy k s) | |
| (Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c) | |
| Semigroup a => Semigroup (Const k a b) | |
| Alternative f => Semigroup (Alt * f a) | |
| (Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d) | |
| (Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e) | |
type ListNonEmpty = NonEmpty Source #