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
Introduction
This module provides two main features:
GMonoid
, a generic version of theMonoid
type class, including instances of the types from Data.Monoid- Default generic definitions for the
Monoid
methodsmempty
andmappend
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
Methods
Generic mempty
Generic mappend
Generic mconcat
Instances
GMonoid All # | |
GMonoid Any # | |
GMonoid Ordering # | |
GMonoid () # | |
GMonoid a => GMonoid (Identity a) # | |
GMonoid (First a) # | |
GMonoid (Last a) # | |
GMonoid a => GMonoid (Down a) # | |
GMonoid m => GMonoid (WrappedMonoid m) # | |
GMonoid a => GMonoid (Dual a) # | |
GMonoid (Endo a) # | |
Num a => GMonoid (Product a) # | |
Num a => GMonoid (Sum a) # | |
(Generic a, GMonoid' (Rep a)) => GMonoid (Default a) # | |
GSemigroup a => GMonoid (Maybe a) # | |
GMonoid [a] # | |
GMonoid (Proxy s) # | |
(GMonoid a, GMonoid b) => GMonoid (a, b) # | |
GMonoid b => GMonoid (a -> b) # | |
GMonoid a => GMonoid (Const a b) # | |
Alternative f => GMonoid (Alt f a) # | |
(GMonoid a, GMonoid b, GMonoid c) => GMonoid (a, b, c) # | |
(GMonoid a, GMonoid b, GMonoid c, GMonoid d) => GMonoid (a, b, c, d) # | |
(GMonoid a, GMonoid b, GMonoid c, GMonoid d, GMonoid e) => GMonoid (a, b, c, d, e) # | |
(GMonoid a, GMonoid b, GMonoid c, GMonoid d, GMonoid e, GMonoid f) => GMonoid (a, b, c, d, e, f) # | |
(GMonoid a, GMonoid b, GMonoid c, GMonoid d, GMonoid e, GMonoid f, GMonoid g) => GMonoid (a, b, c, d, e, f, g) # | |
(GMonoid a, GMonoid b, GMonoid c, GMonoid d, GMonoid e, GMonoid f, GMonoid g, GMonoid h) => GMonoid (a, b, c, d, e, f, g, h) # | |
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 #
Instances
GMonoid' (U1 :: k -> Type) # | |
Defined in Generics.Deriving.Monoid.Internal | |
(GMonoid' f, GMonoid' h) => GMonoid' (f :*: h :: k -> Type) # | |
Defined in Generics.Deriving.Monoid.Internal | |
GMonoid a => GMonoid' (K1 i a :: k -> Type) # | |
Defined in Generics.Deriving.Monoid.Internal | |
GMonoid' f => GMonoid' (M1 i c f :: k -> Type) # | |
Defined in Generics.Deriving.Monoid.Internal |
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
Instances
Monoid' (U1 :: k -> Type) # | |
Defined in Generics.Deriving.Monoid.Internal | |
(Monoid' f, Monoid' h) => Monoid' (f :*: h :: k -> Type) # | |
Defined in Generics.Deriving.Monoid.Internal | |
Monoid a => Monoid' (K1 i a :: k -> Type) # | |
Defined in Generics.Deriving.Monoid.Internal | |
Monoid' f => Monoid' (M1 i c f :: k -> Type) # | |
Defined in Generics.Deriving.Monoid.Internal |
The Monoid module
This is exported for convenient access to the various wrapper types.