| Copyright | (c) Justin Le 2018 |
|---|---|
| License | BSD-3 |
| Maintainer | justin@jle.im |
| Stability | unstable |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Monoid.OneLiner
Description
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.
Constructors
| GMonoid | |
Fields
| |
Instances
| Functor GMonoid # | |
| Foldable GMonoid # | |
| Traversable GMonoid # | |
| Eq a => Eq (GMonoid a) # | |
| Data a => Data (GMonoid a) # | |
| Ord a => Ord (GMonoid a) # | |
| Read a => Read (GMonoid a) # | |
| Show a => Show (GMonoid a) # | |
| Generic (GMonoid a) # | |
| (ADTRecord a, Constraints a Semigroup) => Semigroup (GMonoid a) # | |
| (ADTRecord a, Constraints a Semigroup, Constraints a Monoid) => Monoid (GMonoid a) # | |
| type Rep (GMonoid a) # | |
Generics-derived methods
Semigroup
gSemigroup :: forall a. (ADTRecord a, Constraints a Semigroup) => a -> a -> a #
Monoid
gMappend :: forall a. (ADTRecord a, Constraints a Monoid) => a -> a -> a #