blob: 2dc673f58b4d19d486d125e5ee4d3c04a3d96ffb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
|