summaryrefslogtreecommitdiff
path: root/testsuite/tests/indexed-types/should_compile/ColGivenCheck2.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/indexed-types/should_compile/ColGivenCheck2.hs')
-rw-r--r--testsuite/tests/indexed-types/should_compile/ColGivenCheck2.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_compile/ColGivenCheck2.hs b/testsuite/tests/indexed-types/should_compile/ColGivenCheck2.hs
new file mode 100644
index 0000000000..2da7cb4117
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_compile/ColGivenCheck2.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE TypeFamilies #-}
+
+module ColInference where
+
+type family Elem c
+
+type instance Elem [e] = e
+
+class Col c where
+ isEmpty :: c -> Bool
+ add :: c -> Elem c -> c
+ headTail :: c -> (Elem c,c)
+
+-- addAll :: (Col c1, Col c2, Elem c1 ~ Elem c2) => c1 -> c2 -> c2
+-- addAll c1 c2
+-- | isEmpty c1
+-- = c2
+-- | otherwise
+-- = let (x,c1') = headTail c1
+-- in addAll c1' (add c2 x)
+
+sumCol :: (Col c, Elem c ~ Int) => c -> Int
+sumCol c | isEmpty c
+ = 0
+ | otherwise
+ = let (x,xs) = headTail c
+ in x + (sumCol xs)
+
+-- data CP :: * -> * where
+-- CP :: (Col c1, Col c2, Elem c1 ~ Elem c2, Elem c2 ~ Int) => (c1,c2) -> CP Char
+