|
24 | 24 | {-# LANGUAGE UndecidableInstances #-}
|
25 | 25 |
|
26 | 26 | #if __GLASGOW_HASKELL__ >= 800
|
27 |
| -{-# LANGUAGE DeriveLift #-} |
| 27 | +{-# LANGUAGE DeriveLift #-} |
| 28 | +#endif |
| 29 | + |
| 30 | +#if __GLASGOW_HASKELL__ >= 806 |
| 31 | +{-# LANGUAGE QuantifiedConstraints #-} |
28 | 32 | #endif
|
29 | 33 |
|
30 | 34 | {-|
|
@@ -209,8 +213,21 @@ deriving instance Typeable FromGeneric1
|
209 | 213 | deriving instance ( Data (f a), Typeable f, Typeable a
|
210 | 214 | ) => Data (FromGeneric1 f (a :: *))
|
211 | 215 |
|
| 216 | +-- | /Since: 3.10/ |
| 217 | +instance (Generic1 f, GTextShowB (Rep1 f a)) => TextShow (FromGeneric1 f a) where |
| 218 | + showbPrec p = gShowbPrec p . from1 . fromGeneric1 |
| 219 | + |
212 | 220 | -- | /Since: 3.7.4/
|
213 |
| -instance (Generic1 f, GTextShowB1 (Rep1 f)) => TextShow1 (FromGeneric1 f) where |
| 221 | +instance ( Generic1 f, GTextShowB1 (Rep1 f) |
| 222 | +#if __GLASGOW_HASKELL__ >= 806 && __GLASGOW_HASKELL__ < 902 |
| 223 | + -- Unfortunately, the quantified superclass for GTextShowB1 doesn't |
| 224 | + -- work on pre-9.2 versions of GHC, perhaps due to |
| 225 | + -- https://gitlab.haskell.org/ghc/ghc/-/issues/14860#note_454218. |
| 226 | + -- Fortunately, we can make GHC come to its senses by using an |
| 227 | + -- equality constraint. |
| 228 | + , g ~ Rep1 f, forall a. TextShow a => GTextShowB (g a) |
| 229 | +#endif |
| 230 | + ) => TextShow1 (FromGeneric1 f) where |
214 | 231 | liftShowbPrec sp sl p = genericLiftShowbPrec sp sl p . fromGeneric1
|
215 | 232 |
|
216 | 233 | -- | A 'Generic' implementation of 'showt'.
|
@@ -367,6 +384,12 @@ one_hash = mempty; \
|
367 | 384 | two_hash = mempty;
|
368 | 385 | #endif
|
369 | 386 |
|
| 387 | +#if __GLASGOW_HASKELL__ >= 806 |
| 388 | +#define QUANTIFIED_SUPERCLASS(class_name,f) (forall a. TextShow a => class_name (f a)) => |
| 389 | +#else |
| 390 | +#define QUANTIFIED_SUPERCLASS(class_name,f) |
| 391 | +#endif |
| 392 | + |
370 | 393 | #define GTEXT_SHOW(text_type,show_funs,one_hash,two_hash,gtext_show,gtext_show1,gshow_prec,glift_show_prec,gtext_show_con,gtext_show_con1,gshow_prec_con,glift_show_prec_con,show_prec,lift_show_prec,show_space,show_paren,show_list,show_list_with,from_char,from_string,c1_show_prec,s1_show_prec,product_show_prec,u_char_show_prec,u_double_show_prec,u_float_show_prec,u_int_show_prec,u_word_show_prec) \
|
371 | 394 | {- | Class of generic representation types that can be converted to a \
|
372 | 395 | 'text_type'. \
|
@@ -463,7 +486,8 @@ be converted to a 'text_type'.
|
463 | 486 | \
|
464 | 487 | /Since: 3.10/ \
|
465 | 488 | -}; \
|
466 |
| -class gtext_show1 f where { \ |
| 489 | +class QUANTIFIED_SUPERCLASS(gtext_show,f) \ |
| 490 | + gtext_show1 f where { \ |
467 | 491 | ; glift_show_prec :: (Int -> a -> text_type) -> ([a] -> text_type) \
|
468 | 492 | -> Int -> f a -> text_type \
|
469 | 493 | }; \
|
@@ -492,7 +516,8 @@ the 'ConType' has been determined.
|
492 | 516 | \
|
493 | 517 | /Since: 3.10/ \
|
494 | 518 | -}; \
|
495 |
| -class gtext_show_con1 f where { \ |
| 519 | +class QUANTIFIED_SUPERCLASS(gtext_show_con,f) \ |
| 520 | + gtext_show_con1 f where { \ |
496 | 521 | ; glift_show_prec_con :: (Int -> a -> text_type) -> ([a] -> text_type) \
|
497 | 522 | -> ConType -> Int -> f a -> text_type \
|
498 | 523 | }; \
|
|
0 commit comments