2{-# LANGUAGE TypeOperators #-}
3{-# LANGUAGE TypeFamilies #-}
6-- Data.Semigroup.Additive
8-- This module defines a class for commutative semigroups, until it is moved
10module Data.Semigroup.Additive
14import Data.Functor.Const (Const (..))
15import Data.Functor.Identity
17#if !MIN_VERSION_base(4,12,0)
18-- for :*: and :.: semigroup instances
21#if !MIN_VERSION_base(4,11,0)
22import Data.Semigroup (Semigroup (..))
26-- | An 'Additive' 'Semigroup' is one where (<>) is commutative
27class Semigroup q => Additive q where
29-- | Trivial additive semigroup.
32-- | Product additive semigroup.
33-- A Pair of additive semigroups gives rise to a additive semigroup
34instance (Additive a, Additive b) => Additive (a, b)
36-- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided.
37-- Base does not define Monoid (Compose f g a) so this is the best we can
38-- really do for functor composition.
39instance Additive (f (g a)) => Additive ((f :.: g) a)
41-- | Product of additive semigroups, Functor style.
42instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a)
44-- | Trivial additive semigroup, Functor style
45instance Additive (Proxy x)
47-- | Const lifts additive semigroups into a functor.
48instance Additive a => Additive (Const a x)
50-- | Identity lifts additive semigroups pointwise (at only one point)
51instance Additive a => Additive (Identity a)
53-- | Functions lift additive semigroups pointwise.
54instance Additive b => Additive (a -> b)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list