on develop help sign in
hide Group Ap instance on older GHCs; tidy up some instances.
commit96c446d8138157c842247885fd3e32aa35b287f5 authordan bornside <dan.bornside@gmail.com> dateTue 8 Oct 2019, 22:42 (7 years ago) parentf7da8e8
2 files changed+8−4
src/Reflex/Patch.hs+5−4 src/Reflex/Query/Class.hs+3
src/Reflex/Patch.hs+5−4
@@ -61,20 +61,19 @@ instance Additive ()
6161instance (Group a, Group b) => Group (a, b) where
6262 negateG (a, b) = (negateG a, negateG b)
6363 (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)
6565
6666-- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided.
6767-- Base does not define Monoid (Compose f g a) so this has no "home"
6868instance Group (f (g a)) => Group ((f :.: g) a) where
6969 negateG (Comp1 xs) = Comp1 (negateG xs)
7070 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)
7372
7473instance (Group (f a), Group (g a)) => Group ((f :*: g) a) where
7574 negateG (a :*: b) = negateG a :*: negateG b
7675 (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)
7877
7978instance Group (Proxy x) where
8079 negateG _ = Proxy
@@ -82,7 +81,9 @@ instance Group (Proxy x) where
8281instance Additive (Proxy x)
8382
8483deriving instance Group a => Group (Const a x)
84+instance Additive a => Additive (Const a x)
8585deriving instance Group a => Group (Identity a)
86+instance Additive a => Additive (Identity a)
8687
8788instance Group b => Group (a -> b) where
8889 negateG f = negateG . f
src/Reflex/Query/Class.hs+3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE DeriveDataTypeable #-}
23{-# LANGUAGE FlexibleContexts #-}
34{-# LANGUAGE FlexibleInstances #-}
@@ -68,11 +69,13 @@ instance Query Void where
6869 type QueryResult Void = ()
6970 crop = absurd
7071
72+#if MIN_VERSION_base(4,12,0)
7173-- | We can lift queries into monoidal containers.
7274-- But beware of Applicatives who's monoid is different from (pure mempty, liftA2 mappend)
7375instance (Query q, Applicative f) => Query (Ap f q) where
7476 type QueryResult (Ap f q) = Ap f (QueryResult q)
7577 crop = liftA2 crop
78+#endif
7679-- | QueryMorphism's must be group homomorphisms when acting on the query type
7780-- and compatible with the query relationship when acting on the query result.
7881data QueryMorphism q q' = QueryMorphism