one-liner-instances-0.1.3.0: Generics-based implementations for common typeclasses
Copyright(c) Justin Le 2021
LicenseBSD-3
Maintainerjustin@jle.im
Stabilityunstable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

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.

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.

Will one day be able to be used with DerivingVia syntax, to derive instances automatically.

Constructors

GMonoid 

Fields

Instances

Instances details
Functor GMonoid Source # 
Instance details

Defined in Data.Monoid.OneLiner

Methods

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

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

Foldable GMonoid Source # 
Instance details

Defined in Data.Monoid.OneLiner

Methods

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 #

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 # 
Instance details

Defined in Data.Monoid.OneLiner

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 # 
Instance details

Defined in Data.Monoid.OneLiner

Methods

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

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

Data a => Data (GMonoid a) Source # 
Instance details

Defined in Data.Monoid.OneLiner

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 :: 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 # 
Instance details

Defined in Data.Monoid.OneLiner

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 # 
Instance details

Defined in Data.Monoid.OneLiner

Show a => Show (GMonoid a) Source # 
Instance details

Defined in Data.Monoid.OneLiner

Methods

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

show :: GMonoid a -> String #

showList :: [GMonoid a] -> ShowS #

Generic (GMonoid a) Source # 
Instance details

Defined in Data.Monoid.OneLiner

Associated Types

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

Methods

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

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

(ADTRecord a, Constraints a Semigroup) => Semigroup (GMonoid a) Source # 
Instance details

Defined in Data.Monoid.OneLiner

Methods

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

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

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

(ADTRecord a, Constraints a Semigroup, Constraints a Monoid) => Monoid (GMonoid a) Source # 
Instance details

Defined in Data.Monoid.OneLiner

Methods

mempty :: GMonoid a #

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

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

type Rep (GMonoid a) Source # 
Instance details

Defined in Data.Monoid.OneLiner

type Rep (GMonoid a) = D1 ('MetaData "GMonoid" "Data.Monoid.OneLiner" "one-liner-instances-0.1.3.0-KGYaKgOm9Pn8Wcz4AhCIIX" 'True) (C1 ('MetaCons "GMonoid" 'PrefixI 'True) (S1 ('MetaSel ('Just "getGMonoid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Generics-derived methods

Semigroup

gSemigroup :: forall a. (ADTRecord a, Constraints a Semigroup) => a -> a -> a Source #

Semigroup append (<>) implemented by calling <> on the components.

Monoid

gMappend :: forall a. (ADTRecord a, Constraints a Monoid) => a -> a -> a Source #

Monoid append (mappend) implemented by calling <> on the components.

gMempty :: forall a. (ADTRecord a, Constraints a Monoid) => a Source #

Monoid identity (mempty) implemented by using mempty for all of the components.