summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-06-16 09:59:17 -0400
committerBen Gamari <ben@smart-cactus.org>2019-06-16 09:59:17 -0400
commit4dbf59d684d350f691f4d958085f23efe20b04d3 (patch)
tree88dd2d369c406a16ae233a20cbf006598c89910d
parent5da6c86f7b1304af3c314b3f9c0b007d6508c427 (diff)
downloadhaskell-wip/T16832.tar.gz
testsuite: Add test for #16832wip/T16832
-rw-r--r--testsuite/tests/typecheck/should_compile/T16832.hs40
-rw-r--r--testsuite/tests/typecheck/should_compile/T16832.script2
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
3 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T16832.hs b/testsuite/tests/typecheck/should_compile/T16832.hs
new file mode 100644
index 0000000000..8dcd40fe68
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T16832.hs
@@ -0,0 +1,40 @@
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE EmptyCase #-}
+{-# LANGUAGE UndecidableInstances #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE DefaultSignatures #-}
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE InstanceSigs #-}
+
+module WorkingGenerics where
+import GHC.Generics
+
+-- type family DiffT (p :: * -> *) :: * -> *
+
+data Void deriving(Generic)
+
+class Diff a where
+ type family Patch a :: *
+ type Patch a = GPatch (Rep a) a
+
+ diff :: a -> a -> Patch a
+ default diff :: (Generic a, GDiff (Rep a), Patch a ~ (GPatch (Rep a)) a) => a -> a -> Patch a
+ diff a a' = gdiff (from a) (from a')
+
+class GDiff (gen :: * -> *) where
+ type family GPatch gen :: * -> *
+ gdiff :: gen a -> gen a -> (GPatch gen) a
+
+instance GDiff V1 where
+ type GPatch V1 = V1
+ gdiff v1 _ = undefined
+
+-- meta info, we simply tunnel through
+instance (GDiff f) => GDiff (M1 i t f) where
+ type GPatch (M1 i t f) = M1 i t (GPatch f)
+ gdiff (M1 x) (M1 x') = M1 $ gdiff x x'
+
+
+instance Diff Void
+
diff --git a/testsuite/tests/typecheck/should_compile/T16832.script b/testsuite/tests/typecheck/should_compile/T16832.script
new file mode 100644
index 0000000000..8bafa2c71d
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T16832.script
@@ -0,0 +1,2 @@
+:load T16832
+
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index d0f54c0eca..8534a2c327 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -682,3 +682,4 @@ test('UnliftedNewtypesForall', normal, compile, [''])
test('UnlifNewUnify', normal, compile, [''])
test('UnliftedNewtypesLPFamily', normal, compile, [''])
test('UnliftedNewtypesDifficultUnification', normal, compile, [''])
+test('T16832', normal, ghci_script, [''])