| 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
type ListNonEmpty = NonEmpty Source #