summaryrefslogtreecommitdiff
path: root/testsuite/tests/deriving/should_compile/T13998.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/deriving/should_compile/T13998.hs')
-rw-r--r--testsuite/tests/deriving/should_compile/T13998.hs43
1 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_compile/T13998.hs b/testsuite/tests/deriving/should_compile/T13998.hs
new file mode 100644
index 0000000000..565d4a35f7
--- /dev/null
+++ b/testsuite/tests/deriving/should_compile/T13998.hs
@@ -0,0 +1,43 @@
+{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE KindSignatures #-}
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE DefaultSignatures #-}
+{-# LANGUAGE GADTs #-}
+
+module T13998 where
+
+import Data.Type.Equality
+
+class EqForall f where
+ eqForall :: f a -> f a -> Bool
+
+class EqForall f => EqForallPoly f where
+ eqForallPoly :: f a -> f b -> Bool
+ default eqForallPoly :: TestEquality f => f a -> f b -> Bool
+ eqForallPoly = defaultEqForallPoly
+
+defaultEqForallPoly :: (TestEquality f, EqForall f) => f a -> f b -> Bool
+defaultEqForallPoly x y = case testEquality x y of
+ Nothing -> False
+ Just Refl -> eqForall x y
+
+
+data Atom = AtomInt | AtomString | AtomBool
+
+data Value (a :: Atom) where
+ ValueInt :: Int -> Value 'AtomInt
+ ValueString :: String -> Value 'AtomString
+ ValueBool :: Bool -> Value 'AtomBool
+
+instance TestEquality Value where
+ testEquality (ValueInt _) (ValueInt _) = Just Refl
+ testEquality (ValueString _) (ValueString _) = Just Refl
+ testEquality (ValueBool _) (ValueBool _) = Just Refl
+ testEquality _ _ = Nothing
+
+instance EqForall Value where
+ eqForall (ValueInt a) (ValueInt b) = a == b
+ eqForall (ValueString a) (ValueString b) = a == b
+ eqForall (ValueBool a) (ValueBool b) = a == b
+
+instance EqForallPoly Value