@@ -53,11 +53,13 @@ instance (Ord k, Group q) => Group (MonoidalMap k q) where
5353
5454instance (Ord k, Additive q) => Additive (MonoidalMap k q)
5555
56+-- | Trivial group.
5657instance Group () where
5758 negateG _ = ()
5859 _ ~~ _ = ()
5960instance Additive ()
6061
62+-- | Product group. A Pair of groups gives rise to a group
6163instance (Group a, Group b) => Group (a, b) where
6264 negateG (a, b) = (negateG a, negateG b)
6365 (a, b) ~~ (c, d) = (a ~~ c, b ~~ d)
@@ -71,21 +73,26 @@ instance Group (f (g a)) => Group ((f :.: g) a) where
7173 Comp1 xs ~~ Comp1 ys = Comp1 (xs ~~ ys)
7274instance Additive (f (g a)) => Additive ((f :.: g) a)
7375
76+-- | Product of groups, Functor style.
7477instance (Group (f a), Group (g a)) => Group ((f :*: g) a) where
7578 negateG (a :*: b) = negateG a :*: negateG b
7679 (a :*: b) ~~ (c :*: d) = (a ~~ c :*: b ~~ d)
7780instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a)
7881
82+-- | Trivial group, Functor style
7983instance Group (Proxy x) where
8084 negateG _ = Proxy
8185 _ ~~ _ = Proxy
8286instance Additive (Proxy x)
8387
88+-- | Const lifts groups into a functor.
8489deriving instance Group a => Group (Const a x)
8590instance Additive a => Additive (Const a x)
91+-- | Ideitnty lifts groups pointwise (at only one point)
8692deriving instance Group a => Group (Identity a)
8793instance Additive a => Additive (Identity a)
8894
95+-- | Functions lift groups pointwise.
8996instance Group b => Group (a -> b) where
9097 negateG f = negateG . f
9198 (~~) = liftA2 (~~)