@@ -84,48 +84,22 @@ deriving instance Show k => Show (Const2 k v v')
84deriving instance Read k => Read (Const2 k v v)
84deriving instance Read k => Read (Const2 k v v)
86instance Show k => GShow (Const2 k v) where
86instance Show k => GShow (Const2 k v) where
87−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
88− gshowToShow (Const2 _) = id
90 gshowsPrec n x@(Const2 _) = showsPrec n x
87 gshowsPrec n x@(Const2 _) = showsPrec n x
93instance (Show k, Show (f v)) => ShowTag (Const2 k v) f where
89instance (Show k, Show (f v)) => ShowTag (Const2 k v) f where
94−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
95− showTagToShow (Const2 _) _ = id
97 showTaggedPrec (Const2 _) = showsPrec
90 showTaggedPrec (Const2 _) = showsPrec
100instance Eq k => GEq (Const2 k v) where
92instance Eq k => GEq (Const2 k v) where
101−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
103− geqUnify (Const2 _) (Const2 _) _ = id
105 geq (Const2 a) (Const2 b) =
93 geq (Const2 a) (Const2 b) =
106 if a == b
94 if a == b
107 then Just Refl
95 then Just Refl
108 else Nothing
96 else Nothing
111instance Ord k => GCompare (Const2 k v) where
98instance 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
116 gcompare (Const2 a) (Const2 b) = case compare a b of
99 gcompare (Const2 a) (Const2 b) = case compare a b of
117 LT -> GLT
100 LT -> GLT
118 EQ -> GEQ
101 EQ -> GEQ
119 GT -> GGT
102 GT -> GGT
122−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
123−instance {-# INCOHERENT #-} (Eq k, Eq v) => EqTag (Const2 k v) Identity where
124− eqTagToEq (Const2 _) _ = id
126−instance {-# INCOHERENT #-} Eq k => EqTag (Const2 k v) (Const2 k v) where
127− eqTagToEq (Const2 _) _ = id
130-- | Convert a 'DMap' to a regular 'Map'
104-- | Convert a 'DMap' to a regular 'Map'
131dmapToMap :: DMap (Const2 k v) Identity -> Map k v
105dmapToMap :: DMap (Const2 k v) Identity -> Map k v
@@ -175,17 +149,9 @@ deriving instance Show (f a) => Show (WrapArg g f (g' a))
175deriving instance Read (f a) => Read (WrapArg g f (g a))
149deriving instance Read (f a) => Read (WrapArg g f (g a))
177instance GEq f => GEq (WrapArg g f) where
151instance 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
182 geq (WrapArg a) (WrapArg b) = (\Refl -> Refl) <$> geq a b
152 geq (WrapArg a) (WrapArg b) = (\Refl -> Refl) <$> geq a b
185instance GCompare f => GCompare (WrapArg g f) where
154instance GCompare f => GCompare (WrapArg g f) where
186−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
187− gcompareToOrd (WrapArg f) = gcompareToOrd f
189 gcompare (WrapArg a) (WrapArg b) = case gcompare a b of
155 gcompare (WrapArg a) (WrapArg b) = case gcompare a b of
190 GLT -> GLT
156 GLT -> GLT
191 GEQ -> GEQ
157 GEQ -> GEQ
@@ -237,34 +203,13 @@ deriving instance Show (EitherTag l r a)
237deriving instance Eq (EitherTag l r a)
203deriving instance Eq (EitherTag l r a)
238deriving instance Ord (EitherTag l r a)
204deriving instance Ord (EitherTag l r a)
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
246−instance {-# INCOHERENT #-} (Eq (f l), Eq (f r)) => EqTag (EitherTag l r) f where
247− eqTagToEq e _ = case e of
252instance GEq (EitherTag l r) where
206instance GEq (EitherTag l r) where
253−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
255− geqUnify LeftTag LeftTag _ same = same
256− geqUnify RightTag RightTag _ same = same
257− geqUnify _ _ unknown _ = unknown
259 geq a b = case (a, b) of
207 geq a b = case (a, b) of
260 (LeftTag, LeftTag) -> Just Refl
208 (LeftTag, LeftTag) -> Just Refl
261 (RightTag, RightTag) -> Just Refl
209 (RightTag, RightTag) -> Just Refl
262 _ -> Nothing
210 _ -> Nothing
264instance GCompare (EitherTag l r) where
212instance GCompare (EitherTag l r) where
265−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
266− gcompareToOrd _ = id
268 gcompare a b = case (a, b) of
213 gcompare a b = case (a, b) of
269 (LeftTag, LeftTag) -> GEQ
214 (LeftTag, LeftTag) -> GEQ
270 (LeftTag, RightTag) -> GLT
215 (LeftTag, RightTag) -> GLT
@@ -272,24 +217,14 @@ instance GCompare (EitherTag l r) where
272 (RightTag, RightTag) -> GEQ
217 (RightTag, RightTag) -> GEQ
274instance GShow (EitherTag l r) where
219instance GShow (EitherTag l r) where
275−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
278 gshowsPrec _ a = case a of
220 gshowsPrec _ a = case a of
279 LeftTag -> showString "LeftTag"
221 LeftTag -> showString "LeftTag"
280 RightTag -> showString "RightTag"
222 RightTag -> showString "RightTag"
283instance (Show l, Show r) => ShowTag (EitherTag l r) Identity where
224instance (Show l, Show r) => ShowTag (EitherTag l r) Identity where
284−#ifdef EXPERIMENTAL_DEPENDENT_SUM_INSTANCES
285− showTagToShow t _ = case t of
289 showTaggedPrec t n (Identity a) = case t of
225 showTaggedPrec t n (Identity a) = case t of
290 LeftTag -> showsPrec n a
226 LeftTag -> showsPrec n a
291 RightTag -> showsPrec n a
227 RightTag -> showsPrec n a
294-- | Convert 'Either' to a 'DSum'. Inverse of 'dsumToEither'.
229-- | Convert 'Either' to a 'DSum'. Inverse of 'dsumToEither'.
295eitherToDSum :: Either a b -> DSum (EitherTag a b) Identity
230eitherToDSum :: Either a b -> DSum (EitherTag a b) Identity
@@ -319,13 +254,6 @@ newtype ComposeMaybe (f :: * -> *) (a :: *) =
320deriving instance Functor f => Functor (ComposeMaybe f)
255deriving instance Functor f => Functor (ComposeMaybe f)
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)
326−instance {-# INCOHERENT #-} GShow k => ShowTag k (ComposeMaybe k) where
327− showTagToShow k _ r = gshowToShow k (showTagToShow k (Proxy :: Proxy k) r)
329--------------------------------------------------------------------------------
257--------------------------------------------------------------------------------
330-- Deprecated functions
258-- Deprecated functions
331--------------------------------------------------------------------------------
259--------------------------------------------------------------------------------