on develop help sign in
Get rid of experimental-dependent-sum-instances
commit66d4b183e9c740d715eb6c3f67232daa3a78939b authorRyan Trinkle <ryan.trinkle@gmail.com> dateFri 13 Jul 2018, 22:18 (8 years ago) parent9fcbf07
5 files changed−114
reflex.cabal−8 src/Data/Functor/Misc.hs−72 src/Reflex/Dynamic.hs−9 src/Reflex/Patch/DMapWithMove.hs−17 src/Reflex/Spider/Internal.hs−8
reflex.cabal−8
@@ -38,11 +38,6 @@ flag debug-trace-events
3838 default: False
3939 manual: True
4040
41−flag experimental-dependent-sum-instances
42− description: Use experimental incoherent instances for certain forked dependent-sum typeclasses
43− default: False
44− manual: True
45−
4641flag fast-weak
4742 description: Use the primitive implementation of FastWeak in GHCJS; note that this requires GHCJS to be built with FastWeak and FastWeakBag present in the RTS, which is not the default
4843 default: False
@@ -158,9 +153,6 @@ library
158153 if flag(expose-all-unfoldings)
159154 ghc-options: -fexpose-all-unfoldings
160155
161− if flag(experimental-dependent-sum-instances)
162− ghc-options: -DEXPERIMENTAL_DEPENDENT_SUM_INSTANCES
163−
164156 if flag(fast-weak) && impl(ghcjs)
165157 ghc-options: -DGHCJS_FAST_WEAK
166158
src/Data/Functor/Misc.hs−72
@@ -84,48 +84,22 @@ deriving instance Show k => Show (Const2 k v v')
8484deriving instance Read k => Read (Const2 k v v)
8585
8686instance Show k => GShow (Const2 k v) where
87−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
88− gshowToShow (Const2 _) = id
89−#else
9087 gshowsPrec n x@(Const2 _) = showsPrec n x
91−#endif
9288
9389instance (Show k, Show (f v)) => ShowTag (Const2 k v) f where
94−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
95− showTagToShow (Const2 _) _ = id
96−#else
9790 showTaggedPrec (Const2 _) = showsPrec
98−#endif
9991
10092instance Eq k => GEq (Const2 k v) where
101−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
102− geqToEq _ = id
103− geqUnify (Const2 _) (Const2 _) _ = id
104−#else
10593 geq (Const2 a) (Const2 b) =
10694 if a == b
10795 then Just Refl
10896 else Nothing
109−#endif
11097
11198instance Ord k => GCompare (Const2 k v) where
112−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
113− gcompareToOrd (Const2 _) = id
114− gcompare (Const2 a) (Const2 b) = strengthenOrdering $ compare a b
115−#else
11699 gcompare (Const2 a) (Const2 b) = case compare a b of
117100 LT -> GLT
118101 EQ -> GEQ
119102 GT -> GGT
120−#endif
121−
122−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
123−instance {-# INCOHERENT #-} (Eq k, Eq v) => EqTag (Const2 k v) Identity where
124− eqTagToEq (Const2 _) _ = id
125−
126−instance {-# INCOHERENT #-} Eq k => EqTag (Const2 k v) (Const2 k v) where
127− eqTagToEq (Const2 _) _ = id
128−#endif
129103
130104-- | Convert a 'DMap' to a regular 'Map'
131105dmapToMap :: DMap (Const2 k v) Identity -> Map k v
@@ -175,17 +149,9 @@ deriving instance Show (f a) => Show (WrapArg g f (g' a))
175149deriving instance Read (f a) => Read (WrapArg g f (g a))
176150
177151instance GEq f => GEq (WrapArg g f) where
178−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
179− geqToEq (WrapArg f) = geqToEq f
180− geqUnify (WrapArg a) (WrapArg b) = geqUnify a b
181−#else
182152 geq (WrapArg a) (WrapArg b) = (\Refl -> Refl) <$> geq a b
183−#endif
184153
185154instance GCompare f => GCompare (WrapArg g f) where
186−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
187− gcompareToOrd (WrapArg f) = gcompareToOrd f
188−#endif
189155 gcompare (WrapArg a) (WrapArg b) = case gcompare a b of
190156 GLT -> GLT
191157 GEQ -> GEQ
@@ -237,34 +203,13 @@ deriving instance Show (EitherTag l r a)
237203deriving instance Eq (EitherTag l r a)
238204deriving instance Ord (EitherTag l r a)
239205
240−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
241−instance {-# INCOHERENT #-} (Show (f l), Show (f r)) => ShowTag (EitherTag l r) f where
242− showTagToShow e _ = case e of
243− LeftTag -> id
244− RightTag -> id
245−
246−instance {-# INCOHERENT #-} (Eq (f l), Eq (f r)) => EqTag (EitherTag l r) f where
247− eqTagToEq e _ = case e of
248− LeftTag -> id
249− RightTag -> id
250−#endif
251−
252206instance GEq (EitherTag l r) where
253−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
254− geqToEq _ = id
255− geqUnify LeftTag LeftTag _ same = same
256− geqUnify RightTag RightTag _ same = same
257− geqUnify _ _ unknown _ = unknown
258−#endif
259207 geq a b = case (a, b) of
260208 (LeftTag, LeftTag) -> Just Refl
261209 (RightTag, RightTag) -> Just Refl
262210 _ -> Nothing
263211
264212instance GCompare (EitherTag l r) where
265−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
266− gcompareToOrd _ = id
267−#endif
268213 gcompare a b = case (a, b) of
269214 (LeftTag, LeftTag) -> GEQ
270215 (LeftTag, RightTag) -> GLT
@@ -272,24 +217,14 @@ instance GCompare (EitherTag l r) where
272217 (RightTag, RightTag) -> GEQ
273218
274219instance GShow (EitherTag l r) where
275−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
276− gshowToShow _ = id
277−#else
278220 gshowsPrec _ a = case a of
279221 LeftTag -> showString "LeftTag"
280222 RightTag -> showString "RightTag"
281−#endif
282223
283224instance (Show l, Show r) => ShowTag (EitherTag l r) Identity where
284−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
285− showTagToShow t _ = case t of
286− LeftTag -> id
287− RightTag -> id
288−#else
289225 showTaggedPrec t n (Identity a) = case t of
290226 LeftTag -> showsPrec n a
291227 RightTag -> showsPrec n a
292−#endif
293228
294229-- | Convert 'Either' to a 'DSum'. Inverse of 'dsumToEither'.
295230eitherToDSum :: Either a b -> DSum (EitherTag a b) Identity
@@ -319,13 +254,6 @@ newtype ComposeMaybe (f :: * -> *) (a :: *) =
319254
320255deriving instance Functor f => Functor (ComposeMaybe f)
321256
322−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
323−instance {-# INCOHERENT #-} EqTag f g => EqTag f (ComposeMaybe g) where
324− eqTagToEq f _ = eqTagToEq f (Proxy :: Proxy g)
325−
326−instance {-# INCOHERENT #-} GShow k => ShowTag k (ComposeMaybe k) where
327− showTagToShow k _ r = gshowToShow k (showTagToShow k (Proxy :: Proxy k) r)
328−#endif
329257--------------------------------------------------------------------------------
330258-- Deprecated functions
331259--------------------------------------------------------------------------------
src/Reflex/Dynamic.hs−9
@@ -428,21 +428,12 @@ data FHList f l where
428428 FHCons :: f e -> FHList f l -> FHList f (e ': l)
429429
430430instance GEq (HListPtr l) where
431−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
432− geqToEq _ = id
433− geqUnify HHeadPtr HHeadPtr _ same = same
434− geqUnify (HTailPtr a) (HTailPtr b) different same = geqUnify a b different same
435− geqUnify _ _ different _ = different
436−#endif
437431 HHeadPtr `geq` HHeadPtr = Just Refl
438432 HHeadPtr `geq` HTailPtr _ = Nothing
439433 HTailPtr _ `geq` HHeadPtr = Nothing
440434 HTailPtr a `geq` HTailPtr b = a `geq` b
441435
442436instance GCompare (HListPtr l) where -- Warning: This ordering can't change, dmapTo*HList will break
443−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
444− gcompareToOrd _ = id
445−#endif
446437 HHeadPtr `gcompare` HHeadPtr = GEQ
447438 HHeadPtr `gcompare` HTailPtr _ = GLT
448439 HTailPtr _ `gcompare` HHeadPtr = GGT
src/Reflex/Patch/DMapWithMove.hs−17
@@ -34,12 +34,6 @@ import Data.Some (Some)
3434import qualified Data.Some as Some
3535import Data.These
3636
37−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
38−import Data.Dependent.Sum (ShowTag (..))
39−import Data.GADT.Show (GShow (..))
40−import Data.Typeable (Proxy (..))
41−#endif
42−
4337-- | Like 'PatchMapWithMove', but for 'DMap'. Each key carries a 'NodeInfo' which describes how it will be changed by the patch and connects move sources and
4438-- destinations.
4539--
@@ -48,9 +42,6 @@ import Data.Typeable (Proxy (..))
4842-- * A key should not move to itself.
4943-- * A move should always be represented with both the destination key (as a 'From_Move') and the source key (as a @'ComposeMaybe' ('Just' destination)@)
5044newtype PatchDMapWithMove k v = PatchDMapWithMove (DMap k (NodeInfo k v))
51−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
52− deriving (Show)
53−#endif
5445
5546-- |Structure which represents what changes apply to a particular key. @_nodeInfo_from@ specifies what happens to this key, and in particular what other key
5647-- the current key is moving from, while @_nodeInfo_to@ specifies what key the current key is moving to if involved in a move.
@@ -62,14 +53,6 @@ data NodeInfo k v a = NodeInfo
6253 }
6354 deriving (Show)
6455
65−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
66−instance {-# INCOHERENT #-} (GShow k, ShowTag k v) => ShowTag k (NodeInfo k v) where
67− showTagToShow k _ r = gshowToShow k $ showTagToShow k (Proxy :: Proxy v) r
68−
69−instance {-# INCOHERENT #-} (GEq k, EqTag k v) => EqTag k (From k v) where
70− eqTagToEq k _ r = eqTagToEq k (Proxy :: Proxy v) (geqToEq k r)
71−#endif
72−
7356-- |Structure describing a particular change to a key, be it inserting a new key (@From_Insert@), updating an existing key (@From_Insert@ again), deleting a
7457-- key (@From_Delete@), or moving a key (@From_Move@).
7558data From (k :: a -> *) (v :: a -> *) :: a -> * where
src/Reflex/Spider/Internal.hs−8
@@ -784,17 +784,9 @@ instance Eq (SpiderTimelineEnv x) where
784784 _ == _ = True -- Since only one exists of each type
785785
786786instance GEq SpiderTimelineEnv where
787−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
788− geqToEq _ = id
789− geqUnify (a :: SpiderTimelineEnv a) (b :: SpiderTimelineEnv b) different same = if _spiderTimeline_lock a == _spiderTimeline_lock b
790− then case unsafeCoerce Refl :: a :~: b of
791− Refl -> same -- This unsafeCoerce is safe because the same SpiderTimelineEnv can't have two different 'x' arguments
792− else different
793−#else
794787 a `geq` b = if _spiderTimeline_lock a == _spiderTimeline_lock b
795788 then Just $ unsafeCoerce Refl -- This unsafeCoerce is safe because the same SpiderTimelineEnv can't have two different 'x' arguments
796789 else Nothing
797−#endif
798790
799791data EventEnv x
800792 = EventEnv { eventEnvAssignments :: !(IORef [SomeAssignment x]) -- Needed for Subscribe