Copyright | (c) Justin Le 2021 |
---|---|
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.
Synopsis
- 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 | |
|
Instances
Functor GMonoid Source # | |
Foldable GMonoid Source # | |
Defined in Data.Monoid.OneLiner fold :: Monoid m => GMonoid m -> m # foldMap :: Monoid m => (a -> m) -> GMonoid a -> m # foldMap' :: Monoid m => (a -> m) -> GMonoid a -> m # foldr :: (a -> b -> b) -> b -> GMonoid a -> b # foldr' :: (a -> b -> b) -> b -> GMonoid a -> b # foldl :: (b -> a -> b) -> b -> GMonoid a -> b # foldl' :: (b -> a -> b) -> b -> GMonoid a -> b # foldr1 :: (a -> a -> a) -> GMonoid a -> a # foldl1 :: (a -> a -> a) -> GMonoid a -> a # elem :: Eq a => a -> GMonoid a -> Bool # maximum :: Ord a => GMonoid a -> a # minimum :: Ord a => GMonoid a -> a # | |
Traversable GMonoid Source # | |
Eq a => Eq (GMonoid a) Source # | |
Data a => Data (GMonoid a) Source # | |
Defined in Data.Monoid.OneLiner gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GMonoid a -> c (GMonoid a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (GMonoid a) # toConstr :: GMonoid a -> Constr # dataTypeOf :: GMonoid a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (GMonoid a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GMonoid a)) # gmapT :: (forall b. Data b => b -> b) -> GMonoid a -> GMonoid a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GMonoid a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GMonoid a -> r # gmapQ :: (forall d. Data d => d -> u) -> GMonoid a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> GMonoid a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a) # | |
Ord a => Ord (GMonoid a) Source # | |
Defined in Data.Monoid.OneLiner | |
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 # | |
Defined in Data.Monoid.OneLiner |
Generics-derived methods
Semigroup
gSemigroup :: forall a. (ADTRecord a, Constraints a Semigroup) => a -> a -> a Source #