yukigo-ast 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/globals/generics.d.ts +740 -0
- package/dist/globals/generics.js +1128 -0
- package/dist/globals/helpers.d.ts +4 -0
- package/dist/globals/helpers.js +76 -0
- package/dist/globals/operators.d.ts +251 -0
- package/dist/globals/operators.js +336 -0
- package/dist/globals/patterns.d.ts +170 -0
- package/dist/globals/patterns.js +261 -0
- package/dist/globals/runtime.d.ts +22 -0
- package/dist/globals/runtime.js +6 -0
- package/dist/globals/types.d.ts +185 -0
- package/dist/globals/types.js +329 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/paradigms/data.d.ts +246 -0
- package/dist/paradigms/data.js +348 -0
- package/dist/paradigms/functional.d.ts +59 -0
- package/dist/paradigms/functional.js +103 -0
- package/dist/paradigms/imperative.d.ts +124 -0
- package/dist/paradigms/imperative.js +188 -0
- package/dist/paradigms/logic.d.ts +163 -0
- package/dist/paradigms/logic.js +240 -0
- package/dist/paradigms/object.d.ts +201 -0
- package/dist/paradigms/object.js +308 -0
- package/dist/visitor.d.ts +254 -0
- package/dist/visitor.js +426 -0
- package/package.json +25 -0
- package/src/globals/generics.ts +1421 -0
- package/src/globals/helpers.ts +107 -0
- package/src/globals/operators.ts +515 -0
- package/src/globals/patterns.ts +321 -0
- package/src/globals/runtime.ts +33 -0
- package/src/globals/types.ts +375 -0
- package/src/index.ts +12 -0
- package/src/paradigms/data.ts +393 -0
- package/src/paradigms/functional.ts +129 -0
- package/src/paradigms/imperative.ts +232 -0
- package/src/paradigms/logic.ts +314 -0
- package/src/paradigms/object.ts +366 -0
- package/src/visitor.ts +692 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Visitor } from "../visitor.js";
|
|
2
|
+
import { ASTNode, Primitive, SourceLocation, SymbolPrimitive } from "./generics.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a pattern that matches any value and binds it to a variable.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* map (\x -> x + 1)
|
|
8
|
+
* @category Patterns
|
|
9
|
+
*/
|
|
10
|
+
export declare class VariablePattern extends ASTNode {
|
|
11
|
+
/** @hidden */
|
|
12
|
+
name: SymbolPrimitive;
|
|
13
|
+
constructor(name: SymbolPrimitive, loc?: SourceLocation);
|
|
14
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
15
|
+
toJSON(): {
|
|
16
|
+
type: string;
|
|
17
|
+
name: {
|
|
18
|
+
type: string;
|
|
19
|
+
value: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Represents a pattern that matches an exact literal value.
|
|
25
|
+
* @category Patterns
|
|
26
|
+
*/
|
|
27
|
+
export declare class LiteralPattern extends ASTNode {
|
|
28
|
+
/** @hidden */
|
|
29
|
+
name: Primitive;
|
|
30
|
+
constructor(name: Primitive, loc?: SourceLocation);
|
|
31
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
32
|
+
toJSON(): {
|
|
33
|
+
type: string;
|
|
34
|
+
name: {
|
|
35
|
+
type: string;
|
|
36
|
+
value: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: string;
|
|
39
|
+
value: number;
|
|
40
|
+
} | {
|
|
41
|
+
type: string;
|
|
42
|
+
value: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
type: string;
|
|
45
|
+
value: import("./generics.js").Expression[];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Represents a pattern matching a function application or constructor with arguments.
|
|
51
|
+
* @category Patterns
|
|
52
|
+
*/
|
|
53
|
+
export declare class ApplicationPattern extends ASTNode {
|
|
54
|
+
/** @hidden */
|
|
55
|
+
args: Pattern[];
|
|
56
|
+
/** @hidden */
|
|
57
|
+
symbol: SymbolPrimitive;
|
|
58
|
+
constructor(symbol: SymbolPrimitive, args: Pattern[], loc?: SourceLocation);
|
|
59
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
60
|
+
toJSON(): any;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Represents a pattern matching a tuple structure.
|
|
64
|
+
* @category Patterns
|
|
65
|
+
*/
|
|
66
|
+
export declare class TuplePattern extends ASTNode {
|
|
67
|
+
/** @hidden */
|
|
68
|
+
elements: Pattern[];
|
|
69
|
+
constructor(elements: Pattern[], loc?: SourceLocation);
|
|
70
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
71
|
+
toJSON(): any;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Represents a pattern matching a list structure.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* sum (x:xs) = x + sum xs
|
|
78
|
+
* @category Patterns
|
|
79
|
+
*/
|
|
80
|
+
export declare class ListPattern extends ASTNode {
|
|
81
|
+
/** @hidden */
|
|
82
|
+
elements: Pattern[];
|
|
83
|
+
constructor(elements: Pattern[], loc?: SourceLocation);
|
|
84
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
85
|
+
toJSON(): any;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Represents a pattern matching a functor or compound term.
|
|
89
|
+
* @category Patterns
|
|
90
|
+
*/
|
|
91
|
+
export declare class FunctorPattern extends ASTNode {
|
|
92
|
+
/** @hidden */
|
|
93
|
+
args: Pattern[];
|
|
94
|
+
/** @hidden */
|
|
95
|
+
identifier: SymbolPrimitive;
|
|
96
|
+
constructor(identifier: SymbolPrimitive, args: Pattern[], loc?: SourceLocation);
|
|
97
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
98
|
+
toJSON(): any;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Represents an alias pattern (e.g., x@pat), binding the whole value to a name while matching inner patterns.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* f p@(x, y) = ...
|
|
105
|
+
* @category Patterns
|
|
106
|
+
*/
|
|
107
|
+
export declare class AsPattern extends ASTNode {
|
|
108
|
+
/** @hidden */
|
|
109
|
+
pattern: Pattern;
|
|
110
|
+
/** @hidden */
|
|
111
|
+
alias: VariablePattern | WildcardPattern;
|
|
112
|
+
constructor(alias: VariablePattern | WildcardPattern, pattern: Pattern, loc?: SourceLocation);
|
|
113
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
114
|
+
toJSON(): any;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Represents a wildcard pattern (_), which matches anything and discards the value.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* const _ x = x
|
|
121
|
+
* @category Patterns
|
|
122
|
+
*/
|
|
123
|
+
export declare class WildcardPattern extends ASTNode {
|
|
124
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
125
|
+
toJSON(): {
|
|
126
|
+
type: string;
|
|
127
|
+
name: string;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Represents a union of patterns, matching if any of the sub-patterns match.
|
|
132
|
+
* @category Patterns
|
|
133
|
+
*/
|
|
134
|
+
export declare class UnionPattern extends ASTNode {
|
|
135
|
+
/** @hidden */
|
|
136
|
+
patterns: Pattern[];
|
|
137
|
+
constructor(patterns: Pattern[], loc?: SourceLocation);
|
|
138
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
139
|
+
toJSON(): any;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Represents a pattern matching a specific data constructor.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* safeDiv (Just x) y = x / y
|
|
146
|
+
* @category Patterns
|
|
147
|
+
*/
|
|
148
|
+
export declare class ConstructorPattern extends ASTNode {
|
|
149
|
+
/** @hidden */
|
|
150
|
+
patterns: Pattern[];
|
|
151
|
+
/** @hidden */
|
|
152
|
+
constr: string;
|
|
153
|
+
constructor(constr: string, patterns: Pattern[], loc?: SourceLocation);
|
|
154
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
155
|
+
toJSON(): any;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Represents a pattern matching the head and tail of a list (x:xs).
|
|
159
|
+
* @category Patterns
|
|
160
|
+
*/
|
|
161
|
+
export declare class ConsPattern extends ASTNode {
|
|
162
|
+
/** @hidden */
|
|
163
|
+
tail: Pattern;
|
|
164
|
+
/** @hidden */
|
|
165
|
+
head: Pattern;
|
|
166
|
+
constructor(head: Pattern, tail: Pattern, loc?: SourceLocation);
|
|
167
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
168
|
+
toJSON(): any;
|
|
169
|
+
}
|
|
170
|
+
export type Pattern = VariablePattern | LiteralPattern | ApplicationPattern | TuplePattern | ListPattern | FunctorPattern | AsPattern | WildcardPattern | ConstructorPattern | UnionPattern | ConsPattern;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { ASTNode, } from "./generics.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a pattern that matches any value and binds it to a variable.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* map (\x -> x + 1)
|
|
7
|
+
* @category Patterns
|
|
8
|
+
*/
|
|
9
|
+
export class VariablePattern extends ASTNode {
|
|
10
|
+
/** @hidden */
|
|
11
|
+
name;
|
|
12
|
+
constructor(name, loc) {
|
|
13
|
+
super(loc);
|
|
14
|
+
this.name = name;
|
|
15
|
+
}
|
|
16
|
+
accept(visitor) {
|
|
17
|
+
return visitor.visitVariablePattern?.(this);
|
|
18
|
+
}
|
|
19
|
+
toJSON() {
|
|
20
|
+
return {
|
|
21
|
+
type: "VariablePattern",
|
|
22
|
+
name: this.name.toJSON(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Represents a pattern that matches an exact literal value.
|
|
28
|
+
* @category Patterns
|
|
29
|
+
*/
|
|
30
|
+
export class LiteralPattern extends ASTNode {
|
|
31
|
+
/** @hidden */
|
|
32
|
+
name;
|
|
33
|
+
constructor(name, loc) {
|
|
34
|
+
super(loc);
|
|
35
|
+
this.name = name;
|
|
36
|
+
}
|
|
37
|
+
accept(visitor) {
|
|
38
|
+
return visitor.visitLiteralPattern?.(this);
|
|
39
|
+
}
|
|
40
|
+
toJSON() {
|
|
41
|
+
return {
|
|
42
|
+
type: "LiteralPattern",
|
|
43
|
+
name: this.name.toJSON(),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Represents a pattern matching a function application or constructor with arguments.
|
|
49
|
+
* @category Patterns
|
|
50
|
+
*/
|
|
51
|
+
export class ApplicationPattern extends ASTNode {
|
|
52
|
+
/** @hidden */
|
|
53
|
+
args;
|
|
54
|
+
/** @hidden */
|
|
55
|
+
symbol;
|
|
56
|
+
constructor(symbol, args, loc) {
|
|
57
|
+
super(loc);
|
|
58
|
+
this.symbol = symbol;
|
|
59
|
+
this.args = args;
|
|
60
|
+
}
|
|
61
|
+
accept(visitor) {
|
|
62
|
+
return visitor.visitApplicationPattern?.(this);
|
|
63
|
+
}
|
|
64
|
+
toJSON() {
|
|
65
|
+
return {
|
|
66
|
+
type: "ApplicationPattern",
|
|
67
|
+
symbol: this.symbol.toJSON(),
|
|
68
|
+
args: this.args.map((arg) => arg.toJSON()),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Represents a pattern matching a tuple structure.
|
|
74
|
+
* @category Patterns
|
|
75
|
+
*/
|
|
76
|
+
export class TuplePattern extends ASTNode {
|
|
77
|
+
/** @hidden */
|
|
78
|
+
elements;
|
|
79
|
+
constructor(elements, loc) {
|
|
80
|
+
super(loc);
|
|
81
|
+
this.elements = elements;
|
|
82
|
+
}
|
|
83
|
+
accept(visitor) {
|
|
84
|
+
return visitor.visitTuplePattern?.(this);
|
|
85
|
+
}
|
|
86
|
+
toJSON() {
|
|
87
|
+
return {
|
|
88
|
+
type: "TuplePattern",
|
|
89
|
+
elements: this.elements.map((elem) => elem.toJSON()),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Represents a pattern matching a list structure.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* sum (x:xs) = x + sum xs
|
|
98
|
+
* @category Patterns
|
|
99
|
+
*/
|
|
100
|
+
export class ListPattern extends ASTNode {
|
|
101
|
+
/** @hidden */
|
|
102
|
+
elements;
|
|
103
|
+
constructor(elements, loc) {
|
|
104
|
+
super(loc);
|
|
105
|
+
this.elements = elements;
|
|
106
|
+
}
|
|
107
|
+
accept(visitor) {
|
|
108
|
+
return visitor.visitListPattern?.(this);
|
|
109
|
+
}
|
|
110
|
+
toJSON() {
|
|
111
|
+
return {
|
|
112
|
+
type: "ListPattern",
|
|
113
|
+
elements: this.elements.map((elem) => elem.toJSON()),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Represents a pattern matching a functor or compound term.
|
|
119
|
+
* @category Patterns
|
|
120
|
+
*/
|
|
121
|
+
export class FunctorPattern extends ASTNode {
|
|
122
|
+
/** @hidden */
|
|
123
|
+
args;
|
|
124
|
+
/** @hidden */
|
|
125
|
+
identifier;
|
|
126
|
+
constructor(identifier, args, loc) {
|
|
127
|
+
super(loc);
|
|
128
|
+
this.identifier = identifier;
|
|
129
|
+
this.args = args;
|
|
130
|
+
}
|
|
131
|
+
accept(visitor) {
|
|
132
|
+
return visitor.visitFunctorPattern?.(this);
|
|
133
|
+
}
|
|
134
|
+
toJSON() {
|
|
135
|
+
return {
|
|
136
|
+
type: "FunctorPattern",
|
|
137
|
+
identifier: this.identifier.toJSON(),
|
|
138
|
+
args: this.args.map((arg) => arg.toJSON()),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Represents an alias pattern (e.g., x@pat), binding the whole value to a name while matching inner patterns.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* f p@(x, y) = ...
|
|
147
|
+
* @category Patterns
|
|
148
|
+
*/
|
|
149
|
+
export class AsPattern extends ASTNode {
|
|
150
|
+
/** @hidden */
|
|
151
|
+
pattern;
|
|
152
|
+
/** @hidden */
|
|
153
|
+
alias;
|
|
154
|
+
constructor(alias, pattern, loc) {
|
|
155
|
+
super(loc);
|
|
156
|
+
this.alias = alias;
|
|
157
|
+
this.pattern = pattern;
|
|
158
|
+
}
|
|
159
|
+
accept(visitor) {
|
|
160
|
+
return visitor.visitAsPattern?.(this);
|
|
161
|
+
}
|
|
162
|
+
toJSON() {
|
|
163
|
+
return {
|
|
164
|
+
type: "AsPattern",
|
|
165
|
+
alias: this.alias.toJSON(),
|
|
166
|
+
pattern: this.pattern.toJSON(),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Represents a wildcard pattern (_), which matches anything and discards the value.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* const _ x = x
|
|
175
|
+
* @category Patterns
|
|
176
|
+
*/
|
|
177
|
+
export class WildcardPattern extends ASTNode {
|
|
178
|
+
accept(visitor) {
|
|
179
|
+
return visitor.visitWildcardPattern?.(this);
|
|
180
|
+
}
|
|
181
|
+
toJSON() {
|
|
182
|
+
return {
|
|
183
|
+
type: "WildcardPattern",
|
|
184
|
+
name: "_",
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Represents a union of patterns, matching if any of the sub-patterns match.
|
|
190
|
+
* @category Patterns
|
|
191
|
+
*/
|
|
192
|
+
export class UnionPattern extends ASTNode {
|
|
193
|
+
/** @hidden */
|
|
194
|
+
patterns;
|
|
195
|
+
constructor(patterns, loc) {
|
|
196
|
+
super(loc);
|
|
197
|
+
this.patterns = patterns;
|
|
198
|
+
}
|
|
199
|
+
accept(visitor) {
|
|
200
|
+
return visitor.visitUnionPattern?.(this);
|
|
201
|
+
}
|
|
202
|
+
toJSON() {
|
|
203
|
+
return {
|
|
204
|
+
type: "UnionPattern",
|
|
205
|
+
patterns: this.patterns.map((pattern) => pattern.toJSON()),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Represents a pattern matching a specific data constructor.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* safeDiv (Just x) y = x / y
|
|
214
|
+
* @category Patterns
|
|
215
|
+
*/
|
|
216
|
+
export class ConstructorPattern extends ASTNode {
|
|
217
|
+
/** @hidden */
|
|
218
|
+
patterns;
|
|
219
|
+
/** @hidden */
|
|
220
|
+
constr;
|
|
221
|
+
constructor(constr, patterns, loc) {
|
|
222
|
+
super(loc);
|
|
223
|
+
this.constr = constr;
|
|
224
|
+
this.patterns = patterns;
|
|
225
|
+
}
|
|
226
|
+
accept(visitor) {
|
|
227
|
+
return visitor.visitConstructorPattern?.(this);
|
|
228
|
+
}
|
|
229
|
+
toJSON() {
|
|
230
|
+
return {
|
|
231
|
+
type: "ConstructorPattern",
|
|
232
|
+
constructor: this.constr,
|
|
233
|
+
patterns: this.patterns.map((pattern) => pattern.toJSON()),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Represents a pattern matching the head and tail of a list (x:xs).
|
|
239
|
+
* @category Patterns
|
|
240
|
+
*/
|
|
241
|
+
export class ConsPattern extends ASTNode {
|
|
242
|
+
/** @hidden */
|
|
243
|
+
tail;
|
|
244
|
+
/** @hidden */
|
|
245
|
+
head;
|
|
246
|
+
constructor(head, tail, loc) {
|
|
247
|
+
super(loc);
|
|
248
|
+
this.head = head;
|
|
249
|
+
this.tail = tail;
|
|
250
|
+
}
|
|
251
|
+
accept(visitor) {
|
|
252
|
+
return visitor.visitConsPattern?.(this);
|
|
253
|
+
}
|
|
254
|
+
toJSON() {
|
|
255
|
+
return {
|
|
256
|
+
type: "ConsPattern",
|
|
257
|
+
head: this.head.toJSON(),
|
|
258
|
+
tail: this.tail.toJSON(),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GuardedBody, PrimitiveValue, UnguardedBody } from "./generics.js";
|
|
2
|
+
import { Pattern } from "./patterns.js";
|
|
3
|
+
export interface EquationRuntime {
|
|
4
|
+
patterns: Pattern[];
|
|
5
|
+
body: GuardedBody[] | UnguardedBody;
|
|
6
|
+
}
|
|
7
|
+
export type PrimitiveThunk = () => PrimitiveValue;
|
|
8
|
+
/**
|
|
9
|
+
* Runtime Function used in the Interpreter
|
|
10
|
+
*/
|
|
11
|
+
export interface RuntimeFunction {
|
|
12
|
+
arity: number;
|
|
13
|
+
identifier?: string;
|
|
14
|
+
equations: EquationRuntime[];
|
|
15
|
+
pendingArgs?: (PrimitiveValue | PrimitiveThunk)[];
|
|
16
|
+
closure?: Map<string, PrimitiveValue>[];
|
|
17
|
+
}
|
|
18
|
+
export interface LazyList {
|
|
19
|
+
readonly type: "LazyList";
|
|
20
|
+
readonly generator: () => Generator<PrimitiveValue, void, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export declare function isLazyList(prim: PrimitiveValue): prim is LazyList;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { Visitor } from "../visitor.js";
|
|
2
|
+
import { ASTNode, Expression, SourceLocation, SymbolPrimitive } from "./generics.js";
|
|
3
|
+
export type Type = SimpleType | TypeVar | ListType | TypeApplication | TupleType | ParameterizedType | ConstrainedType;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a basic named type (e.g., Int, Bool).
|
|
6
|
+
* @category Types
|
|
7
|
+
*/
|
|
8
|
+
export declare class SimpleType extends ASTNode {
|
|
9
|
+
/** @hidden */
|
|
10
|
+
constraints: Constraint[];
|
|
11
|
+
/** @hidden */
|
|
12
|
+
value: string;
|
|
13
|
+
constructor(value: string, constraints: Constraint[], loc?: SourceLocation);
|
|
14
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
15
|
+
toString(): string;
|
|
16
|
+
toJSON(): any;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Represents a type variable (e.g., 'a), used in polymorphic types.
|
|
20
|
+
* @category Types
|
|
21
|
+
*/
|
|
22
|
+
export declare class TypeVar extends ASTNode {
|
|
23
|
+
/** @hidden */
|
|
24
|
+
constraints: Constraint[];
|
|
25
|
+
/** @hidden */
|
|
26
|
+
value: string;
|
|
27
|
+
constructor(value: string, constraints: Constraint[], loc?: SourceLocation);
|
|
28
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
29
|
+
toString(): string;
|
|
30
|
+
toJSON(): {
|
|
31
|
+
type: string;
|
|
32
|
+
value: string;
|
|
33
|
+
constraints: any[];
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Represents the application of a type constructor to arguments (e.g., List Int).
|
|
38
|
+
* @category Types
|
|
39
|
+
*/
|
|
40
|
+
export declare class TypeApplication extends ASTNode {
|
|
41
|
+
/** @hidden */
|
|
42
|
+
argument: Type;
|
|
43
|
+
/** @hidden */
|
|
44
|
+
functionType: Type;
|
|
45
|
+
constructor(functionType: Type, argument: Type, loc?: SourceLocation);
|
|
46
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
47
|
+
toString(): string;
|
|
48
|
+
toJSON(): any;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Represents a list type (e.g., [Int]).
|
|
52
|
+
* @category Types
|
|
53
|
+
*/
|
|
54
|
+
export declare class ListType extends ASTNode {
|
|
55
|
+
/** @hidden */
|
|
56
|
+
constraints: Constraint[];
|
|
57
|
+
/** @hidden */
|
|
58
|
+
values: Type;
|
|
59
|
+
constructor(values: Type, constraints: Constraint[], loc?: SourceLocation);
|
|
60
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
61
|
+
toString(): string;
|
|
62
|
+
toJSON(): any;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Represents a tuple type (e.g., (Int, Bool)).
|
|
66
|
+
* @category Types
|
|
67
|
+
*/
|
|
68
|
+
export declare class TupleType extends ASTNode {
|
|
69
|
+
/** @hidden */
|
|
70
|
+
constraints: Constraint[];
|
|
71
|
+
/** @hidden */
|
|
72
|
+
values: Type[];
|
|
73
|
+
constructor(values: Type[], constraints: Constraint[], loc?: SourceLocation);
|
|
74
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
75
|
+
toString(): string;
|
|
76
|
+
toJSON(): any;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Represents a type constraint or class constraint (e.g., Eq a).
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* (Eq a) => a -> a -> Bool
|
|
83
|
+
* @category Types
|
|
84
|
+
*/
|
|
85
|
+
export declare class Constraint extends ASTNode {
|
|
86
|
+
/** @hidden */
|
|
87
|
+
parameters: Type[];
|
|
88
|
+
/** @hidden */
|
|
89
|
+
name: string;
|
|
90
|
+
constructor(name: string, parameters: Type[], loc?: SourceLocation);
|
|
91
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
92
|
+
toJSON(): any;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Represents a type that accepts type parameters.
|
|
96
|
+
* @category Types
|
|
97
|
+
*/
|
|
98
|
+
export declare class ParameterizedType extends ASTNode {
|
|
99
|
+
/** @hidden */
|
|
100
|
+
constraints: Constraint[];
|
|
101
|
+
/** @hidden */
|
|
102
|
+
returnType: Type;
|
|
103
|
+
/** @hidden */
|
|
104
|
+
inputs: Type[];
|
|
105
|
+
constructor(inputs: Type[], returnType: Type, constraints: Constraint[], loc?: SourceLocation);
|
|
106
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
107
|
+
toString(): any;
|
|
108
|
+
toJSON(): any;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Represents a type qualified by a context of constraints.
|
|
112
|
+
* @category Types
|
|
113
|
+
*/
|
|
114
|
+
export declare class ConstrainedType extends ASTNode {
|
|
115
|
+
/** @hidden */
|
|
116
|
+
constraints: Constraint[];
|
|
117
|
+
constructor(constraints: Constraint[], loc?: SourceLocation);
|
|
118
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
119
|
+
toJSON(): {
|
|
120
|
+
type: string;
|
|
121
|
+
constraints: any[];
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Represents a type alias definition, giving a new name to an existing type.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* type String = [Char]
|
|
129
|
+
* @category Types
|
|
130
|
+
*/
|
|
131
|
+
export declare class TypeAlias extends ASTNode {
|
|
132
|
+
/** @hidden */
|
|
133
|
+
value: Type;
|
|
134
|
+
/** @hidden */
|
|
135
|
+
variables: string[];
|
|
136
|
+
/** @hidden */
|
|
137
|
+
identifier: SymbolPrimitive;
|
|
138
|
+
constructor(identifier: SymbolPrimitive, variables: string[], value: Type, loc?: SourceLocation);
|
|
139
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
140
|
+
toJSON(): {
|
|
141
|
+
type: string;
|
|
142
|
+
identifier: {
|
|
143
|
+
type: string;
|
|
144
|
+
value: string;
|
|
145
|
+
};
|
|
146
|
+
variables: string[];
|
|
147
|
+
value: any;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Represents an explicit type signature declaration for a function or variable.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* add :: Int -> Int -> Int
|
|
155
|
+
* @category Types
|
|
156
|
+
*/
|
|
157
|
+
export declare class TypeSignature extends ASTNode {
|
|
158
|
+
/** @hidden */
|
|
159
|
+
body: Type;
|
|
160
|
+
/** @hidden */
|
|
161
|
+
identifier: SymbolPrimitive;
|
|
162
|
+
constructor(identifier: SymbolPrimitive, body: Type, loc?: SourceLocation);
|
|
163
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
164
|
+
toJSON(): {
|
|
165
|
+
type: string;
|
|
166
|
+
identifier: {
|
|
167
|
+
type: string;
|
|
168
|
+
value: string;
|
|
169
|
+
};
|
|
170
|
+
body: any;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Represents an explicit type casting or annotation expression.
|
|
175
|
+
* @category Types
|
|
176
|
+
*/
|
|
177
|
+
export declare class TypeCast extends ASTNode {
|
|
178
|
+
/** @hidden */
|
|
179
|
+
body: Type;
|
|
180
|
+
/** @hidden */
|
|
181
|
+
expression: Expression;
|
|
182
|
+
constructor(expression: Expression, body: Type, loc?: SourceLocation);
|
|
183
|
+
accept<R>(visitor: Visitor<R>): R;
|
|
184
|
+
toJSON(): any;
|
|
185
|
+
}
|