| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Generics.Deriving.Monoid
Synopsis
- class GSemigroup a => GMonoid a where
- gmemptydefault :: (Generic a, GMonoid' (Rep a)) => a
- gmappenddefault :: (Generic a, GMonoid' (Rep a)) => a -> a -> a
- class GSemigroup' f => GMonoid' f where
- memptydefault :: (Generic a, Monoid' (Rep a)) => a
- mappenddefault :: (Generic a, Monoid' (Rep a)) => a -> a -> a
- class Monoid' f where
- module Data.Monoid
Introduction
This module provides two main features:
GMonoid, a generic version of theMonoidtype class, including instances of the types from Data.Monoid- Default generic definitions for the
Monoidmethodsmemptyandmappend
The generic defaults only work for types without alternatives (i.e. they have only one constructor). We cannot in general know how to deal with different constructors.
GMonoid type class
class GSemigroup a => GMonoid a where #
Minimal complete definition
Nothing
Instances
Default definitions
GMonoid
gmemptydefault :: (Generic a, GMonoid' (Rep a)) => a #
gmappenddefault :: (Generic a, GMonoid' (Rep a)) => a -> a -> a #
Internal auxiliary class for GMonoid
class GSemigroup' f => GMonoid' f where #
Monoid
These functions can be used in a Monoid instance. For example:
-- LANGUAGE DeriveGeneric import Generics.Deriving.Base (Generic) import Generics.Deriving.Monoid data T a = C a (Maybe a) deriving Generic instance Monoid a => Monoid (T a) where mempty = memptydefault mappend = mappenddefault
memptydefault :: (Generic a, Monoid' (Rep a)) => a #
mappenddefault :: (Generic a, Monoid' (Rep a)) => a -> a -> a #
Internal auxiliary class for Monoid
The Monoid module
This is exported for convenient access to the various wrapper types.
module Data.Monoid
Orphan instances
| GSemigroup a => GMonoid (Maybe a) # | |
| GMonoid m => GMonoid (WrappedMonoid m) # | |
Methods gmempty :: WrappedMonoid m # gmappend :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m # gmconcat :: [WrappedMonoid m] -> WrappedMonoid m # | |