@@ -53,11 +53,13 @@ instance (Ord k, Group q) => Group (MonoidalMap k q) where
53
53
54
54
instance (Ord k , Additive q ) => Additive (MonoidalMap k q )
55
55
56
+ -- | Trivial group.
56
57
instance Group () where
57
58
negateG _ = ()
58
59
_ ~~ _ = ()
59
60
instance Additive ()
60
61
62
+ -- | Product group. A Pair of groups gives rise to a group
61
63
instance (Group a , Group b ) => Group (a , b ) where
62
64
negateG (a, b) = (negateG a, negateG b)
63
65
(a, b) ~~ (c, d) = (a ~~ c, b ~~ d)
@@ -71,21 +73,26 @@ instance Group (f (g a)) => Group ((f :.: g) a) where
71
73
Comp1 xs ~~ Comp1 ys = Comp1 (xs ~~ ys)
72
74
instance Additive (f (g a )) => Additive ((f :.: g ) a )
73
75
76
+ -- | Product of groups, Functor style.
74
77
instance (Group (f a ), Group (g a )) => Group ((f :*: g ) a ) where
75
78
negateG (a :*: b) = negateG a :*: negateG b
76
79
(a :*: b) ~~ (c :*: d) = (a ~~ c :*: b ~~ d)
77
80
instance (Additive (f a ), Additive (g a )) => Additive ((f :*: g ) a )
78
81
82
+ -- | Trivial group, Functor style
79
83
instance Group (Proxy x ) where
80
84
negateG _ = Proxy
81
85
_ ~~ _ = Proxy
82
86
instance Additive (Proxy x )
83
87
88
+ -- | Const lifts groups into a functor.
84
89
deriving instance Group a => Group (Const a x )
85
90
instance Additive a => Additive (Const a x )
91
+ -- | Ideitnty lifts groups pointwise (at only one point)
86
92
deriving instance Group a => Group (Identity a )
87
93
instance Additive a => Additive (Identity a )
88
94
95
+ -- | Functions lift groups pointwise.
89
96
instance Group b => Group (a -> b ) where
90
97
negateG f = negateG . f
91
98
(~~) = liftA2 (~~)
0 commit comments