yukigo-haskell-parser 0.1.0 → 0.1.2
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/.mocharc.json +3 -3
- package/CHANGELOG.md +6 -0
- package/README.md +10 -10
- package/dist/index.d.ts +13 -2
- package/dist/index.js +112 -32
- package/dist/index.js.map +1 -1
- package/dist/parser/grammar.js +220 -231
- package/dist/parser/grammar.js.map +1 -1
- package/dist/parser/lexer.d.ts +70 -15
- package/dist/parser/lexer.js +259 -50
- package/dist/parser/lexer.js.map +1 -1
- package/dist/prelude.d.ts +1 -1
- package/dist/prelude.js +280 -204
- package/dist/prelude.js.map +1 -1
- package/dist/typechecker/DeclarationCollector.d.ts +6 -1
- package/dist/typechecker/DeclarationCollector.js +39 -0
- package/dist/typechecker/DeclarationCollector.js.map +1 -1
- package/dist/typechecker/TypeBuilder.d.ts +1 -1
- package/dist/typechecker/TypeBuilder.js +6 -2
- package/dist/typechecker/TypeBuilder.js.map +1 -1
- package/dist/typechecker/checker.d.ts +15 -4
- package/dist/typechecker/checker.js +108 -25
- package/dist/typechecker/checker.js.map +1 -1
- package/dist/typechecker/core.d.ts +4 -0
- package/dist/typechecker/core.js +45 -19
- package/dist/typechecker/core.js.map +1 -1
- package/dist/typechecker/inference.d.ts +5 -1
- package/dist/typechecker/inference.js +95 -21
- package/dist/typechecker/inference.js.map +1 -1
- package/dist/utils/helpers.d.ts +1 -1
- package/dist/utils/helpers.js +1 -1
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/types.d.ts +1 -1
- package/dist/utils/types.js +7 -0
- package/dist/utils/types.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +192 -55
- package/src/parser/grammar.ne +519 -463
- package/src/parser/grammar.ts +230 -239
- package/src/parser/lexer.ts +353 -77
- package/src/prelude.ts +282 -206
- package/src/typechecker/DeclarationCollector.ts +157 -104
- package/src/typechecker/TypeBuilder.ts +150 -148
- package/src/typechecker/checker.ts +501 -395
- package/src/typechecker/core.ts +192 -162
- package/src/typechecker/inference.ts +1421 -1327
- package/src/utils/helpers.ts +29 -29
- package/src/utils/types.ts +63 -56
- package/tests/hspec.spec.ts +92 -0
- package/tests/lexer.spec.ts +175 -0
- package/tests/parser.spec.ts +829 -823
- package/tests/prelude.spec.ts +17 -22
- package/tests/typechecker.spec.ts +327 -310
- package/tsconfig.json +26 -17
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/parser/layoutPreprocessor.d.ts +0 -1
- package/dist/parser/layoutPreprocessor.js +0 -22
- package/dist/parser/layoutPreprocessor.js.map +0 -1
- package/dist/parser/preprocessor.d.ts +0 -28
- package/dist/parser/preprocessor.js +0 -453
- package/dist/parser/preprocessor.js.map +0 -1
- package/src/parser/layoutPreprocessor.ts +0 -21
- package/src/parser/preprocessor.ne +0 -375
- package/src/parser/preprocessor.ts +0 -502
- package/tests/preprocessor.spec.ts +0 -69
package/dist/parser/lexer.js
CHANGED
|
@@ -1,75 +1,284 @@
|
|
|
1
1
|
import moo from "moo";
|
|
2
2
|
import { keywords } from "../utils/types.js";
|
|
3
|
-
import { makeLexer } from "moo-ignore";
|
|
4
|
-
import IndentationLexer from "moo-indentation-lexer";
|
|
5
3
|
export const HaskellLexerConfig = {
|
|
6
|
-
|
|
7
|
-
anonymousVariable: "_",
|
|
8
|
-
WS: / |\t/,
|
|
9
|
-
comment: /--.*?$|{-[\s\S]*?-}/,
|
|
4
|
+
comment: { match: /--.*?$|{-[\s\S]*?-}/, lineBreaks: true },
|
|
10
5
|
number: /0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+|(?:\d*\.\d+|\d+)(?:[eE][+-]?\d+)?/,
|
|
11
6
|
char: /'(?:\\['\\bfnrtv0]|\\u[0-9a-fA-F]{4}|[^'\\\n\r])?'/,
|
|
12
|
-
string: /"(?:\\[
|
|
13
|
-
//template: /`(?:\\[\s\S]|[^\\`])*`/,
|
|
14
|
-
backtick: "`",
|
|
7
|
+
string: { match: /"(?:\\[\s\S]|[^"\\])*"/, lineBreaks: true },
|
|
15
8
|
lparen: "(",
|
|
16
9
|
rparen: ")",
|
|
17
10
|
lbracket: "{",
|
|
18
11
|
rbracket: "}",
|
|
19
12
|
lsquare: "[",
|
|
20
13
|
rsquare: "]",
|
|
21
|
-
rangeOperator: "..",
|
|
22
14
|
semicolon: ";",
|
|
23
15
|
typeArrow: "->",
|
|
24
16
|
leftArrow: "<-",
|
|
25
17
|
typeEquals: "::",
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
fatArrow: "=>",
|
|
19
|
+
op: {
|
|
20
|
+
match: /,|>>=|>>|\\\\|\\|\.\.|\.|\+\+|\+|\-|\*\*|\*|===|!==|==|\/=|<=|>=|<|>|&&|\/|\|\||\$!|\$|\^\^|\^|#|@|~|!!|!|%|\?|:|&|`/,
|
|
21
|
+
lineBreaks: false,
|
|
30
22
|
},
|
|
31
|
-
op: /,|>>=|>>|\\\\|\\|\.|\+\+|\+|\-|\*\*|\*|===|!==|==|\/=|<=|>=|<|>|&&|\/|\|\||\.\.|\$|\^\^|\^|#|@|~|!!|!|%|\?|:|&|\||`/,
|
|
32
23
|
assign: "=",
|
|
24
|
+
backslash: "\\",
|
|
25
|
+
pipe: "|",
|
|
26
|
+
at: "@",
|
|
27
|
+
tilde: "~",
|
|
28
|
+
anonymousVariable: "_",
|
|
33
29
|
constructor: {
|
|
34
30
|
match: /[A-Z][a-zA-Z0-9']*/,
|
|
35
|
-
type: moo.keywords({
|
|
36
|
-
typeClass: [
|
|
37
|
-
"Foldable",
|
|
38
|
-
"Bounded",
|
|
39
|
-
"Enum",
|
|
40
|
-
"Eq",
|
|
41
|
-
"Floating",
|
|
42
|
-
"Fractional",
|
|
43
|
-
"Functor",
|
|
44
|
-
"Integral",
|
|
45
|
-
"Ix",
|
|
46
|
-
"Monad",
|
|
47
|
-
"MonadPlus",
|
|
48
|
-
"Num",
|
|
49
|
-
"Ord",
|
|
50
|
-
"Random",
|
|
51
|
-
"RandomGen",
|
|
52
|
-
"Read",
|
|
53
|
-
"Real",
|
|
54
|
-
"RealFloat",
|
|
55
|
-
"RealFrac",
|
|
56
|
-
"Show",
|
|
57
|
-
],
|
|
58
|
-
}),
|
|
31
|
+
type: moo.keywords({ bool: ["True", "False"] }),
|
|
59
32
|
},
|
|
60
33
|
variable: {
|
|
61
34
|
match: /[a-z_][a-zA-Z0-9_']*/,
|
|
62
|
-
type: moo.keywords({
|
|
63
|
-
otherwise: "otherwise",
|
|
64
|
-
error: "error",
|
|
65
|
-
keyword: keywords,
|
|
66
|
-
}),
|
|
35
|
+
type: moo.keywords({ otherwise: "otherwise", keyword: keywords }),
|
|
67
36
|
},
|
|
37
|
+
NL: { match: /\r?\n/, lineBreaks: true },
|
|
38
|
+
WS: { match: /[ \t]+/, lineBreaks: false },
|
|
68
39
|
};
|
|
69
|
-
export
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
40
|
+
export class HaskellLayoutLexer {
|
|
41
|
+
index;
|
|
42
|
+
mooLexer;
|
|
43
|
+
state;
|
|
44
|
+
layoutTriggers = new Set(["where", "let", "do", "of"]);
|
|
45
|
+
noSemicolonKeywords = new Set(["in", "then", "else", "of"]);
|
|
46
|
+
alwaysNewDeclarationKeywords = new Set([
|
|
47
|
+
"type",
|
|
48
|
+
"data",
|
|
49
|
+
"class",
|
|
50
|
+
"instance",
|
|
51
|
+
"describe",
|
|
52
|
+
"it",
|
|
53
|
+
"module",
|
|
54
|
+
"import",
|
|
55
|
+
]);
|
|
56
|
+
constructor() {
|
|
57
|
+
this.mooLexer = moo.compile(HaskellLexerConfig);
|
|
58
|
+
this.state = {
|
|
59
|
+
stack: [1],
|
|
60
|
+
tokenBuffer: [],
|
|
61
|
+
expectingBlock: false,
|
|
62
|
+
firstTokenProcessed: false,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
[Symbol.iterator]() {
|
|
66
|
+
return {
|
|
67
|
+
next: () => {
|
|
68
|
+
const value = this.next();
|
|
69
|
+
return value
|
|
70
|
+
? { value, done: false }
|
|
71
|
+
: { value: undefined, done: true };
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
reset(chunk, state) {
|
|
76
|
+
if (state && state.layoutState) {
|
|
77
|
+
const fullState = state;
|
|
78
|
+
this.state = {
|
|
79
|
+
stack: [...fullState.layoutState.stack],
|
|
80
|
+
tokenBuffer: [...fullState.layoutState.tokenBuffer],
|
|
81
|
+
expectingBlock: fullState.layoutState.expectingBlock,
|
|
82
|
+
firstTokenProcessed: fullState.layoutState.firstTokenProcessed,
|
|
83
|
+
};
|
|
84
|
+
this.mooLexer.reset(chunk, fullState);
|
|
85
|
+
if (typeof fullState.mooIndex === "number") {
|
|
86
|
+
this.mooLexer.index = fullState.mooIndex;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
this.state = {
|
|
91
|
+
stack: [1],
|
|
92
|
+
tokenBuffer: [],
|
|
93
|
+
expectingBlock: false,
|
|
94
|
+
firstTokenProcessed: false,
|
|
95
|
+
};
|
|
96
|
+
this.mooLexer.reset(chunk);
|
|
97
|
+
}
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
save() {
|
|
101
|
+
return {
|
|
102
|
+
...this.mooLexer.save(),
|
|
103
|
+
mooIndex: this.mooLexer.index,
|
|
104
|
+
layoutState: {
|
|
105
|
+
stack: [...this.state.stack],
|
|
106
|
+
tokenBuffer: [...this.state.tokenBuffer],
|
|
107
|
+
expectingBlock: this.state.expectingBlock,
|
|
108
|
+
firstTokenProcessed: this.state.firstTokenProcessed,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
pushState(state) {
|
|
113
|
+
this.mooLexer.pushState(state);
|
|
114
|
+
}
|
|
115
|
+
popState() {
|
|
116
|
+
return this.mooLexer.popState();
|
|
117
|
+
}
|
|
118
|
+
setState(state) {
|
|
119
|
+
this.mooLexer.setState(state);
|
|
120
|
+
}
|
|
121
|
+
formatError(token, message) {
|
|
122
|
+
return this.mooLexer.formatError(token, message);
|
|
123
|
+
}
|
|
124
|
+
has(tokenType) {
|
|
125
|
+
return true; // deprecated in moo but Lexer interface requires it.
|
|
126
|
+
}
|
|
127
|
+
next() {
|
|
128
|
+
let token;
|
|
129
|
+
if (this.state.tokenBuffer.length > 0) {
|
|
130
|
+
token = this.state.tokenBuffer.shift();
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
token = this.fetchAndProcessNextToken();
|
|
134
|
+
}
|
|
135
|
+
if (token) {
|
|
136
|
+
this.checkLayoutTrigger(token);
|
|
137
|
+
if (!this.state.firstTokenProcessed && token.col > 1) {
|
|
138
|
+
this.state.stack[0] = token.col;
|
|
139
|
+
}
|
|
140
|
+
this.state.firstTokenProcessed = true;
|
|
141
|
+
}
|
|
142
|
+
return token;
|
|
143
|
+
}
|
|
144
|
+
fetchAndProcessNextToken() {
|
|
145
|
+
let { token: rawToken, crossedNewline } = this.advanceSkippingWhitespace();
|
|
146
|
+
if (!rawToken)
|
|
147
|
+
return this.emitEOF();
|
|
148
|
+
if (this.state.expectingBlock)
|
|
149
|
+
return this.handleBlockStart(rawToken);
|
|
150
|
+
if (this.isInToken(rawToken))
|
|
151
|
+
return this.handleInKeyword(rawToken);
|
|
152
|
+
if (crossedNewline)
|
|
153
|
+
return this.handleIndentationChange(rawToken);
|
|
154
|
+
return rawToken;
|
|
155
|
+
}
|
|
156
|
+
advanceSkippingWhitespace() {
|
|
157
|
+
let token = this.mooLexer.next();
|
|
158
|
+
let crossedNewline = false;
|
|
159
|
+
while (token && this.isSkippableToken(token)) {
|
|
160
|
+
if (this.isNewlineToken(token))
|
|
161
|
+
crossedNewline = true;
|
|
162
|
+
token = this.mooLexer.next();
|
|
163
|
+
}
|
|
164
|
+
return { token, crossedNewline };
|
|
165
|
+
}
|
|
166
|
+
closeBlocksUntil(targetIndent, sourceToken) {
|
|
167
|
+
const ops = [];
|
|
168
|
+
while (this.state.stack.length > 1 &&
|
|
169
|
+
this.state.stack[this.state.stack.length - 1] > targetIndent) {
|
|
170
|
+
this.state.stack.pop();
|
|
171
|
+
ops.push(this.createVirtualToken("rbracket", "}", sourceToken));
|
|
172
|
+
}
|
|
173
|
+
const isAlwaysNewDeclaration = this.state.stack.length === 1 &&
|
|
174
|
+
sourceToken.type === "keyword" &&
|
|
175
|
+
this.alwaysNewDeclarationKeywords.has(sourceToken.value);
|
|
176
|
+
const shouldInjectSemicolon = !sourceToken.value || !this.noSemicolonKeywords.has(sourceToken.value);
|
|
177
|
+
if (this.state.stack.length > 1 &&
|
|
178
|
+
this.state.stack[this.state.stack.length - 1] === targetIndent &&
|
|
179
|
+
this.isInToken(sourceToken)) {
|
|
180
|
+
this.state.stack.pop();
|
|
181
|
+
ops.push(this.createVirtualToken("rbracket", "}", sourceToken));
|
|
182
|
+
}
|
|
183
|
+
else if ((this.state.stack.length > 0 &&
|
|
184
|
+
this.state.stack[this.state.stack.length - 1] === targetIndent &&
|
|
185
|
+
shouldInjectSemicolon) ||
|
|
186
|
+
isAlwaysNewDeclaration) {
|
|
187
|
+
ops.push(this.createVirtualToken("semicolon", ";", sourceToken));
|
|
188
|
+
}
|
|
189
|
+
this.state.tokenBuffer.unshift(...ops);
|
|
190
|
+
return this.state.tokenBuffer.shift();
|
|
191
|
+
}
|
|
192
|
+
emitEOF() {
|
|
193
|
+
if (this.state.stack.length > 1) {
|
|
194
|
+
const dummy = {
|
|
195
|
+
line: 0,
|
|
196
|
+
col: 0,
|
|
197
|
+
text: "",
|
|
198
|
+
value: "",
|
|
199
|
+
offset: 0,
|
|
200
|
+
lineBreaks: 0,
|
|
201
|
+
};
|
|
202
|
+
const ops = [];
|
|
203
|
+
while (this.state.stack.length > 1) {
|
|
204
|
+
this.state.stack.pop();
|
|
205
|
+
ops.push(this.createVirtualToken("rbracket", "}", dummy));
|
|
206
|
+
}
|
|
207
|
+
this.state.tokenBuffer.push(...ops);
|
|
208
|
+
return this.state.tokenBuffer.shift();
|
|
209
|
+
}
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
enqueue(token) {
|
|
213
|
+
this.state.tokenBuffer.push(token);
|
|
214
|
+
}
|
|
215
|
+
handleBlockStart(token) {
|
|
216
|
+
this.state.expectingBlock = false;
|
|
217
|
+
if (token.type === "lbracket")
|
|
218
|
+
return token;
|
|
219
|
+
this.state.stack.push(token.col);
|
|
220
|
+
this.enqueue(token);
|
|
221
|
+
return this.createVirtualToken("lbracket", "{", token);
|
|
222
|
+
}
|
|
223
|
+
handleInKeyword(token) {
|
|
224
|
+
const stackTop = this.state.stack[this.state.stack.length - 1];
|
|
225
|
+
if (token.col < stackTop) {
|
|
226
|
+
this.enqueue(token);
|
|
227
|
+
return this.closeBlocksUntil(token.col, token);
|
|
228
|
+
}
|
|
229
|
+
if (this.state.stack.length > 1) {
|
|
230
|
+
this.state.stack.pop();
|
|
231
|
+
this.enqueue(token);
|
|
232
|
+
return this.createVirtualToken("rbracket", "}", token);
|
|
233
|
+
}
|
|
234
|
+
return token;
|
|
235
|
+
}
|
|
236
|
+
handleIndentationChange(token) {
|
|
237
|
+
const currentIndent = token.col;
|
|
238
|
+
const stackTop = this.state.stack[this.state.stack.length - 1];
|
|
239
|
+
const isAlwaysNewDeclaration = this.state.stack.length === 1 &&
|
|
240
|
+
token.type === "keyword" &&
|
|
241
|
+
this.alwaysNewDeclarationKeywords.has(token.value);
|
|
242
|
+
if (currentIndent === stackTop || isAlwaysNewDeclaration) {
|
|
243
|
+
const isContinuationKeyword = token.value && this.noSemicolonKeywords.has(token.value);
|
|
244
|
+
if (this.state.firstTokenProcessed && !isContinuationKeyword) {
|
|
245
|
+
this.enqueue(token);
|
|
246
|
+
return this.createVirtualToken("semicolon", ";", token);
|
|
247
|
+
}
|
|
248
|
+
return token;
|
|
249
|
+
}
|
|
250
|
+
else if (currentIndent < stackTop) {
|
|
251
|
+
this.enqueue(token);
|
|
252
|
+
return this.closeBlocksUntil(currentIndent, token);
|
|
253
|
+
}
|
|
254
|
+
return token;
|
|
255
|
+
}
|
|
256
|
+
checkLayoutTrigger(token) {
|
|
257
|
+
if (token && token.value && this.layoutTriggers.has(token.value))
|
|
258
|
+
this.state.expectingBlock = true;
|
|
259
|
+
}
|
|
260
|
+
isSkippableToken(token) {
|
|
261
|
+
return (token.type === "WS" ||
|
|
262
|
+
this.isNewlineToken(token) ||
|
|
263
|
+
token.type === "comment");
|
|
264
|
+
}
|
|
265
|
+
isNewlineToken(token) {
|
|
266
|
+
return token.type === "NL";
|
|
267
|
+
}
|
|
268
|
+
isInToken(token) {
|
|
269
|
+
return token.type === "keyword" && token.value === "in";
|
|
270
|
+
}
|
|
271
|
+
createVirtualToken(type, value, source) {
|
|
272
|
+
return {
|
|
273
|
+
type,
|
|
274
|
+
value,
|
|
275
|
+
text: value,
|
|
276
|
+
line: source.line,
|
|
277
|
+
col: source.col,
|
|
278
|
+
offset: source.offset,
|
|
279
|
+
lineBreaks: 0,
|
|
280
|
+
toString: () => value,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
}
|
|
75
284
|
//# sourceMappingURL=lexer.js.map
|
package/dist/parser/lexer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../src/parser/lexer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../src/parser/lexer.ts"],"names":[],"mappings":"AAAA,OAAO,GAAiC,MAAM,KAAK,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAkB7C,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,IAAI,EAAE;IAE3D,MAAM,EACJ,4EAA4E;IAC9E,IAAI,EAAE,oDAAoD;IAC1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,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,kBAAkB,CAAC,KAAY;QACrC,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC;YAC9D,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;IACrC,CAAC;IACO,gBAAgB,CAAC,KAAY;QACnC,OAAO,CACL,KAAK,CAAC,IAAI,KAAK,IAAI;YACnB,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC;YAC1B,KAAK,CAAC,IAAI,KAAK,SAAS,CACzB,CAAC;IACJ,CAAC;IACO,cAAc,CAAC,KAAY;QACjC,OAAO,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IAC7B,CAAC;IACO,SAAS,CAAC,KAAY;QAC5B,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;IAC1D,CAAC;IAEO,kBAAkB,CACxB,IAAY,EACZ,KAAa,EACb,MAAa;QAEb,OAAO;YACL,IAAI;YACJ,KAAK;YACL,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK;SACtB,CAAC;IACJ,CAAC;CACF"}
|
package/dist/prelude.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const preludeCode = "data Ordering = LT | EQ | GT\ndata Maybe a = Nothing | Just a\n(,) :: a -> b -> (a, b)\n(,) x y = (x, y)\n($) :: (a -> b) -> a -> b\n($) f x = f x\n(.) :: (b -> c) -> (a -> b) -> a -> c\n(.) f g a = (\\x -> f (g x)) a\n(:) :: a -> [a] -> [a]\n(:) x xs = x : xs\n(++) :: [a] -> [a] -> [a]\n(++) [] ys = ys\n(++) (x:xs) ys = x : (xs ++ ys)\n(&&) ::
|
|
1
|
+
export declare const preludeCode = "data Ordering = LT | EQ | GT\ndata Maybe a = Nothing | Just a\nid :: a -> a\nid x = x\nconst :: a -> b -> a\nconst x _ = x\n(,) :: a -> b -> (a, b)\n(,) x y = (x, y)\n($) :: (a -> b) -> a -> b\n($) f x = f x\n($!) :: (a -> b) -> a -> b\n($!) f x = f x\n(.) :: (b -> c) -> (a -> b) -> a -> c\n(.) f g a = (\\x -> f (g x)) a\n(:) :: a -> [a] -> [a]\n(:) x xs = x : xs\n(++) :: [a] -> [a] -> [a]\n(++) [] ys = ys\n(++) (x:xs) ys = x : (xs ++ ys)\n(&&) :: Bool -> Bool -> Bool\n(||) :: Bool -> Bool -> Bool\n(&&) x y = x && y\n(||) x y = x || y\n(==) :: (Ord a) => a -> a -> Boolean\n(==) x y = x == y\n(/=) :: (Ord a) => a -> a -> Boolean\n(/=) x y = x /= y\n(<) :: (Ord a) => a -> a -> Boolean\n(<) x y = x < y\n(>) :: (Ord a) => a -> a -> Boolean\n(>) x y = x > y\n(<=) :: (Ord a) => a -> a -> Boolean\n(<=) x y = x <= y\n(>=) :: (Ord a) => a -> a -> Boolean\n(>=) x y = x >= y\n(+) :: Num a => a -> a -> a\n(-) :: Num a => a -> a -> a\n(+) x y = x + y\n(-) x y = x - y\n(**) :: (Floating a) => a -> a -> a\n(**) x y = x ** y\n(^) :: (Num a, Integral b) => a -> b -> a\n(^) x y = x ^ y\n(^^) :: (Fractional a, Integral b) => a -> b -> a\n(^^) x y = x ^^ y\n(*) :: (Num a) => a -> a -> a\n(*) x y = x * y\n(/) :: Fractional a => a -> a -> a\n(/) _ 0 = error \"Prelude./: divide by zero\"\n(/) x y = x / y\n(!!) :: [a] -> Int -> a\n(!!) xs n | n < 0 = error \"Prelude.!!: negative index\"\n(!!) [] _ = error \"Prelude.!!: index too large\"\n(!!) (x:_) 0 = x\n(!!) (_:xs) n = xs !! (n - 1)\nnot :: Bool -> Bool\nnot True = False\nnot False = True\nquot :: Integral a => a -> a -> a\nquot _ 0 = error \"divide by zero\"\nquot 0 _ = 0\nquot a b = let { absA = abs a; absB = abs b; result = quotPositive absA absB } in if (a < 0) == (b < 0) then result else -result\nrem :: Integral a => a -> a -> a\nrem _ 0 = error \"divide by zero\"\nrem 0 _ = 0\nrem a b = let { absA = abs a; absB = abs b; remainder = remPositive absA absB } in if a < 0 then -remainder else remainder\nquotPositive :: Integral a => a -> a -> a\nquotPositive n d | n < d = 0 | otherwise = 1 + quotPositive (n - d) d\nremPositive :: Integral a => a -> a -> a\nremPositive n d | n < d = n | otherwise = remPositive (n - d) d\ndiv :: Integral a => a -> a -> a\ndiv _ 0 = error \"divide by zero\"\ndiv 0 _ = 0\ndiv a b = let { q = quot a b; r = rem a b } in if r == 0 || (a < 0) == (b < 0) then q else q - 1\nmod :: Integral a => a -> a -> a\nmod _ 0 = error \"divide by zero\"\nmod 0 _ = 0\nmod a b = a - (div a b) * b\nsignum :: (Num a) => a -> a\nsignum x | x == 0 = 0 | x > 0 = 1 | otherwise = -1\nabs :: (Num a) => a -> a\nabs n = if n < 0 then -n else n\nsucc :: (Num a) => a -> a\nsucc x = x + 1\npred :: (Num a) => a -> a\npred x = x - 1\nsqrt :: (Num a) => a -> a\nsqrt x = x ** 0.5\nmax :: Ord a => a -> a -> a\nmax x y = if x <= y then y else x\nmin :: Ord a => a -> a -> a\nmin x y = if x <= y then x else y\neven :: (Integral a) => a -> Bool\nodd :: (Integral a) => a -> Bool\neven n = n `rem` 2 == 0\nodd n = (not . even) n\nlength :: [a] -> Int\nlength [] = 0\nlength (_:l) = 1 + length l\ngenericLength :: (Integral a) => [b] -> a\ngenericLength [] = 0\ngenericLength (x:xs) = 1 + genericLength xs\nnull :: [a] -> Bool\nnull [] = True\nnull (_:_) = False\nunion :: (Eq a) => [a] -> [a] -> [a]\nunion xs ys = unionBy (==) xs ys\ndeleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]\ndeleteBy eq x [] = []\ndeleteBy eq x (y:ys) = if x `eq` y then ys else y : deleteBy eq x ys\ndeleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]\ndeleteFirstsBy eq xs ys = foldl (flip (deleteBy eq)) xs ys\nnubBy :: (a -> a -> Bool) -> [a] -> [a]\nnubBy eq [] = []\nnubBy eq (x:xs) = x : nubBy eq (filter (\\y -> not (eq x y)) xs)\nunionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]\nunionBy eq xs ys = xs ++ deleteFirstsBy eq (nubBy eq ys) xs\nintersect :: (Eq a) => [a] -> [a] -> [a]\nintersect xs ys = intersectBy (==) xs ys\nintersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]\nintersectBy eq xs ys = [x | x <- xs, any (eq x) ys]\nelem :: (Eq a) => a -> [a] -> Bool\nnotElem :: (Eq a) => a -> [a] -> Bool\nelem x xs = any (\\y -> y == x) xs\nnotElem x xs = all (\\y -> y /= x) xs\nmaximum :: (Ord a) => [a] -> a\nminimum :: (Ord a) => [a] -> a\nmaximum [] = error \"Prelude.maximum: empty list\"\nmaximum xs = foldl1 max xs\nminimum [] = error \"Prelude.minimum: empty list\"\nminimum xs = foldl1 min xs\nsum :: (Num a) => [a] -> a\nproduct :: (Num a) => [a] -> a\nsum xs = foldl (+) 0 xs\nproduct xs = foldl (*) 1 xs\nconcat :: [[a]] -> [a]\nconcat xss = foldr (++) [] xss\nconcatMap :: (a -> [b]) -> [a] -> [b]\nconcatMap f xs = (concat . map) f xs\ntake :: Int -> [a] -> [a]\ntake n _ | n <= 0 = []\ntake _ [] = []\ntake n (x:xs) = x : take (n - 1) xs\ndrop :: Int -> [a] -> [a]\ndrop n xs | n <= 0 = xs\ndrop _ [] = []\ndrop n (_:xs) = drop (n - 1) xs\nhead :: [a] -> a\nhead (x:_) = x\nhead [] = error \"Prelude.head: empty list\"\ntail :: [a] -> [a]\ntail (_:xs) = xs\ntail [] = error \"Prelude.tail: empty list\"\nlast :: [a] -> a\nlast [x] = x\nlast (_:xs) = last xs\nlast [] = error \"Prelude.last: empty list\"\ninit :: [a] -> [a]\ninit [x] = []\ninit (x:xs) = x : init xs\ninit [] = error \"Prelude.init: empty list\"\nzip :: [a] -> [b] -> [(a, b)]\nzip xs ys = zipWith (,) xs ys\nzipWith :: (a -> b -> c) -> [a] -> [b] -> [c]\nzipWith z (a:as) (b:bs) = z a b : zipWith z as bs\nzipWith _ _ _ = []\nreverse :: [a] -> [a]\nreverse xs = foldl (flip (:)) [] xs\nfilter :: (a -> Bool) -> [a] -> [a]\nfilter p [] = []\nfilter p (x:xs) | p x = x : filter p xs | otherwise = filter p xs\nmap :: (a -> b) -> [a] -> [b]\nmap f [] = []\nmap f (x:xs) = f x : map f xs\nany :: (a -> Bool) -> [a] -> Bool\nany f [] = False\nany f (x:xs) = f x || any f xs\nall :: (a -> Bool) -> [a] -> Bool\nall f [] = True\nall f (x:xs) = f x && all f xs\nfoldl :: (a -> b -> a) -> a -> [b] -> a\nfoldl f z [] = z\nfoldl f z (x:xs) = foldl f (f z x) xs\nfoldl1 :: (a -> a -> a) -> [a] -> a\nfoldl1 f (x:xs) = foldl f x xs\nfoldl1 _ [] = error \"Prelude.foldl1: empty list\"\nfoldr :: (a -> b -> b) -> b -> [a] -> b\nfoldr f z [] = z\nfoldr f z (x:xs) = f x (foldr f z xs)\nfoldr1 :: (a -> a -> a) -> [a] -> a\nfoldr1 f [x] = x\nfoldr1 f (x:xs) = f x (foldr1 f xs)\nfoldr1 _ [] = error \"Prelude.foldr1: empty list\"\nfind :: Ord a => (a -> Bool) -> [a] -> Maybe a\nfind _ [] = Nothing\nfind f (x:xs) | f x = Just x | otherwise = find f xs\nsort :: (Ord a) => [a] -> [a]\nsort xs = sortBy compare xs\nsortBy :: (a -> a -> Ordering) -> [a] -> [a]\nsortBy cmp xs = foldr (insertBy cmp) [] xs\ncompare :: Ord a => a -> a -> Ordering\ncompare x y | x == y = EQ | x <= y = LT | otherwise = GT\ninsertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]\ninsertBy cmp x [] = [x]\ninsertBy cmp x ys@(y:ys') = case cmp x y of { GT -> y : insertBy cmp x ys'; _ -> x : ys }\nflip :: (a -> b -> c) -> b -> a -> c\nflip f x y = f y x\nrepeat :: a -> [a]\nrepeat x = x : (repeat x)\niterate :: (a -> a) -> a -> [a]\niterate f x = x : iterate f (f x)\nreplicate :: Int -> a -> [a]\nreplicate n x = take n (repeat x)\ncycle :: [a] -> [a]\ncycle [] = error \"Prelude.cycle: empty list\"\ncycle xs = xs ++ (cycle xs)\nfst :: (a,b) -> a\nfst (x,_) = x\nsnd :: (a,b) -> b\nsnd (_,y) = y\nbetween :: Ord a => a -> a -> a -> Bool\nbetween m n p | n >= m && n <= p = True | otherwise = False\ntruncate :: (Num a, Integral b) => a -> b\ntruncate x = quot x 1\nfloor :: (Num a, Integral b) => a -> b\nfloor x = div x 1\nnegate :: Num a => a -> a\nnegate n = 0 - n\nceiling :: (Num a, Integral b) => a -> b\nceiling x = negate (floor (negate x))\nround :: (Num a, Integral b) => a -> b\nround x | r < 0.5 = n | r > 0.5 = n + 1 | even n = n | otherwise = n + 1 where { n = floor x; r = x - n }\ndropWhile :: (a -> Bool) -> [a] -> [a]\ndropWhile _ [] = []\ndropWhile p xs@(x:xs') | p x = dropWhile p xs' | otherwise = xs\nbreak :: (a -> Bool) -> [a] -> ([a], [a])\nbreak _ [] = ([], [])\nbreak p (x:xs) | p x = ([], x:xs) | otherwise = (x : fst (break p xs), snd (break p xs))\nwords :: String -> [String]\nwords s = let { sTrim = dropWhile (\\c -> c == ' ') s } in if null sTrim then [] else fst (break (\\c -> c == ' ') sTrim) : words (snd (break (\\c -> c == ' ') sTrim))\nintersperse :: a -> [a] -> [a]\nintersperse _ [] = []\nintersperse _ [x] = [x]\nintersperse sep (x:xs) = x : sep : intersperse sep xs\nintercalate :: [a] -> [[a]] -> [a]\nintercalate xs xss = concat (intersperse xs xss)\nfromIntegral :: (Integral a, Num b) => a -> b\nfromIntegral x = x \n\nanyException = \"\"\nevaluate x = x\n\nclass Show a where\n show :: a -> String\n\ninstance Show Int where\n show x = primShow x\n\ninstance Show Bool where\n show True = \"True\"\n show False = \"False\"\n\ninstance Show Ordering where\n show LT = \"LT\"\n show EQ = \"EQ\"\n show GT = \"GT\"\n\ninstance Show (Maybe a) where\n show Nothing = \"Nothing\"\n show (Just x) = \"Just \" ++ show x\n\ninstance Show Char where\n show c = '\\'' : c : '\\'' : []\n\ninstance Show String where\n show s = primShowString s\n\ninstance Show [a] where\n show xs = '[' : (intercalate \",\" (map show xs) ++ \"]\")\n";
|