|
1 | | -{-# LANGUAGE CPP #-} |
2 | | -{-# LANGUAGE TypeOperators #-} |
3 | | -{-# LANGUAGE TypeFamilies #-} |
| 1 | +{-# LANGUAGE ConstraintKinds #-} |
4 | 2 |
|
5 | 3 | {-| |
6 | 4 | Description : A class for commutative semigroups |
7 | 5 | -} |
8 | 6 | module Data.Semigroup.Additive |
| 7 | + {-# DEPRECATED "Use 'Data.Semigroup.Commutative'" #-} |
9 | 8 | ( Additive |
10 | 9 | ) where |
11 | 10 |
|
12 | | -import Data.Functor.Const (Const (..)) |
13 | | -import Data.Functor.Identity |
14 | | -import Data.Proxy |
15 | | -#if !MIN_VERSION_base(4,12,0) |
16 | | --- for :*: and :.: semigroup instances |
17 | | -import Data.Orphans () |
18 | | -#endif |
19 | | -#if !MIN_VERSION_base(4,11,0) |
20 | | -import Data.Semigroup (Semigroup (..)) |
21 | | -#endif |
22 | | -import GHC.Generics |
| 11 | +import Data.Semigroup.Commutative |
23 | 12 |
|
24 | | --- | An 'Additive' 'Semigroup' is one where (<>) is commutative |
25 | | -class Semigroup q => Additive q where |
26 | | - |
27 | | --- | Trivial additive semigroup. |
28 | | -instance Additive () |
29 | | - |
30 | | --- | Product additive semigroup. |
31 | | --- A Pair of additive semigroups gives rise to a additive semigroup |
32 | | -instance (Additive a, Additive b) => Additive (a, b) |
33 | | - |
34 | | --- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided. |
35 | | --- Base does not define Monoid (Compose f g a) so this is the best we can |
36 | | --- really do for functor composition. |
37 | | -instance Additive (f (g a)) => Additive ((f :.: g) a) |
38 | | - |
39 | | --- | Product of additive semigroups, Functor style. |
40 | | -instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a) |
41 | | - |
42 | | --- | Trivial additive semigroup, Functor style |
43 | | -instance Additive (Proxy x) |
44 | | - |
45 | | --- | Const lifts additive semigroups into a functor. |
46 | | -instance Additive a => Additive (Const a x) |
47 | | - |
48 | | --- | Identity lifts additive semigroups pointwise (at only one point) |
49 | | -instance Additive a => Additive (Identity a) |
50 | | - |
51 | | --- | Functions lift additive semigroups pointwise. |
52 | | -instance Additive b => Additive (a -> b) |
| 13 | +{-# DEPRECATED Additive "Use 'Data.Semigroup.Commutative.Commutative'" #-} |
| 14 | +type Additive = Commutative |
0 commit comments