monoid-0.1.9: Monoid type classes, designed in modular way, distinguish Monoid from Mempty and Semigroup. This design allows mempty operation don't bring Semigroups related constraints until (<>) is used.

Data.Monoids

Synopsis

# Documentation

type family Monoids lst :: Constraint where ... Source #

Equations

 Monoids '[] = () Monoids (a ': as) = (Monoid a, Monoids as)

class (Mempty a, Semigroup a) => Monoid a where Source #

Minimal complete definition

Nothing

Methods

mconcat :: [a] -> a Source #

Instances
 (Mempty a, Semigroup a) => Monoid a Source # Instance detailsDefined in Data.Monoids Methodsmconcat :: [a] -> a Source #

type family Semigroups lst :: Constraint where ... Source #

Equations

 Semigroups '[] = () Semigroups (a ': as) = (Semigroup a, Semigroups as)

type family Mempties lst :: Constraint where ... Source #

Equations

 Mempties '[] = () Mempties (a ': as) = (Mempty a, Mempties as)

class Mempty a where Source #

Minimal complete definition

Nothing

Methods

mempty :: a Source #

mempty :: Monoid a => a Source #

Instances
 Monoid a => Mempty a Source # Instance detailsDefined in Data.Monoids Methodsmempty :: a Source # Mempty [a] Source # Instance detailsDefined in Data.Monoids Methodsmempty :: [a] Source # Mempty (Maybe a) Source # Instance detailsDefined in Data.Monoids Methods Mempty (Map k a) Source # Instance detailsDefined in Data.Monoids Methodsmempty :: Map k a Source #

mappend :: Semigroup a => a -> a -> a Source #

mappendWith :: Semigroup a => a -> a -> a -> a Source #

mappendBetween :: Semigroup a => a -> a -> a -> a Source #

mconcat' :: (Foldable t, Monoid a) => t a -> a Source #

intersperse :: Foldable f => a -> f a -> [a] Source #

intercalate :: (Monoid a, Foldable f) => a -> f a -> a Source #

intercalate' :: Monoid a => a -> [a] -> a Source #

class Semigroup a where #

The class of semigroups (types with an associative binary operation).

Instances should satisfy the associativity law:

• x <> (y <> z) = (x <> y) <> z

Since: base-4.9.0.0

Minimal complete definition

(<>)

Methods

(<>) :: a -> a -> a infixr 6 #

An associative operation.

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
 Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodsstimes :: Integral b => b -> Ordering -> Ordering # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: () -> () -> () #sconcat :: NonEmpty () -> () #stimes :: Integral b => b -> () -> () # Semigroup [a] Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: [a] -> [a] -> [a] #sconcat :: NonEmpty [a] -> [a] #stimes :: Integral b => b -> [a] -> [a] # Semigroup a => Semigroup (Maybe a) Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: Maybe a -> Maybe a -> Maybe a #sconcat :: NonEmpty (Maybe a) -> Maybe a #stimes :: Integral b => b -> Maybe a -> Maybe a # Semigroup a => Semigroup (IO a) Since: base-4.10.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: IO a -> IO a -> IO a #sconcat :: NonEmpty (IO a) -> IO a #stimes :: Integral b => b -> IO a -> IO a # Ord a => Semigroup (Min a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup 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) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(<>) :: Max a -> Max a -> Max a #sconcat :: NonEmpty (Max a) -> Max a #stimes :: Integral b => b -> Max a -> Max a # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(<>) :: First a -> First a -> First a #sconcat :: NonEmpty (First a) -> First a #stimes :: Integral b => b -> First a -> First a # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup 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) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(<>) :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m #stimes :: Integral b => b -> WrappedMonoid m -> WrappedMonoid m # Semigroup a => Semigroup (Option a) Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methods(<>) :: Option a -> Option a -> Option a #sconcat :: NonEmpty (Option a) -> Option a #stimes :: Integral b => b -> Option a -> Option a # Since: base-4.9.0.0 Instance detailsDefined in Data.Monoid Methods(<>) :: First a -> First a -> First a #sconcat :: NonEmpty (First a) -> First a #stimes :: Integral b => b -> First a -> First a # Since: base-4.9.0.0 Instance detailsDefined in Data.Monoid Methods(<>) :: Last a -> Last a -> Last a #sconcat :: NonEmpty (Last a) -> Last a #stimes :: Integral b => b -> Last a -> Last a # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: NonEmpty a -> NonEmpty a -> NonEmpty a #sconcat :: NonEmpty (NonEmpty a) -> NonEmpty a #stimes :: Integral b => b -> NonEmpty a -> NonEmpty a # Semigroup b => Semigroup (a -> b) Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: (a -> b) -> (a -> b) -> a -> b #sconcat :: NonEmpty (a -> b) -> a -> b #stimes :: Integral b0 => b0 -> (a -> b) -> a -> b # Semigroup (Either a b) Since: base-4.9.0.0 Instance detailsDefined in Data.Either Methods(<>) :: Either a b -> Either a b -> Either a b #sconcat :: NonEmpty (Either a b) -> Either a b #stimes :: Integral b0 => b0 -> Either a b -> Either a b # (Semigroup a, Semigroup b) => Semigroup (a, b) Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: (a, b) -> (a, b) -> (a, b) #sconcat :: NonEmpty (a, b) -> (a, b) #stimes :: Integral b0 => b0 -> (a, b) -> (a, b) # Ord k => Semigroup (Map k v) Instance detailsDefined in Data.Map.Internal Methods(<>) :: Map k v -> Map k v -> Map k v #sconcat :: NonEmpty (Map k v) -> Map k v #stimes :: Integral b => b -> Map k v -> Map k v # (Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c) Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methods(<>) :: (a, b, c) -> (a, b, c) -> (a, b, c) #sconcat :: NonEmpty (a, b, c) -> (a, b, c) #stimes :: Integral b0 => b0 -> (a, b, c) -> (a, b, c) # (Applicative f, Semigroup a) => Semigroup (Ap f a) Since: base-4.12.0.0 Instance detailsDefined in Data.Monoid Methods(<>) :: Ap f a -> Ap f a -> Ap f a #sconcat :: NonEmpty (Ap f a) -> Ap f a #stimes :: Integral b => b -> Ap f a -> Ap f a # (Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d) Since: base-4.9.0.0 Instance detailsDefined in GHC.Base 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 b0 => b0 -> (a, b, c, d) -> (a, b, c, d) # (Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e) Since: base-4.9.0.0 Instance detailsDefined in GHC.Base 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 b0 => b0 -> (a, b, c, d, e) -> (a, b, c, d, e) #