generic-deriving-1.14.5: Generic programming library for generalised deriving.

Safe Haskell | Safe
Language | Haskell2010

Generics.Deriving.Semigroup

Contents

- Generic semigroup class
- Default definition
- Internal semigroup class
- Orphan instances

Synopsis

- class GSemigroup a where
  - gsappend :: a -> a -> a
  - gstimes :: Integral b => b -> a -> a
  - gsconcat :: NonEmpty a -> a
- gsappenddefault :: (Generic a, GSemigroup' (Rep a)) => a -> a -> a
- class GSemigroup' f where
  - gsappend' :: f x -> f x -> f x

# Generic semigroup class

class GSemigroup a where #

Minimal complete definition

Nothing

Methods

gsappend :: a -> a -> a infixr 6 #

default gsappend :: (Generic a, GSemigroup' (Rep a)) => a -> a -> a #

gstimes :: Integral b => b -> a -> a #

gsconcat :: NonEmpty a -> a #

Only available with `base-4.9` or later

#### Instances

Instances details

GSemigroup All # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: All -> All -> All # gstimes :: Integral b => b -> All -> All # gsconcat :: NonEmpty All -> All #
GSemigroup Any # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Any -> Any -> Any # gstimes :: Integral b => b -> Any -> Any # gsconcat :: NonEmpty Any -> Any #
GSemigroup Void # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Void -> Void -> Void # gstimes :: Integral b => b -> Void -> Void # gsconcat :: NonEmpty Void -> Void #
GSemigroup Ordering # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Ordering -> Ordering -> Ordering # gstimes :: Integral b => b -> Ordering -> Ordering # gsconcat :: NonEmpty Ordering -> Ordering #
GSemigroup () # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: () -> () -> () # gstimes :: Integral b => b -> () -> () # gsconcat :: NonEmpty () -> () #
GSemigroup a => GSemigroup (Identity a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Identity a -> Identity a -> Identity a # gstimes :: Integral b => b -> Identity a -> Identity a # gsconcat :: NonEmpty (Identity a) -> Identity a #
GSemigroup (First a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: First a -> First a -> First a # gstimes :: Integral b => b -> First a -> First a # gsconcat :: NonEmpty (First a) -> First a #
GSemigroup (Last a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Last a -> Last a -> Last a # gstimes :: Integral b => b -> Last a -> Last a # gsconcat :: NonEmpty (Last a) -> Last a #
GSemigroup a => GSemigroup (Down a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Down a -> Down a -> Down a # gstimes :: Integral b => b -> Down a -> Down a # gsconcat :: NonEmpty (Down a) -> Down a #
GSemigroup (First a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: First a -> First a -> First a # gstimes :: Integral b => b -> First a -> First a # gsconcat :: NonEmpty (First a) -> First a #
GSemigroup (Last a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Last a -> Last a -> Last a # gstimes :: Integral b => b -> Last a -> Last a # gsconcat :: NonEmpty (Last a) -> Last a #
Ord a => GSemigroup (Max a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Max a -> Max a -> Max a # gstimes :: Integral b => b -> Max a -> Max a # gsconcat :: NonEmpty (Max a) -> Max a #
Ord a => GSemigroup (Min a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Min a -> Min a -> Min a # gstimes :: Integral b => b -> Min a -> Min a # gsconcat :: NonEmpty (Min a) -> Min a #
GMonoid m => GSemigroup (WrappedMonoid m) # |
Instance details Defined in Generics.Deriving.Semigroup Methods gsappend :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m # gstimes :: Integral b => b -> WrappedMonoid m -> WrappedMonoid m # gsconcat :: NonEmpty (WrappedMonoid m) -> WrappedMonoid m #
GSemigroup a => GSemigroup (Dual a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Dual a -> Dual a -> Dual a # gstimes :: Integral b => b -> Dual a -> Dual a # gsconcat :: NonEmpty (Dual a) -> Dual a #
GSemigroup (Endo a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Endo a -> Endo a -> Endo a # gstimes :: Integral b => b -> Endo a -> Endo a # gsconcat :: NonEmpty (Endo a) -> Endo a #
Num a => GSemigroup (Product a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Product a -> Product a -> Product a # gstimes :: Integral b => b -> Product a -> Product a # gsconcat :: NonEmpty (Product a) -> Product a #
Num a => GSemigroup (Sum a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Sum a -> Sum a -> Sum a # gstimes :: Integral b => b -> Sum a -> Sum a # gsconcat :: NonEmpty (Sum a) -> Sum a #
GSemigroup (NonEmpty a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: NonEmpty a -> NonEmpty a -> NonEmpty a # gstimes :: Integral b => b -> NonEmpty a -> NonEmpty a # gsconcat :: NonEmpty (NonEmpty a) -> NonEmpty a #
(Generic a, GSemigroup' (Rep a)) => GSemigroup (Default a) # | Semigroups often have many sensible implementations of `<>` / `gsappend`, and therefore no sensible default. Indeed, there is no `GSemigroup'` instance for representations of sum types. In other cases, one may wish to use the existing wrapper newtypes in `base`, such as the following (using `First`):
    newtype FirstSemigroup = FirstSemigroup Bool
      deriving stock (Eq, Show)
      deriving (GSemigroup) via (First Bool)
Instance details Defined in Generics.Deriving.Default Methods gsappend :: Default a -> Default a -> Default a # gstimes :: Integral b => b -> Default a -> Default a # gsconcat :: NonEmpty (Default a) -> Default a #
GSemigroup a => GSemigroup (Maybe a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Maybe a -> Maybe a -> Maybe a # gstimes :: Integral b => b -> Maybe a -> Maybe a # gsconcat :: NonEmpty (Maybe a) -> Maybe a #
GSemigroup [a] # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: [a] -> [a] -> [a] # gstimes :: Integral b => b -> [a] -> [a] # gsconcat :: NonEmpty [a] -> [a] #
GSemigroup (Either a b) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Either a b -> Either a b -> Either a b # gstimes :: Integral b0 => b0 -> Either a b -> Either a b # gsconcat :: NonEmpty (Either a b) -> Either a b #
GSemigroup (Proxy s) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Proxy s -> Proxy s -> Proxy s # gstimes :: Integral b => b -> Proxy s -> Proxy s # gsconcat :: NonEmpty (Proxy s) -> Proxy s #
(GSemigroup a, GSemigroup b) => GSemigroup (a, b) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: (a, b) -> (a, b) -> (a, b) # gstimes :: Integral b0 => b0 -> (a, b) -> (a, b) # gsconcat :: NonEmpty (a, b) -> (a, b) #
GSemigroup b => GSemigroup (a -> b) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: (a -> b) -> (a -> b) -> a -> b # gstimes :: Integral b0 => b0 -> (a -> b) -> a -> b # gsconcat :: NonEmpty (a -> b) -> a -> b #
GSemigroup a => GSemigroup (Const a b) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Const a b -> Const a b -> Const a b # gstimes :: Integral b0 => b0 -> Const a b -> Const a b # gsconcat :: NonEmpty (Const a b) -> Const a b #
Alternative f => GSemigroup (Alt f a) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: Alt f a -> Alt f a -> Alt f a # gstimes :: Integral b => b -> Alt f a -> Alt f a # gsconcat :: NonEmpty (Alt f a) -> Alt f a #
(GSemigroup a, GSemigroup b, GSemigroup c) => GSemigroup (a, b, c) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: (a, b, c) -> (a, b, c) -> (a, b, c) # gstimes :: Integral b0 => b0 -> (a, b, c) -> (a, b, c) # gsconcat :: NonEmpty (a, b, c) -> (a, b, c) #
(GSemigroup a, GSemigroup b, GSemigroup c, GSemigroup d) => GSemigroup (a, b, c, d) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) # gstimes :: Integral b0 => b0 -> (a, b, c, d) -> (a, b, c, d) # gsconcat :: NonEmpty (a, b, c, d) -> (a, b, c, d) #
(GSemigroup a, GSemigroup b, GSemigroup c, GSemigroup d, GSemigroup e) => GSemigroup (a, b, c, d, e) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) # gstimes :: Integral b0 => b0 -> (a, b, c, d, e) -> (a, b, c, d, e) # gsconcat :: NonEmpty (a, b, c, d, e) -> (a, b, c, d, e) #
(GSemigroup a, GSemigroup b, GSemigroup c, GSemigroup d, GSemigroup e, GSemigroup f) => GSemigroup (a, b, c, d, e, f) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) # gstimes :: Integral b0 => b0 -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) # gsconcat :: NonEmpty (a, b, c, d, e, f) -> (a, b, c, d, e, f) #
(GSemigroup a, GSemigroup b, GSemigroup c, GSemigroup d, GSemigroup e, GSemigroup f, GSemigroup g) => GSemigroup (a, b, c, d, e, f, g) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) # gstimes :: Integral b0 => b0 -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) # gsconcat :: NonEmpty (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) #
(GSemigroup a, GSemigroup b, GSemigroup c, GSemigroup d, GSemigroup e, GSemigroup f, GSemigroup g, GSemigroup h) => GSemigroup (a, b, c, d, e, f, g, h) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) # gstimes :: Integral b0 => b0 -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) # gsconcat :: NonEmpty (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) #

# Default definition

gsappenddefault :: (Generic a, GSemigroup' (Rep a)) => a -> a -> a infixr 6 #

# Internal semigroup class

class GSemigroup' f where #

Methods

gsappend' :: f x -> f x -> f x infixr 6 #

#### Instances

Instances details

GSemigroup' (U1 :: k -> Type) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend' :: forall (x :: k0). U1 x -> U1 x -> U1 x #
(GSemigroup' f, GSemigroup' g) => GSemigroup' (f :*: g :: k -> Type) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend' :: forall (x :: k0). (f :*: g) x -> (f :*: g) x -> (f :*: g) x #
GSemigroup a => GSemigroup' (K1 i a :: k -> Type) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend' :: forall (x :: k0). K1 i a x -> K1 i a x -> K1 i a x #
GSemigroup' f => GSemigroup' (M1 i c f :: k -> Type) # |
Instance details Defined in Generics.Deriving.Semigroup.Internal Methods gsappend' :: forall (x :: k0). M1 i c f x -> M1 i c f x -> M1 i c f x #

# Orphan instances

GMonoid m => GSemigroup (WrappedMonoid m) # |
Instance details Methods gsappend :: WrappedMonoid m -> WrappedMonoid m -> WrappedMonoid m # gstimes :: Integral b => b -> WrappedMonoid m -> WrappedMonoid m # gsconcat :: NonEmpty (WrappedMonoid m) -> WrappedMonoid m #