on develop help sign in
hide Group Ap instance on older GHCs; tidy up some instances.
96c446ddan bornside
src/Reflex/Patch.hs+5−4
@@ -61,20 +61,19 @@ instance Additive ()
61instance (Group a, Group b) => Group (a, b) where
61instance (Group a, Group b) => Group (a, b) where
62 negateG (a, b) = (negateG a, negateG b)
62 negateG (a, b) = (negateG a, negateG b)
63 (a, b) ~~ (c, d) = (a ~~ c, b ~~ d)
63 (a, b) ~~ (c, d) = (a ~~ c, b ~~ d)
64−instance (Additive a, Additive b) => Additive (a, b) where
64+instance (Additive a, Additive b) => Additive (a, b)
65
65
66-- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided.
66-- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided.
67-- Base does not define Monoid (Compose f g a) so this has no "home"
67-- Base does not define Monoid (Compose f g a) so this has no "home"
68instance Group (f (g a)) => Group ((f :.: g) a) where
68instance Group (f (g a)) => Group ((f :.: g) a) where
69 negateG (Comp1 xs) = Comp1 (negateG xs)
69 negateG (Comp1 xs) = Comp1 (negateG xs)
70 Comp1 xs ~~ Comp1 ys = Comp1 (xs ~~ ys)
70 Comp1 xs ~~ Comp1 ys = Comp1 (xs ~~ ys)
71−
72−instance Additive (f (g a)) => Additive ((f :.: g) a) where
71+instance Additive (f (g a)) => Additive ((f :.: g) a)
73
72
74instance (Group (f a), Group (g a)) => Group ((f :*: g) a) where
73instance (Group (f a), Group (g a)) => Group ((f :*: g) a) where
75 negateG (a :*: b) = negateG a :*: negateG b
74 negateG (a :*: b) = negateG a :*: negateG b
76 (a :*: b) ~~ (c :*: d) = (a ~~ c :*: b ~~ d)
75 (a :*: b) ~~ (c :*: d) = (a ~~ c :*: b ~~ d)
77−instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a) where
76+instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a)
78
77
79instance Group (Proxy x) where
78instance Group (Proxy x) where
80 negateG _ = Proxy
79 negateG _ = Proxy
@@ -82,7 +81,9 @@ instance Group (Proxy x) where
82instance Additive (Proxy x)
81instance Additive (Proxy x)
83
82
84deriving instance Group a => Group (Const a x)
83deriving instance Group a => Group (Const a x)
84+instance Additive a => Additive (Const a x)
85deriving instance Group a => Group (Identity a)
85deriving instance Group a => Group (Identity a)
86+instance Additive a => Additive (Identity a)
86
87
87instance Group b => Group (a -> b) where
88instance Group b => Group (a -> b) where
88 negateG f = negateG . f
89 negateG f = negateG . f
src/Reflex/Query/Class.hs+3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
@@ -68,11 +69,13 @@ instance Query Void where
68 type QueryResult Void = ()
69 type QueryResult Void = ()
69 crop = absurd
70 crop = absurd
70
71
72+#if MIN_VERSION_base(4,12,0)
71-- | We can lift queries into monoidal containers.
73-- | We can lift queries into monoidal containers.
72-- But beware of Applicatives who's monoid is different from (pure mempty, liftA2 mappend)
74-- But beware of Applicatives who's monoid is different from (pure mempty, liftA2 mappend)
73instance (Query q, Applicative f) => Query (Ap f q) where
75instance (Query q, Applicative f) => Query (Ap f q) where
74 type QueryResult (Ap f q) = Ap f (QueryResult q)
76 type QueryResult (Ap f q) = Ap f (QueryResult q)
75 crop = liftA2 crop
77 crop = liftA2 crop
78+#endif
76-- | QueryMorphism's must be group homomorphisms when acting on the query type
79-- | QueryMorphism's must be group homomorphisms when acting on the query type
77-- and compatible with the query relationship when acting on the query result.
80-- and compatible with the query relationship when acting on the query result.
78data QueryMorphism q q' = QueryMorphism
81data QueryMorphism q q' = QueryMorphism