summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/indexed-types/should_compile/ColGivenCheck.hs
diff options
context:
space:
mode:
authorManuel M T Chakravarty <chak@cse.unsw.edu.au>2007-08-31 12:04:31 +0000
committerManuel M T Chakravarty <chak@cse.unsw.edu.au>2007-08-31 12:04:31 +0000
commit1c2badd480a7facf25067f17afc395e3284027dd (patch)
treedf857154f1df0a944b46ee3fe2fdbf0bb41f969c /testsuite/tests/ghc-regress/indexed-types/should_compile/ColGivenCheck.hs
parent186a2abe7b608dcb541165cda8ac594b13abf8e7 (diff)
downloadhaskell-1c2badd480a7facf25067f17afc395e3284027dd.tar.gz
Tom Schrijvers' type family tests
Diffstat (limited to 'testsuite/tests/ghc-regress/indexed-types/should_compile/ColGivenCheck.hs')
-rw-r--r--testsuite/tests/ghc-regress/indexed-types/should_compile/ColGivenCheck.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/testsuite/tests/ghc-regress/indexed-types/should_compile/ColGivenCheck.hs b/testsuite/tests/ghc-regress/indexed-types/should_compile/ColGivenCheck.hs
new file mode 100644
index 0000000000..288c6e0608
--- /dev/null
+++ b/testsuite/tests/ghc-regress/indexed-types/should_compile/ColGivenCheck.hs
@@ -0,0 +1,20 @@
+{-# 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)