Copyright | (c) Justin Le 2018 |
---|---|
License | BSD-3 |
Maintainer | justin@jle.im |
Stability | unstable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Derived methods for Semigroup
and Monoid
, using Generics.OneLiner
and GHC.Generics.
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, which can one day be used
with DerivingVia syntax to derive instances automatically.
- newtype GMonoid a = GMonoid {
- getGMonoid :: a
- gSemigroup :: forall a. (ADTRecord a, Constraints a Semigroup) => a -> a -> a
- gMappend :: forall a. (ADTRecord a, Constraints a Monoid) => a -> a -> a
- gMempty :: forall a. (ADTRecord a, Constraints a Monoid) => 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.
Will one day be able to be used with DerivingVia syntax, to derive instances automatically.
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 # | |
(ADTRecord a, Constraints a Semigroup) => Semigroup (GMonoid a) Source # | |
(ADTRecord a, Constraints a Semigroup, Constraints a Monoid) => Monoid (GMonoid a) Source # | |
type Rep (GMonoid a) Source # | |
Generics-derived methods
Semigroup
gSemigroup :: forall a. (ADTRecord a, Constraints a Semigroup) => a -> a -> a Source #