on develop help sign in
Haddock those new instances
4eea268Dan Bornside
src/Reflex/Patch.hs+7
@@ -53,11 +53,13 @@ instance (Ord k, Group q) => Group (MonoidalMap k q) where
53
53
54instance (Ord k, Additive q) => Additive (MonoidalMap k q)
54instance (Ord k, Additive q) => Additive (MonoidalMap k q)
55
55
56+-- | Trivial group.
56instance Group () where
57instance Group () where
57 negateG _ = ()
58 negateG _ = ()
58 _ ~~ _ = ()
59 _ ~~ _ = ()
59instance Additive ()
60instance Additive ()
60
61
62+-- | Product group. A Pair of groups gives rise to a group
61instance (Group a, Group b) => Group (a, b) where
63instance (Group a, Group b) => Group (a, b) where
62 negateG (a, b) = (negateG a, negateG b)
64 negateG (a, b) = (negateG a, negateG b)
63 (a, b) ~~ (c, d) = (a ~~ c, b ~~ d)
65 (a, b) ~~ (c, d) = (a ~~ c, b ~~ d)
@@ -71,21 +73,26 @@ instance Group (f (g a)) => Group ((f :.: g) a) where
71 Comp1 xs ~~ Comp1 ys = Comp1 (xs ~~ ys)
73 Comp1 xs ~~ Comp1 ys = Comp1 (xs ~~ ys)
72instance Additive (f (g a)) => Additive ((f :.: g) a)
74instance Additive (f (g a)) => Additive ((f :.: g) a)
73
75
76+-- | Product of groups, Functor style.
74instance (Group (f a), Group (g a)) => Group ((f :*: g) a) where
77instance (Group (f a), Group (g a)) => Group ((f :*: g) a) where
75 negateG (a :*: b) = negateG a :*: negateG b
78 negateG (a :*: b) = negateG a :*: negateG b
76 (a :*: b) ~~ (c :*: d) = (a ~~ c :*: b ~~ d)
79 (a :*: b) ~~ (c :*: d) = (a ~~ c :*: b ~~ d)
77instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a)
80instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a)
78
81
82+-- | Trivial group, Functor style
79instance Group (Proxy x) where
83instance Group (Proxy x) where
80 negateG _ = Proxy
84 negateG _ = Proxy
81 _ ~~ _ = Proxy
85 _ ~~ _ = Proxy
82instance Additive (Proxy x)
86instance Additive (Proxy x)
83
87
88+-- | Const lifts groups into a functor.
84deriving instance Group a => Group (Const a x)
89deriving instance Group a => Group (Const a x)
85instance Additive a => Additive (Const a x)
90instance Additive a => Additive (Const a x)
91+-- | Ideitnty lifts groups pointwise (at only one point)
86deriving instance Group a => Group (Identity a)
92deriving instance Group a => Group (Identity a)
87instance Additive a => Additive (Identity a)
93instance Additive a => Additive (Identity a)
88
94
95+-- | Functions lift groups pointwise.
89instance Group b => Group (a -> b) where
96instance Group b => Group (a -> b) where
90 negateG f = negateG . f
97 negateG f = negateG . f
91 (~~) = liftA2 (~~)
98 (~~) = liftA2 (~~)
src/Reflex/Query/Class.hs+4
@@ -55,14 +55,18 @@ instance (Ord k, Query v) => Query (MonoidalMap k v) where
55 type QueryResult (MonoidalMap k v) = MonoidalMap k (QueryResult v)
55 type QueryResult (MonoidalMap k v) = MonoidalMap k (QueryResult v)
56 crop q r = MonoidalMap.intersectionWith (flip crop) r q
56 crop q r = MonoidalMap.intersectionWith (flip crop) r q
57
57
58+-- | the result of two queries is both results.
58instance (Query a, Query b) => Query (a, b) where
59instance (Query a, Query b) => Query (a, b) where
59 type QueryResult (a, b) = (QueryResult a, QueryResult b)
60 type QueryResult (a, b) = (QueryResult a, QueryResult b)
60 crop (x, x') (y, y') = (crop x y, crop x' y')
61 crop (x, x') (y, y') = (crop x y, crop x' y')
61
62
63+-- | Trivial queries have trivial results.
62instance Query () where
64instance Query () where
63 type QueryResult () = ()
65 type QueryResult () = ()
64 crop _ _ = ()
66 crop _ _ = ()
65
67
68+-- | The result of an absurd query is trivial; If you can ask the question, the
69+-- answer cannot tell you anything you didn't already know
66instance Query Void where
70instance Query Void where
67 type QueryResult Void = ()
71 type QueryResult Void = ()
68 crop = absurd
72 crop = absurd