Guest User

Untitled

a guest
Sep 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. {-# LANGUAGE StrictData, GADTs, DataKinds, KindSignatures #-}
  2. {-# LANGUAGE RankNTypes, StandaloneDeriving #-}
  3.  
  4. -- this gets suggested, but doesn't help
  5. -- {-# LANGUAGE UndecidableInstances #-}
  6.  
  7. -- this would help but isn't in until 8.6?
  8. -- {-# LANGUAGE QuantifiedConstraints #-}
  9.  
  10. import Data.Kind (Type)
  11.  
  12. data State
  13. = A
  14. | B
  15.  
  16. data Thing :: (State -> State -> Type -> Type) -> Type where
  17. IntThing :: f a b Int -> f b c Int -> Thing f
  18. DoubleThing :: f a b Double -> f b c Double -> Thing f
  19.  
  20. -- this doesn't work, but suggests -XUndecidableInstances, which also doesn't work
  21. -- deriving instance (Show (f a b Int), Show (f a b Double)) => Show (Thing f)
  22.  
  23. -- this also doesn't work, also suggests -XUndecidableInstances, which also doesn't work
  24. {-
  25. instance (Show (f a b Int), Show (f a b Double)) => Show (Thing f) where
  26. show (IntThing x y) = "IntThing " ++ show x ++ " " ++ show y
  27. show (DoubleThing x y) = "DoubleThing " ++ show x ++ " " ++ show y
  28. -}
  29.  
  30. -- doesn't work until 8.6 with -XQuantifiedConstraints?
  31. -- deriving instance (forall i j a . Show a => Show (f i j a)) => Show (Thing f)
Add Comment
Please, Sign In to add comment