{-# LANGUAGE CPP                  #-}
{-# LANGUAGE DeriveDataTypeable   #-}
{-# LANGUAGE DeriveFoldable       #-}
{-# LANGUAGE DeriveFunctor        #-}
{-# LANGUAGE DeriveGeneric        #-}
{-# LANGUAGE DeriveTraversable    #-}
{-# LANGUAGE FlexibleContexts     #-}
{-# LANGUAGE ScopedTypeVariables  #-}
{-# LANGUAGE TypeApplications     #-}
{-# LANGUAGE UndecidableInstances #-}

-- |
-- Module      : Data.Monoid.OneLiner
-- Description : Derived methods for Semigroup and Monoid.
-- Copyright   : (c) Justin Le 2021
-- License     : BSD-3
-- Maintainer  : justin@jle.im
-- Stability   : unstable
-- Portability : portable
--
-- 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.
--

module Data.Monoid.OneLiner (
  -- * Newtype wrapper
    GMonoid(..)
  -- * Generics-derived methods
  -- ** Semigroup
  , gSemigroup
  -- ** Monoid
  , gMappend
  , gMempty
  ) where

import           Data.Coerce
import           Data.Data
import           GHC.Generics
import           Generics.OneLiner

#if !MIN_VERSION_base(4,11,0)
import           Data.Semigroup
#endif

-- | 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.
--
newtype GMonoid a = GMonoid { GMonoid a -> a
getGMonoid :: a }
  deriving (GMonoid a -> GMonoid a -> Bool
(GMonoid a -> GMonoid a -> Bool)
-> (GMonoid a -> GMonoid a -> Bool) -> Eq (GMonoid a)
forall a. Eq a => GMonoid a -> GMonoid a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GMonoid a -> GMonoid a -> Bool
$c/= :: forall a. Eq a => GMonoid a -> GMonoid a -> Bool
== :: GMonoid a -> GMonoid a -> Bool
$c== :: forall a. Eq a => GMonoid a -> GMonoid a -> Bool
Eq, Eq (GMonoid a)
Eq (GMonoid a)
-> (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)
-> (GMonoid a -> GMonoid a -> GMonoid a)
-> (GMonoid a -> GMonoid a -> GMonoid a)
-> Ord (GMonoid a)
GMonoid a -> GMonoid a -> Bool
GMonoid a -> GMonoid a -> Ordering
GMonoid a -> GMonoid a -> GMonoid a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (GMonoid a)
forall a. Ord a => GMonoid a -> GMonoid a -> Bool
forall a. Ord a => GMonoid a -> GMonoid a -> Ordering
forall a. Ord a => GMonoid a -> GMonoid a -> GMonoid a
min :: GMonoid a -> GMonoid a -> GMonoid a
$cmin :: forall a. Ord a => GMonoid a -> GMonoid a -> GMonoid a
max :: GMonoid a -> GMonoid a -> GMonoid a
$cmax :: forall a. Ord a => GMonoid a -> GMonoid a -> GMonoid a
>= :: GMonoid a -> GMonoid a -> Bool
$c>= :: forall a. Ord a => GMonoid a -> GMonoid a -> Bool
> :: GMonoid a -> GMonoid a -> Bool
$c> :: forall a. Ord a => GMonoid a -> GMonoid a -> Bool
<= :: GMonoid a -> GMonoid a -> Bool
$c<= :: forall a. Ord a => GMonoid a -> GMonoid a -> Bool
< :: GMonoid a -> GMonoid a -> Bool
$c< :: forall a. Ord a => GMonoid a -> GMonoid a -> Bool
compare :: GMonoid a -> GMonoid a -> Ordering
$ccompare :: forall a. Ord a => GMonoid a -> GMonoid a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (GMonoid a)
Ord, Int -> GMonoid a -> ShowS
[GMonoid a] -> ShowS
GMonoid a -> String
(Int -> GMonoid a -> ShowS)
-> (GMonoid a -> String)
-> ([GMonoid a] -> ShowS)
-> Show (GMonoid a)
forall a. Show a => Int -> GMonoid a -> ShowS
forall a. Show a => [GMonoid a] -> ShowS
forall a. Show a => GMonoid a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GMonoid a] -> ShowS
$cshowList :: forall a. Show a => [GMonoid a] -> ShowS
show :: GMonoid a -> String
$cshow :: forall a. Show a => GMonoid a -> String
showsPrec :: Int -> GMonoid a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> GMonoid a -> ShowS
Show, ReadPrec [GMonoid a]
ReadPrec (GMonoid a)
Int -> ReadS (GMonoid a)
ReadS [GMonoid a]
(Int -> ReadS (GMonoid a))
-> ReadS [GMonoid a]
-> ReadPrec (GMonoid a)
-> ReadPrec [GMonoid a]
-> Read (GMonoid a)
forall a. Read a => ReadPrec [GMonoid a]
forall a. Read a => ReadPrec (GMonoid a)
forall a. Read a => Int -> ReadS (GMonoid a)
forall a. Read a => ReadS [GMonoid a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GMonoid a]
$creadListPrec :: forall a. Read a => ReadPrec [GMonoid a]
readPrec :: ReadPrec (GMonoid a)
$creadPrec :: forall a. Read a => ReadPrec (GMonoid a)
readList :: ReadS [GMonoid a]
$creadList :: forall a. Read a => ReadS [GMonoid a]
readsPrec :: Int -> ReadS (GMonoid a)
$creadsPrec :: forall a. Read a => Int -> ReadS (GMonoid a)
Read, Typeable (GMonoid a)
DataType
Constr
Typeable (GMonoid a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> GMonoid a -> c (GMonoid a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (GMonoid a))
-> (GMonoid a -> Constr)
-> (GMonoid a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (GMonoid a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (GMonoid a)))
-> ((forall b. Data b => b -> b) -> GMonoid a -> GMonoid a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> GMonoid a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> GMonoid a -> r)
-> (forall u. (forall d. Data d => d -> u) -> GMonoid a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> GMonoid a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a))
-> Data (GMonoid a)
GMonoid a -> DataType
GMonoid a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (GMonoid a))
(forall b. Data b => b -> b) -> GMonoid a -> GMonoid a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GMonoid a -> c (GMonoid a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GMonoid a)
forall a. Data a => Typeable (GMonoid a)
forall a. Data a => GMonoid a -> DataType
forall a. Data a => GMonoid a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> GMonoid a -> GMonoid a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> GMonoid a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> GMonoid a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GMonoid a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GMonoid a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GMonoid a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GMonoid a -> c (GMonoid a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (GMonoid a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (GMonoid a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> GMonoid a -> u
forall u. (forall d. Data d => d -> u) -> GMonoid a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GMonoid a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GMonoid a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GMonoid a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GMonoid a -> c (GMonoid a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (GMonoid a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (GMonoid a))
$cGMonoid :: Constr
$tGMonoid :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a)
gmapMp :: (forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a)
gmapM :: (forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> GMonoid a -> m (GMonoid a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> GMonoid a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> GMonoid a -> u
gmapQ :: (forall d. Data d => d -> u) -> GMonoid a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> GMonoid a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GMonoid a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GMonoid a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GMonoid a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GMonoid a -> r
gmapT :: (forall b. Data b => b -> b) -> GMonoid a -> GMonoid a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> GMonoid a -> GMonoid a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (GMonoid a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (GMonoid a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (GMonoid a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (GMonoid a))
dataTypeOf :: GMonoid a -> DataType
$cdataTypeOf :: forall a. Data a => GMonoid a -> DataType
toConstr :: GMonoid a -> Constr
$ctoConstr :: forall a. Data a => GMonoid a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GMonoid a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GMonoid a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GMonoid a -> c (GMonoid a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GMonoid a -> c (GMonoid a)
$cp1Data :: forall a. Data a => Typeable (GMonoid a)
Data, (forall x. GMonoid a -> Rep (GMonoid a) x)
-> (forall x. Rep (GMonoid a) x -> GMonoid a)
-> Generic (GMonoid a)
forall x. Rep (GMonoid a) x -> GMonoid a
forall x. GMonoid a -> Rep (GMonoid a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (GMonoid a) x -> GMonoid a
forall a x. GMonoid a -> Rep (GMonoid a) x
$cto :: forall a x. Rep (GMonoid a) x -> GMonoid a
$cfrom :: forall a x. GMonoid a -> Rep (GMonoid a) x
Generic, a -> GMonoid b -> GMonoid a
(a -> b) -> GMonoid a -> GMonoid b
(forall a b. (a -> b) -> GMonoid a -> GMonoid b)
-> (forall a b. a -> GMonoid b -> GMonoid a) -> Functor GMonoid
forall a b. a -> GMonoid b -> GMonoid a
forall a b. (a -> b) -> GMonoid a -> GMonoid b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> GMonoid b -> GMonoid a
$c<$ :: forall a b. a -> GMonoid b -> GMonoid a
fmap :: (a -> b) -> GMonoid a -> GMonoid b
$cfmap :: forall a b. (a -> b) -> GMonoid a -> GMonoid b
Functor, GMonoid a -> Bool
(a -> m) -> GMonoid a -> m
(a -> b -> b) -> b -> GMonoid a -> b
(forall m. Monoid m => GMonoid m -> m)
-> (forall m a. Monoid m => (a -> m) -> GMonoid a -> m)
-> (forall m a. Monoid m => (a -> m) -> GMonoid a -> m)
-> (forall a b. (a -> b -> b) -> b -> GMonoid a -> b)
-> (forall a b. (a -> b -> b) -> b -> GMonoid a -> b)
-> (forall b a. (b -> a -> b) -> b -> GMonoid a -> b)
-> (forall b a. (b -> a -> b) -> b -> GMonoid a -> b)
-> (forall a. (a -> a -> a) -> GMonoid a -> a)
-> (forall a. (a -> a -> a) -> GMonoid a -> a)
-> (forall a. GMonoid a -> [a])
-> (forall a. GMonoid a -> Bool)
-> (forall a. GMonoid a -> Int)
-> (forall a. Eq a => a -> GMonoid a -> Bool)
-> (forall a. Ord a => GMonoid a -> a)
-> (forall a. Ord a => GMonoid a -> a)
-> (forall a. Num a => GMonoid a -> a)
-> (forall a. Num a => GMonoid a -> a)
-> Foldable GMonoid
forall a. Eq a => a -> GMonoid a -> Bool
forall a. Num a => GMonoid a -> a
forall a. Ord a => GMonoid a -> a
forall m. Monoid m => GMonoid m -> m
forall a. GMonoid a -> Bool
forall a. GMonoid a -> Int
forall a. GMonoid a -> [a]
forall a. (a -> a -> a) -> GMonoid a -> a
forall m a. Monoid m => (a -> m) -> GMonoid a -> m
forall b a. (b -> a -> b) -> b -> GMonoid a -> b
forall a b. (a -> b -> b) -> b -> GMonoid a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: GMonoid a -> a
$cproduct :: forall a. Num a => GMonoid a -> a
sum :: GMonoid a -> a
$csum :: forall a. Num a => GMonoid a -> a
minimum :: GMonoid a -> a
$cminimum :: forall a. Ord a => GMonoid a -> a
maximum :: GMonoid a -> a
$cmaximum :: forall a. Ord a => GMonoid a -> a
elem :: a -> GMonoid a -> Bool
$celem :: forall a. Eq a => a -> GMonoid a -> Bool
length :: GMonoid a -> Int
$clength :: forall a. GMonoid a -> Int
null :: GMonoid a -> Bool
$cnull :: forall a. GMonoid a -> Bool
toList :: GMonoid a -> [a]
$ctoList :: forall a. GMonoid a -> [a]
foldl1 :: (a -> a -> a) -> GMonoid a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> GMonoid a -> a
foldr1 :: (a -> a -> a) -> GMonoid a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> GMonoid a -> a
foldl' :: (b -> a -> b) -> b -> GMonoid a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> GMonoid a -> b
foldl :: (b -> a -> b) -> b -> GMonoid a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> GMonoid a -> b
foldr' :: (a -> b -> b) -> b -> GMonoid a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> GMonoid a -> b
foldr :: (a -> b -> b) -> b -> GMonoid a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> GMonoid a -> b
foldMap' :: (a -> m) -> GMonoid a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> GMonoid a -> m
foldMap :: (a -> m) -> GMonoid a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> GMonoid a -> m
fold :: GMonoid m -> m
$cfold :: forall m. Monoid m => GMonoid m -> m
Foldable, Functor GMonoid
Foldable GMonoid
Functor GMonoid
-> Foldable GMonoid
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> GMonoid a -> f (GMonoid b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    GMonoid (f a) -> f (GMonoid a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> GMonoid a -> m (GMonoid b))
-> (forall (m :: * -> *) a.
    Monad m =>
    GMonoid (m a) -> m (GMonoid a))
-> Traversable GMonoid
(a -> f b) -> GMonoid a -> f (GMonoid b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => GMonoid (m a) -> m (GMonoid a)
forall (f :: * -> *) a.
Applicative f =>
GMonoid (f a) -> f (GMonoid a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GMonoid a -> m (GMonoid b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GMonoid a -> f (GMonoid b)
sequence :: GMonoid (m a) -> m (GMonoid a)
$csequence :: forall (m :: * -> *) a. Monad m => GMonoid (m a) -> m (GMonoid a)
mapM :: (a -> m b) -> GMonoid a -> m (GMonoid b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GMonoid a -> m (GMonoid b)
sequenceA :: GMonoid (f a) -> f (GMonoid a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
GMonoid (f a) -> f (GMonoid a)
traverse :: (a -> f b) -> GMonoid a -> f (GMonoid b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GMonoid a -> f (GMonoid b)
$cp2Traversable :: Foldable GMonoid
$cp1Traversable :: Functor GMonoid
Traversable)

instance ( ADTRecord a
         , Constraints a Semigroup
         )
      => Semigroup (GMonoid a) where
    <> :: GMonoid a -> GMonoid a -> GMonoid a
(<>) = (a -> a -> a) -> GMonoid a -> GMonoid a -> GMonoid a
coerce ((ADTRecord a, Constraints a Semigroup) => a -> a -> a
forall a. (ADTRecord a, Constraints a Semigroup) => a -> a -> a
gSemigroup @a)
    {-# INLINE (<>) #-}

instance ( ADTRecord a
         , Constraints a Semigroup
         , Constraints a Monoid
         )
      => Monoid (GMonoid a) where
    mappend :: GMonoid a -> GMonoid a -> GMonoid a
mappend = (a -> a -> a) -> GMonoid a -> GMonoid a -> GMonoid a
coerce ((ADTRecord a, Constraints a Monoid) => a -> a -> a
forall a. (ADTRecord a, Constraints a Monoid) => a -> a -> a
gMappend @a)
    {-# INLINE mappend #-}
    mempty :: GMonoid a
mempty  = a -> GMonoid a
coerce ((ADTRecord a, Constraints a Monoid) => a
forall a. (ADTRecord a, Constraints a Monoid) => a
gMempty @a)
    {-# INLINE mempty #-}


-- | Semigroup append ('<>') implemented by calling '<>' on the components.
gSemigroup
    :: forall a. (ADTRecord a, Constraints a Semigroup)
    => a -> a -> a
gSemigroup :: a -> a -> a
gSemigroup = (forall s. Semigroup s => s -> s -> s) -> a -> a -> a
forall (c :: * -> Constraint) t.
(ADTRecord t, Constraints t c) =>
(forall s. c s => s -> s -> s) -> t -> t -> t
binaryOp @Semigroup forall s. Semigroup s => s -> s -> s
(<>)
{-# INLINE gSemigroup #-}

-- | Monoid append ('mappend') implemented by calling '<>' on the
-- components.
gMappend
    :: forall a. (ADTRecord a, Constraints a Monoid)
    => a -> a -> a
gMappend :: a -> a -> a
gMappend = (forall s. Monoid s => s -> s -> s) -> a -> a -> a
forall (c :: * -> Constraint) t.
(ADTRecord t, Constraints t c) =>
(forall s. c s => s -> s -> s) -> t -> t -> t
binaryOp @Monoid forall s. Monoid s => s -> s -> s
mappend
{-# INLINE gMappend #-}

-- | Monoid identity ('mempty') implemented by using 'mempty' for all of
-- the components.
gMempty
    :: forall a. (ADTRecord a, Constraints a Monoid)
    => a
gMempty :: a
gMempty = (forall s. Monoid s => s) -> a
forall (c :: * -> Constraint) t.
(ADTRecord t, Constraints t c) =>
(forall s. c s => s) -> t
nullaryOp @Monoid forall s. Monoid s => s
mempty
{-# INLINE gMempty #-}