basement-0.0.3: Foundation scrap box of array & string

Basement.Compat.Semigroup

Synopsis

Documentation

class Semigroup a where #

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


sconcat :: NonEmpty a -> a #

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

 Methodsstimes :: Integral b => b -> Ordering -> Ordering # Methods(<>) :: () -> () -> () #sconcat :: NonEmpty () -> () #stimes :: Integral b => b -> () -> () # Methods(<>) :: Void -> Void -> Void #stimes :: Integral b => b -> Void -> Void # Methods(<>) :: All -> All -> All #stimes :: Integral b => b -> All -> All # Methods(<>) :: Any -> Any -> Any #stimes :: Integral b => b -> Any -> Any # Semigroup [a] Methods(<>) :: [a] -> [a] -> [a] #sconcat :: NonEmpty [a] -> [a] #stimes :: Integral b => b -> [a] -> [a] # Semigroup a => Semigroup (Maybe a) Methods(<>) :: Maybe a -> Maybe a -> Maybe a #sconcat :: NonEmpty (Maybe a) -> Maybe a #stimes :: Integral b => b -> Maybe a -> Maybe a # Semigroup a => Semigroup (Identity a) Methods(<>) :: Identity a -> Identity a -> Identity a #sconcat :: NonEmpty (Identity a) -> Identity a #stimes :: Integral b => b -> Identity a -> Identity a # Ord a => Semigroup (Min a) Methods(<>) :: Min a -> Min a -> Min a #sconcat :: NonEmpty (Min a) -> Min a #stimes :: Integral b => b -> Min a -> Min a # Ord a => Semigroup (Max a) Methods(<>) :: Max a -> Max a -> Max a #sconcat :: NonEmpty (Max a) -> Max a #stimes :: Integral b => b -> Max a -> Max a # Methods(<>) :: First a -> First a -> First a #sconcat :: NonEmpty (First a) -> First a #stimes :: Integral b => b -> First a -> First a # Methods(<>) :: Last a -> Last a -> Last a #sconcat :: NonEmpty (Last a) -> Last a #stimes :: Integral b => b -> Last a -> Last a # Monoid m => Semigroup (WrappedMonoid m) Methods(<>) :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m #stimes :: Integral b => b -> WrappedMonoid m -> WrappedMonoid m # Semigroup a => Semigroup (Option a) Methods(<>) :: Option a -> Option a -> Option a #sconcat :: NonEmpty (Option a) -> Option a #stimes :: Integral b => b -> Option a -> Option a # Methods(<>) :: NonEmpty a -> NonEmpty a -> NonEmpty a #sconcat :: NonEmpty (NonEmpty a) -> NonEmpty a #stimes :: Integral b => b -> NonEmpty a -> NonEmpty a # Semigroup a => Semigroup (Dual a) Methods(<>) :: Dual a -> Dual a -> Dual a #sconcat :: NonEmpty (Dual a) -> Dual a #stimes :: Integral b => b -> Dual a -> Dual a # Methods(<>) :: Endo a -> Endo a -> Endo a #sconcat :: NonEmpty (Endo a) -> Endo a #stimes :: Integral b => b -> Endo a -> Endo a # Num a => Semigroup (Sum a) Methods(<>) :: Sum a -> Sum a -> Sum a #sconcat :: NonEmpty (Sum a) -> Sum a #stimes :: Integral b => b -> Sum a -> Sum a # Num a => Semigroup (Product a) Methods(<>) :: Product a -> Product a -> Product a #sconcat :: NonEmpty (Product a) -> Product a #stimes :: Integral b => b -> Product a -> Product a # Methods(<>) :: First a -> First a -> First a #sconcat :: NonEmpty (First a) -> First a #stimes :: Integral b => b -> First a -> First a # Methods(<>) :: Last a -> Last a -> Last a #sconcat :: NonEmpty (Last a) -> Last a #stimes :: Integral b => b -> Last a -> Last a # Semigroup b => Semigroup (a -> b) Methods(<>) :: (a -> b) -> (a -> b) -> a -> b #sconcat :: NonEmpty (a -> b) -> a -> b #stimes :: Integral b => b -> (a -> b) -> a -> b # Semigroup (Either a b) Methods(<>) :: Either a b -> Either a b -> Either a b #sconcat :: NonEmpty (Either a b) -> Either a b #stimes :: Integral b => b -> Either a b -> Either a b # (Semigroup a, Semigroup b) => Semigroup (a, b) Methods(<>) :: (a, b) -> (a, b) -> (a, b) #sconcat :: NonEmpty (a, b) -> (a, b) #stimes :: Integral b => b -> (a, b) -> (a, b) # Semigroup (Proxy k s) Methods(<>) :: Proxy k s -> Proxy k s -> Proxy k s #sconcat :: NonEmpty (Proxy k s) -> Proxy k s #stimes :: Integral b => b -> Proxy k s -> Proxy k s # (Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c) Methods(<>) :: (a, b, c) -> (a, b, c) -> (a, b, c) #sconcat :: NonEmpty (a, b, c) -> (a, b, c) #stimes :: Integral b => b -> (a, b, c) -> (a, b, c) # Semigroup a => Semigroup (Const k a b) Methods(<>) :: Const k a b -> Const k a b -> Const k a b #sconcat :: NonEmpty (Const k a b) -> Const k a b #stimes :: Integral b => b -> Const k a b -> Const k a b # Alternative f => Semigroup (Alt * f a) Methods(<>) :: Alt * f a -> Alt * f a -> Alt * f a #sconcat :: NonEmpty (Alt * f a) -> Alt * f a #stimes :: Integral b => b -> Alt * f a -> Alt * f a # (Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d) Methods(<>) :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) #sconcat :: NonEmpty (a, b, c, d) -> (a, b, c, d) #stimes :: Integral b => b -> (a, b, c, d) -> (a, b, c, d) # (Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e) Methods(<>) :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) #sconcat :: NonEmpty (a, b, c, d, e) -> (a, b, c, d, e) #stimes :: Integral b => b -> (a, b, c, d, e) -> (a, b, c, d, e) #