HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulegeneric-monoid-0.1.0.1Haskell2010

Data.Monoid.Generic

  • 2 types
  • 2 values
valuegenericMappend :: (Generic a, MappendProduct (Rep a)) => a -> a -> a
#

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.

valuegenericMempty :: (Generic a, MemptyProduct (Rep a)) => a
#

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.

newtypenewtype GenericSemigroup a
#

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

Instances1Semigroup
newtypenewtype GenericMonoid a
#

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

Instances3Show, Semigroup, Monoid