generic-monoid-0.1.0.1: Derive monoid instances for product types.

Safe HaskellSafe
LanguageHaskell2010

Data.Monoid.Generic

Synopsis

Documentation

genericMappend :: (Generic a, MappendProduct (Rep a)) => a -> a -> a Source #

A generic <> function which works for product types where each contained type is itself a Semigroup. It simply calls <> for each field.

If you don't want to use the deriving via mechanism, use this function to implement the Semigroup type class.

genericMempty :: (Generic a, MemptyProduct (Rep a)) => a Source #

A generic mempty function which works for product types where each contained type is itself a Monoid. It simply calls mempty for each field.

If you don't want to use the deriving via mechanism, use this function to implement the Monoid type class.

newtype GenericSemigroup a Source #

A newtype which allows you to using the DerivingVia extension to reduce boilerplate.

data X = X [Int] String
  deriving (Generic, Show)
  deriving Semigroup via GenericSemigroup X

Constructors

GenericSemigroup a 
Instances
(Generic a, MappendProduct (Rep a)) => Semigroup (GenericSemigroup a) Source # 
Instance details

Defined in Data.Semigroup.Generic

newtype GenericMonoid a Source #

A newtype which allows you to using the DerivingVia extension to reduce boilerplate.

data X = X [Int] String
  deriving (Generic, Show)
  deriving Semigroup via GenericSemigroup X
  deriving Monoid    via GenericMonoid X

Note: Do NOT attempt to derive Semigroup via GenericMonoid. That will lead to infinite recursion.

Constructors

GenericMonoid a 
Instances
Show a => Show (GenericMonoid a) Source # 
Instance details

Defined in Data.Monoid.Generic

Semigroup a => Semigroup (GenericMonoid a) Source # 
Instance details

Defined in Data.Monoid.Generic

(Semigroup a, Generic a, MemptyProduct (Rep a)) => Monoid (GenericMonoid a) Source # 
Instance details

Defined in Data.Monoid.Generic