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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
module CurryInterface.Types where
import Data.Function (on)
data Interface = Interface ModuleIdent [IImportDecl] [IDecl]
deriving (Eq, Read, Show)
data IImportDecl = IImportDecl ModuleIdent
deriving (Eq, Read, Show)
type Arity = Int
type Precedence = Int
data Infix
= InfixL
| InfixR
| Infix
deriving (Eq, Read, Show)
data IDecl
= IInfixDecl Infix Precedence QualIdent
| HidingDataDecl QualIdent (Maybe KindExpr) [Ident]
| IDataDecl QualIdent (Maybe KindExpr) [Ident] [ConstrDecl] [Ident]
| INewtypeDecl QualIdent (Maybe KindExpr) [Ident] NewConstrDecl [Ident]
| ITypeDecl QualIdent (Maybe KindExpr) [Ident] TypeExpr
| IFunctionDecl QualIdent (Maybe Ident) Arity QualTypeExpr
| HidingClassDecl Context QualIdent (Maybe KindExpr) [Ident] [FunDep]
| IClassDecl Context QualIdent (Maybe KindExpr) [Ident] [FunDep] [IMethodDecl] [Ident]
| IInstanceDecl Context QualIdent InstanceType [IMethodImpl] (Maybe ModuleIdent)
deriving (Eq, Read, Show)
data IMethodDecl = IMethodDecl Ident (Maybe Arity) QualTypeExpr
deriving (Eq, Read, Show)
type IMethodImpl = (Ident, Arity)
data KindExpr
= Star
| ConstraintKind
| ArrowKind KindExpr KindExpr
deriving (Eq, Read, Show)
data Ident = Ident
{ idName :: String
} deriving (Read, Show)
instance Eq Ident where
Ident m == Ident n = m == n
instance Ord Ident where
Ident m `compare` Ident n = m `compare` n
data ModuleIdent = ModuleIdent
{ midQualifiers :: [String]
} deriving (Read, Show)
instance Eq ModuleIdent where
(==) = (==) `on` midQualifiers
instance Ord ModuleIdent where
compare = compare `on` midQualifiers
data QualIdent = QualIdent
{ qidModule :: Maybe ModuleIdent
, qidIdent :: Ident
} deriving (Read, Show)
instance Eq QualIdent where
QualIdent m i == QualIdent n j = (m, i) == (n, j)
instance Ord QualIdent where
QualIdent m i `compare` QualIdent n j = (m, i) `compare` (n, j)
data ConstrDecl
= ConstrDecl Ident [TypeExpr]
| ConOpDecl TypeExpr Ident TypeExpr
| RecordDecl Ident [FieldDecl]
deriving (Eq, Read, Show)
data NewConstrDecl
= NewConstrDecl Ident TypeExpr
| NewRecordDecl Ident (Ident, TypeExpr)
deriving (Eq, Read, Show)
data FieldDecl = FieldDecl [Ident] TypeExpr
deriving (Eq, Read, Show)
data TypeExpr
= ConstructorType QualIdent
| ApplyType TypeExpr TypeExpr
| VariableType Ident
| TupleType [TypeExpr]
| ListType [TypeExpr]
| ArrowType TypeExpr TypeExpr
| ParenType TypeExpr
| ForallType [Ident] TypeExpr
deriving (Eq, Read, Show)
data QualTypeExpr = QualTypeExpr Context TypeExpr
deriving (Eq, Read, Show)
type Context = [Constraint]
data Constraint = Constraint QualIdent [TypeExpr]
deriving (Eq, Read, Show)
type InstanceType = [TypeExpr]
data FunDep = FunDep [Ident] [Ident]
deriving (Eq, Read, Show)
|