testsuite: Assert that testsuite ways are known
[ghc.git] / testsuite / tests / typecheck / should_compile / T16832.hs
1 {-# LANGUAGE TypeFamilies #-}
2 {-# LANGUAGE EmptyCase #-}
3 {-# LANGUAGE UndecidableInstances #-}
4 {-# LANGUAGE FlexibleInstances #-}
5 {-# LANGUAGE FlexibleContexts #-}
6 {-# LANGUAGE DefaultSignatures #-}
7 {-# LANGUAGE DeriveGeneric #-}
8 {-# LANGUAGE InstanceSigs #-}
9
10 module WorkingGenerics where
11 import GHC.Generics
12 import Data.Kind
13
14 -- type family DiffT (p :: Type -> Type) :: Type -> Type
15
16 data Void deriving(Generic)
17
18 class Diff a where
19 type family Patch a :: Type
20 type Patch a = GPatch (Rep a) a
21
22 diff :: a -> a -> Patch a
23 default diff :: (Generic a, GDiff (Rep a), Patch a ~ (GPatch (Rep a)) a) => a -> a -> Patch a
24 diff a a' = gdiff (from a) (from a')
25
26 class GDiff (gen :: Type -> Type) where
27 type family GPatch gen :: Type -> Type
28 gdiff :: gen a -> gen a -> (GPatch gen) a
29
30 instance GDiff V1 where
31 type GPatch V1 = V1
32 gdiff v1 _ = undefined
33
34 -- meta info, we simply tunnel through
35 instance (GDiff f) => GDiff (M1 i t f) where
36 type GPatch (M1 i t f) = M1 i t (GPatch f)
37 gdiff (M1 x) (M1 x') = M1 $ gdiff x x'
38
39
40 instance Diff Void
41