diff options
Diffstat (limited to 'testsuite/tests/indexed-types/should_compile/Simple2.hs')
-rw-r--r-- | testsuite/tests/indexed-types/should_compile/Simple2.hs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_compile/Simple2.hs b/testsuite/tests/indexed-types/should_compile/Simple2.hs new file mode 100644 index 0000000000..2dc673f58b --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/Simple2.hs @@ -0,0 +1,41 @@ +{-# LANGUAGE TypeFamilies #-} + +module ShouldCompile where + +class C3 a where + data S3 a -- kind is optional + data S3n a -- kind is optional + foo3 :: a -> S3 a + foo3n :: a -> S3n a + bar3 :: S3 a -> a + bar3n :: S3n a -> a + +instance C3 Int where + data S3 Int = D3Int + newtype S3n Int = D3Intn () + foo3 _ = D3Int + foo3n _ = D3Intn () + bar3 D3Int = 1 + bar3n (D3Intn _) = 1 + +instance C3 Char where + data S3 Char = D3Char + foo3 _ = D3Char + bar3 D3Char = 'c' + +bar3' :: S3 Char -> Char +bar3' D3Char = 'a' + +instance C3 Bool where + data S3 Bool = S3_1 | S3_2 + foo3 False = S3_1 + foo3 True = S3_2 + bar3 S3_1 = False + bar3 S3_2 = True + +-- It's ok to omit ATs in instances, as it is ok to omit method definitions, +-- but similar to methods, "undefined" is the only inhabitant of these types, +-- then. +instance C3 Float where + foo3 1.0 = undefined + bar3 _ = 1.0 |