Copyright | (c) Justin Le 2018 |
---|---|
License | BSD-3 |
Maintainer | justin@jle.im |
Stability | unstable |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Derived methods for Semigroup and Monoid.
Can be used for any types (deriving Generic
) made with a single
constructor, where every field is an instance of Semigroup
(or
Monoid
, depending on the function).
Also includes a newtype wrapper that imbues any such data type with
instant Semigroup
and Monoid
instances.
See README for details on usage instructions and motivations.
- newtype GMonoid a = GMonoid {
- getGMonoid :: a
- genericSemigroup :: forall a. (Generic a, GLift Semigroup (Rep a)) => a -> a -> a
- genericMappend :: forall a. (Generic a, GLift Monoid (Rep a)) => a -> a -> a
- genericMempty :: forall a. (Generic a, GLift Monoid (Rep a)) => a
Newtype wrapper
If a
is a data type with a single constructor whose fields are all
instances of Semigroup
, then
has a GMonoid
aSemigroup
instance.
If a
is a data type with a single constructor whose fields are all
instances of Monoid
, then
has a GMonoid
aMonoid
instance.
GMonoid | |
|
Functor GMonoid Source # | |
Foldable GMonoid Source # | |
Traversable GMonoid Source # | |
Eq a => Eq (GMonoid a) Source # | |
Data a => Data (GMonoid a) Source # | |
Ord a => Ord (GMonoid a) Source # | |
Read a => Read (GMonoid a) Source # | |
Show a => Show (GMonoid a) Source # | |
Generic (GMonoid a) Source # | |
GLift Semigroup (Rep (GMonoid a)) => Semigroup (GMonoid a) Source # | |
(GLift Semigroup (Rep (GMonoid a)), GLift Monoid (Rep (GMonoid a))) => Monoid (GMonoid a) Source # | |
type Rep (GMonoid a) Source # | |