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

Safe HaskellSafe
LanguageHaskell2010

Data.Semigroup.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.

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