generics-lift-0.1.0.0: GHC Generics for deriving numeric typeclasses, Monoid, and other similar classes.

Copyright(c) Justin Le 2018
LicenseBSD-3
Maintainerjustin@jle.im
Stabilityunstable
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Data.Monoid.Generics

Contents

Description

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.

Synopsis

Newtype wrapper

newtype GMonoid a Source #

If a is a data type with a single constructor whose fields are all instances of Semigroup, then GMonoid a has a Semigroup instance.

If a is a data type with a single constructor whose fields are all instances of Monoid, then GMonoid a has a Monoid instance.

Constructors

GMonoid 

Fields

Instances

Functor GMonoid Source # 

Methods

fmap :: (a -> b) -> GMonoid a -> GMonoid b #

(<$) :: a -> GMonoid b -> GMonoid a #

Foldable GMonoid Source # 

Methods

fold :: Monoid m => GMonoid m -> 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 #

toList :: GMonoid a -> [a] #

null :: GMonoid a -> Bool #

length :: GMonoid a -> Int #

elem :: Eq a => a -> GMonoid a -> Bool #

maximum :: Ord a => GMonoid a -> a #

minimum :: Ord a => GMonoid a -> a #

sum :: Num a => GMonoid a -> a #

product :: Num a => GMonoid a -> a #

Traversable GMonoid Source # 

Methods

traverse :: Applicative f => (a -> f b) -> GMonoid a -> f (GMonoid b) #

sequenceA :: Applicative f => GMonoid (f a) -> f (GMonoid a) #

mapM :: Monad m => (a -> m b) -> GMonoid a -> m (GMonoid b) #

sequence :: Monad m => GMonoid (m a) -> m (GMonoid a) #

Eq a => Eq (GMonoid a) Source # 

Methods

(==) :: GMonoid a -> GMonoid a -> Bool #

(/=) :: GMonoid a -> GMonoid a -> Bool #

Data a => Data (GMonoid a) Source # 

Methods

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 :: (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 # 

Methods

compare :: GMonoid a -> GMonoid a -> Ordering #

(<) :: GMonoid a -> GMonoid a -> Bool #

(<=) :: GMonoid a -> GMonoid a -> Bool #

(>) :: GMonoid a -> GMonoid a -> Bool #

(>=) :: GMonoid a -> GMonoid a -> Bool #

max :: GMonoid a -> GMonoid a -> GMonoid a #

min :: GMonoid a -> GMonoid a -> GMonoid a #

Read a => Read (GMonoid a) Source # 
Show a => Show (GMonoid a) Source # 

Methods

showsPrec :: Int -> GMonoid a -> ShowS #

show :: GMonoid a -> String #

showList :: [GMonoid a] -> ShowS #

Generic (GMonoid a) Source # 

Associated Types

type Rep (GMonoid a) :: * -> * #

Methods

from :: GMonoid a -> Rep (GMonoid a) x #

to :: Rep (GMonoid a) x -> GMonoid a #

GLift Semigroup (Rep (GMonoid a)) => Semigroup (GMonoid a) Source # 

Methods

(<>) :: GMonoid a -> GMonoid a -> GMonoid a #

sconcat :: NonEmpty (GMonoid a) -> GMonoid a #

stimes :: Integral b => b -> GMonoid a -> GMonoid a #

(GLift Semigroup (Rep (GMonoid a)), GLift Monoid (Rep (GMonoid a))) => Monoid (GMonoid a) Source # 

Methods

mempty :: GMonoid a #

mappend :: GMonoid a -> GMonoid a -> GMonoid a #

mconcat :: [GMonoid a] -> GMonoid a #

type Rep (GMonoid a) Source # 
type Rep (GMonoid a) = D1 * (MetaData "GMonoid" "Data.Monoid.Generics" "generics-lift-0.1.0.0-59raSs2kTdGFz343sZ52qP" True) (C1 * (MetaCons "GMonoid" PrefixI True) (S1 * (MetaSel (Just Symbol "getGMonoid") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * a)))

Generics-derived methods

Semigroup

genericSemigroup :: forall a. (Generic a, GLift Semigroup (Rep a)) => a -> a -> a Source #

Monoid

genericMappend :: forall a. (Generic a, GLift Monoid (Rep a)) => a -> a -> a Source #

genericMempty :: forall a. (Generic a, GLift Monoid (Rep a)) => a Source #