@exercism/codemirror-lang-purescript 0.0.0-stage → 1.0.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/dist/index.js ADDED
@@ -0,0 +1,1002 @@
1
+ import { ExternalTokenizer, ContextTracker, LRParser } from '@lezer/lr';
2
+ import { syntaxTree, indentService, LRLanguage, foldNodeProp, LanguageSupport } from '@codemirror/language';
3
+ import { styleTags, tags } from '@lezer/highlight';
4
+ import { snippetCompletion, ifNotIn, completeFromList } from '@codemirror/autocomplete';
5
+ import { NodeWeakMap } from '@lezer/common';
6
+
7
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
8
+ const LineComment = 1,
9
+ BlockComment = 2,
10
+ DocComment = 3,
11
+ blockOpen = 147,
12
+ blockEnd = 148,
13
+ blockSep = 149,
14
+ fieldDot = 150,
15
+ PropertyName = 4,
16
+ recordBrace = 151,
17
+ Qualifier = 5,
18
+ OperatorQualifier = 6,
19
+ DeclName = 7,
20
+ module$1 = 10,
21
+ closeParen = 12,
22
+ comma = 52,
23
+ closeBrace = 72,
24
+ where = 85,
25
+ _else = 89,
26
+ _in = 100,
27
+ then = 103,
28
+ of = 109,
29
+ closeBracket = 118;
30
+
31
+ // The external tokenizers and the layout tracker for the PureScript grammar.
32
+ // They are adapted from the Haskell grammar at
33
+ // https://codeberg.org/reeven/codemirror-lang-haskell (MIT, by CodinCod).
34
+ function isSpace(ch) {
35
+ return (ch == 32 /* Ch.Space */ ||
36
+ ch == 9 /* Ch.Tab */ ||
37
+ ch == 10 /* Ch.Newline */ ||
38
+ ch == 13 /* Ch.Return */ ||
39
+ ch == 12 /* Ch.FormFeed */ ||
40
+ ch == 11 /* Ch.VerticalTab */);
41
+ }
42
+ function isDigit(ch) {
43
+ return ch >= 48 /* Ch.Zero */ && ch <= 57 /* Ch.Nine */;
44
+ }
45
+ function isUpper(ch) {
46
+ return ch >= 65 /* Ch.UpperA */ && ch <= 90 /* Ch.UpperZ */;
47
+ }
48
+ // Everything above Latin-1 that the grammar doesn't read as an operator counts
49
+ // as a lowercase letter, which is close enough to read the names people write.
50
+ function isLower(ch) {
51
+ return ((ch >= 97 /* Ch.LowerA */ && ch <= 122 /* Ch.LowerZ */) ||
52
+ ch == 95 /* Ch.Underscore */ ||
53
+ (ch >= 161 /* Ch.Latin1 */ && ch < 8592 /* Ch.ArrowsFrom */) ||
54
+ ch >= 9312 /* Ch.LettersAgain */);
55
+ }
56
+ function isIdentifierStart(ch) {
57
+ return isLower(ch) || isUpper(ch);
58
+ }
59
+ function isIdentifierChar(ch) {
60
+ return isIdentifierStart(ch) || isDigit(ch) || ch == 39 /* Ch.Apostrophe */;
61
+ }
62
+ function isSymbol(ch) {
63
+ switch (ch) {
64
+ case 33 /* Ch.Bang */:
65
+ case 35 /* Ch.Hash */:
66
+ case 36 /* Ch.Dollar */:
67
+ case 37 /* Ch.Percent */:
68
+ case 38 /* Ch.Ampersand */:
69
+ case 42 /* Ch.Star */:
70
+ case 43 /* Ch.Plus */:
71
+ case 46 /* Ch.Dot */:
72
+ case 47 /* Ch.Slash */:
73
+ case 60 /* Ch.Less */:
74
+ case 61 /* Ch.Equals */:
75
+ case 62 /* Ch.Greater */:
76
+ case 63 /* Ch.Question */:
77
+ case 64 /* Ch.At */:
78
+ case 92 /* Ch.Backslash */:
79
+ case 94 /* Ch.Caret */:
80
+ case 124 /* Ch.Pipe */:
81
+ case 45 /* Ch.Minus */:
82
+ case 126 /* Ch.Tilde */:
83
+ case 58 /* Ch.Colon */:
84
+ return true;
85
+ default:
86
+ return ch >= 8592 /* Ch.ArrowsFrom */ && ch <= 8959 /* Ch.OperatorsTo */;
87
+ }
88
+ }
89
+ // The word that starts `offset` characters ahead, or "" if no word starts there.
90
+ function wordAt(input, offset) {
91
+ let word = "";
92
+ for (let pos = offset; isIdentifierChar(input.peek(pos)); pos++) {
93
+ word += String.fromCharCode(input.peek(pos));
94
+ }
95
+ return word;
96
+ }
97
+ // A line comment is two or more dashes with no other symbol after them, so
98
+ // `-->` stays an operator.
99
+ function startsComment(input, offset = 0) {
100
+ const next = input.peek(offset);
101
+ if (next == 123 /* Ch.BraceL */)
102
+ return input.peek(offset + 1) == 45 /* Ch.Minus */;
103
+ if (next != 45 /* Ch.Minus */ || input.peek(offset + 1) != 45 /* Ch.Minus */)
104
+ return false;
105
+ let pos = offset + 2;
106
+ while (input.peek(pos) == 45 /* Ch.Minus */)
107
+ pos++;
108
+ return !isSymbol(input.peek(pos));
109
+ }
110
+ // The position after any whitespace and comments that start at `pos`.
111
+ function skipSpace(input, pos) {
112
+ for (;;) {
113
+ const ch = input.peek(pos);
114
+ if (isSpace(ch))
115
+ pos++;
116
+ else if (ch == 45 /* Ch.Minus */ && startsComment(input, pos)) {
117
+ while (input.peek(pos) != 10 /* Ch.Newline */ && input.peek(pos) != -1 /* Ch.EOF */)
118
+ pos++;
119
+ }
120
+ else
121
+ return pos;
122
+ }
123
+ }
124
+ // ── Comments ──────────────────────────────────────────────────────────────────
125
+ /// Block comments nest here, so `{- {- -} -}` is one comment. A comment that
126
+ /// starts with `|`, such as `-- | Adds one`, is documentation.
127
+ const comments = new ExternalTokenizer((input) => {
128
+ if (input.next == 45 /* Ch.Minus */) {
129
+ if (!startsComment(input))
130
+ return;
131
+ let pos = 2;
132
+ while (input.peek(pos) == 45 /* Ch.Minus */)
133
+ pos++;
134
+ let doc = false;
135
+ for (let scan = pos;; scan++) {
136
+ const ch = input.peek(scan);
137
+ if (ch == 32 /* Ch.Space */ || ch == 9 /* Ch.Tab */)
138
+ continue;
139
+ doc = ch == 124 /* Ch.Pipe */;
140
+ break;
141
+ }
142
+ while (input.peek(pos) != 10 /* Ch.Newline */ && input.peek(pos) != -1 /* Ch.EOF */)
143
+ pos++;
144
+ input.acceptToken(doc ? DocComment : LineComment, pos);
145
+ return;
146
+ }
147
+ if (input.next != 123 /* Ch.BraceL */ || input.peek(1) != 45 /* Ch.Minus */)
148
+ return;
149
+ const doc = input.peek(2) == 124 /* Ch.Pipe */;
150
+ let depth = 0;
151
+ for (let pos = 0;; pos++) {
152
+ const ch = input.peek(pos);
153
+ if (ch == -1 /* Ch.EOF */) {
154
+ input.acceptToken(doc ? DocComment : BlockComment, pos);
155
+ return;
156
+ }
157
+ if (ch == 123 /* Ch.BraceL */ && input.peek(pos + 1) == 45 /* Ch.Minus */) {
158
+ depth++;
159
+ pos++;
160
+ }
161
+ else if (ch == 45 /* Ch.Minus */ && input.peek(pos + 1) == 125 /* Ch.BraceR */) {
162
+ depth--;
163
+ pos++;
164
+ if (!depth) {
165
+ input.acceptToken(doc ? DocComment : BlockComment, pos + 1);
166
+ return;
167
+ }
168
+ }
169
+ }
170
+ });
171
+ // ── Layout ────────────────────────────────────────────────────────────────────
172
+ /// One open block, and the column its items line up on.
173
+ class Layout {
174
+ constructor(parent, column) {
175
+ this.parent = parent;
176
+ this.column = column;
177
+ this.hash = (parent ? parent.hash * 31 : 0) + column;
178
+ }
179
+ }
180
+ // Nothing is open yet, and a block may open at any column, including the first.
181
+ const noLayout = new Layout(null, -1);
182
+ // The column a position stands in, and whether only whitespace stands in front
183
+ // of it on its line. Tabs advance to the next multiple of eight.
184
+ function lineInfo(input) {
185
+ const before = [];
186
+ for (let offset = -1; offset > -400; offset--) {
187
+ const ch = input.peek(offset);
188
+ if (ch == -1 /* Ch.EOF */ || ch == 10 /* Ch.Newline */ || ch == 13 /* Ch.Return */)
189
+ break;
190
+ before.push(ch);
191
+ }
192
+ let column = 0, firstOnLine = true;
193
+ for (let pos = before.length - 1; pos >= 0; pos--) {
194
+ const ch = before[pos];
195
+ if (ch == 9 /* Ch.Tab */)
196
+ column += 8 - (column % 8);
197
+ else
198
+ column++;
199
+ if (!isSpace(ch))
200
+ firstOnLine = false;
201
+ }
202
+ return { column, firstOnLine };
203
+ }
204
+ // A block also ends where the parser would otherwise fail, which is what ends
205
+ // the block in `let x = 1 in x` on one line. These are the tokens that often
206
+ // stand right after a block, so the tokenizer asks the parser about them.
207
+ function closesBlock(input, stack) {
208
+ switch (input.next) {
209
+ case 41 /* Ch.ParenR */:
210
+ return !stack.canShift(closeParen);
211
+ case 93 /* Ch.BracketR */:
212
+ return !stack.canShift(closeBracket);
213
+ case 125 /* Ch.BraceR */:
214
+ return !stack.canShift(closeBrace);
215
+ case 44 /* Ch.Comma */:
216
+ return !stack.canShift(comma);
217
+ }
218
+ if (!isIdentifierStart(input.next))
219
+ return false;
220
+ switch (wordAt(input, 0)) {
221
+ case "in":
222
+ return !stack.canShift(_in);
223
+ case "then":
224
+ return !stack.canShift(then);
225
+ case "else":
226
+ return !stack.canShift(_else);
227
+ case "of":
228
+ return !stack.canShift(of);
229
+ case "where":
230
+ return !stack.canShift(where);
231
+ default:
232
+ return false;
233
+ }
234
+ }
235
+ /// The braces and semicolons that PureScript leaves out. A block opens at the
236
+ /// column of the first token after `where`, `do`, `ado`, `let` or `of`. An
237
+ /// item starts wherever a line begins at exactly that column. The block ends
238
+ /// at the first token to the left of that column, where the parser would
239
+ /// fail, or at the end of the file.
240
+ ///
241
+ /// If a block's first token stands no further right than the block around it,
242
+ /// the block is empty and closes where it opened.
243
+ const layout = new ExternalTokenizer((input, stack) => {
244
+ const cx = stack.context;
245
+ const open = cx.parent != null;
246
+ if (input.next == -1 /* Ch.EOF */) {
247
+ if (stack.canShift(blockOpen))
248
+ input.acceptToken(blockOpen);
249
+ else if (open && stack.canShift(blockEnd))
250
+ input.acceptToken(blockEnd);
251
+ return;
252
+ }
253
+ // The grammar skips whitespace and comments, so layout is decided in front
254
+ // of the tokens that are left.
255
+ if (isSpace(input.next) || startsComment(input))
256
+ return;
257
+ // The body of a module may open at the first token of the file, which is
258
+ // also where its header may stand. If there is a header, it wins.
259
+ if (stack.canShift(blockOpen)) {
260
+ if (stack.canShift(module$1) && wordAt(input, 0) == "module")
261
+ return;
262
+ input.acceptToken(blockOpen);
263
+ return;
264
+ }
265
+ if (!open)
266
+ return;
267
+ if (cx.column <= cx.parent.column && stack.canShift(blockEnd)) {
268
+ input.acceptToken(blockEnd);
269
+ return;
270
+ }
271
+ const { column, firstOnLine } = lineInfo(input);
272
+ // An `else` at the start of an item continues an instance chain or an
273
+ // `if` in a `do` block, so it starts a new item and closes nothing.
274
+ const startsItem = firstOnLine && column == cx.column && wordAt(input, 0) == "else";
275
+ if (!startsItem && closesBlock(input, stack) && stack.canShift(blockEnd)) {
276
+ input.acceptToken(blockEnd);
277
+ return;
278
+ }
279
+ if (!firstOnLine)
280
+ return;
281
+ // No item in a block starts with `where`, so a `where` at the block's own
282
+ // column belongs to whatever the block is inside.
283
+ const closing = column < cx.column || (column == cx.column && wordAt(input, 0) == "where");
284
+ if (closing && stack.canShift(blockEnd))
285
+ input.acceptToken(blockEnd);
286
+ else if (column == cx.column && stack.canShift(blockSep))
287
+ input.acceptToken(blockSep);
288
+ }, { contextual: true });
289
+ /// The stack of open blocks. Each block remembers the column it opened on.
290
+ const trackLayout = new ContextTracker({
291
+ start: noLayout,
292
+ shift(context, term, stack, input) {
293
+ var _a;
294
+ if (term == blockOpen)
295
+ return new Layout(context, lineInfo(input).column);
296
+ if (term == blockEnd)
297
+ return (_a = context.parent) !== null && _a !== void 0 ? _a : context;
298
+ return context;
299
+ },
300
+ hash: (context) => context.hash,
301
+ });
302
+ // ── Records ───────────────────────────────────────────────────────────────────
303
+ // The position after the label that starts at `pos`, or -1 if no label starts
304
+ // there. A label is a name or a string.
305
+ function labelEnd(input, pos) {
306
+ if (input.peek(pos) == 34 /* Ch.Quote */) {
307
+ for (pos++;; pos++) {
308
+ const ch = input.peek(pos);
309
+ if (ch == -1 /* Ch.EOF */ || ch == 10 /* Ch.Newline */)
310
+ return -1;
311
+ if (ch == 92 /* Ch.Backslash */)
312
+ pos++;
313
+ else if (ch == 34 /* Ch.Quote */)
314
+ return pos + 1;
315
+ }
316
+ }
317
+ if (!isIdentifierStart(input.peek(pos)))
318
+ return -1;
319
+ while (isIdentifierChar(input.peek(pos)))
320
+ pos++;
321
+ return pos;
322
+ }
323
+ /// Three tokens that records need.
324
+ ///
325
+ /// A dot with no space either side, as in `person.name` or `_.name`, reads a
326
+ /// field. PureScript has no `.` operator, so a dot in that position means
327
+ /// nothing else.
328
+ ///
329
+ /// A field's name is read here as well, because a label may be any word,
330
+ /// including a keyword such as `type`.
331
+ ///
332
+ /// A brace straight after a value opens a record update if its first field is
333
+ /// followed by `=`, as in `p { x = 1 }`. Otherwise the brace opens a record
334
+ /// literal, as in `f { x: 1 }`.
335
+ const fields = new ExternalTokenizer((input, stack) => {
336
+ const next = input.next;
337
+ if (next == 46 /* Ch.Dot */) {
338
+ const before = input.peek(-1);
339
+ const after = input.peek(1);
340
+ const joined = isIdentifierChar(before) ||
341
+ before == 41 /* Ch.ParenR */ ||
342
+ before == 93 /* Ch.BracketR */ ||
343
+ before == 125 /* Ch.BraceR */ ||
344
+ before == 34 /* Ch.Quote */;
345
+ if (joined && (isIdentifierStart(after) || after == 34 /* Ch.Quote */) && stack.canShift(fieldDot))
346
+ input.acceptToken(fieldDot, 1);
347
+ return;
348
+ }
349
+ if (next == 123 /* Ch.BraceL */) {
350
+ if (!stack.canShift(recordBrace))
351
+ return;
352
+ const end = labelEnd(input, skipSpace(input, 1));
353
+ if (end < 0)
354
+ return;
355
+ const after = skipSpace(input, end);
356
+ const ch = input.peek(after);
357
+ if ((ch == 61 /* Ch.Equals */ && !isSymbol(input.peek(after + 1))) || ch == 123 /* Ch.BraceL */)
358
+ input.acceptToken(recordBrace, 1);
359
+ return;
360
+ }
361
+ if (isIdentifierStart(next) && stack.canShift(PropertyName)) {
362
+ let pos = 0;
363
+ while (isIdentifierChar(input.peek(pos)))
364
+ pos++;
365
+ input.acceptToken(PropertyName, pos);
366
+ }
367
+ });
368
+ // ── Names ─────────────────────────────────────────────────────────────────────
369
+ /// The module a name is read out of. `Data.Map.insert` is one name in three
370
+ /// parts, so the module part is read here and handed over as its own token.
371
+ const qualifiers = new ExternalTokenizer((input, stack) => {
372
+ if (!isUpper(input.next))
373
+ return;
374
+ let pos = 0, end = 0, operator = false;
375
+ for (;;) {
376
+ if (!isUpper(input.peek(pos)))
377
+ break;
378
+ while (isIdentifierChar(input.peek(pos)))
379
+ pos++;
380
+ if (input.peek(pos) != 46 /* Ch.Dot */)
381
+ break;
382
+ const after = input.peek(pos + 1);
383
+ if (!isIdentifierStart(after) && !isSymbol(after))
384
+ break;
385
+ pos++;
386
+ end = pos;
387
+ operator = isSymbol(after);
388
+ }
389
+ if (!end)
390
+ return;
391
+ // `f M.x` applies a function and `f M.+ y` doesn't, so the tokenizer decides
392
+ // here whether an operator follows.
393
+ const term = operator ? OperatorQualifier : Qualifier;
394
+ if (stack.canShift(term))
395
+ input.acceptToken(term, end);
396
+ });
397
+ const reserved = new Set([
398
+ "ado",
399
+ "case",
400
+ "class",
401
+ "data",
402
+ "derive",
403
+ "do",
404
+ "else",
405
+ "false",
406
+ "forall",
407
+ "foreign",
408
+ "if",
409
+ "import",
410
+ "in",
411
+ "infix",
412
+ "infixl",
413
+ "infixr",
414
+ "instance",
415
+ "let",
416
+ "module",
417
+ "newtype",
418
+ "of",
419
+ "then",
420
+ "true",
421
+ "type",
422
+ "where",
423
+ "_",
424
+ ]);
425
+ /// The name a declaration declares. `f x = x` declares `f`, and so does
426
+ /// `f :: Int -> Int`, but `x <+> y = ...` declares the operator between the two
427
+ /// names. The tokenizer looks one token ahead to decide.
428
+ ///
429
+ /// If an operator follows the name, the name isn't the one being declared,
430
+ /// unless the operator is `::`, `=` or `|`. A backtick after the name means an
431
+ /// infix function is being declared. Anything else after the name, including
432
+ /// another name, a literal, a bracket and a comma, leaves the name a
433
+ /// declaration.
434
+ const declNames = new ExternalTokenizer((input, stack) => {
435
+ if (!isLower(input.next) || !stack.canShift(DeclName))
436
+ return;
437
+ let pos = 0;
438
+ while (isIdentifierChar(input.peek(pos)))
439
+ pos++;
440
+ if (reserved.has(wordAt(input, 0)))
441
+ return;
442
+ const scan = skipSpace(input, pos);
443
+ const next = input.peek(scan);
444
+ if (next == 96 /* Ch.Backtick */)
445
+ return;
446
+ // `person.name = ...` isn't valid, but `x.y` in a pattern is never a
447
+ // declaration either.
448
+ if (next == 46 /* Ch.Dot */ && scan == pos)
449
+ return;
450
+ if (isSymbol(next)) {
451
+ const second = input.peek(scan + 1), third = input.peek(scan + 2);
452
+ const signature = (next == 58 /* Ch.Colon */ && second == 58 /* Ch.Colon */ && !isSymbol(third)) ||
453
+ (next == 8759 /* Ch.Colons */ && !isSymbol(second));
454
+ const body = (next == 61 /* Ch.Equals */ || next == 124 /* Ch.Pipe */) && !isSymbol(second);
455
+ if (!signature && !body)
456
+ return;
457
+ }
458
+ input.acceptToken(DeclName, pos);
459
+ });
460
+
461
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
462
+ const spec_varid = {__proto__:null,module:20, type:34, class:36, kind:39, _:54, true:58, false:60, let:94, import:98, hiding:101, as:107, infixl:110, infixr:112, infix:114, forall:128, data:156, newtype:162, where:170, instance:174, else:178, derive:182, foreign:186, in:200, if:204, then:206, ado:210, case:216, of:218, do:226};
463
+ const spec_varsym = {__proto__:null,"?":70, "@":82, "\\":86, "->":88, "→":90, "∀":130, "=>":132, "⇒":134, "∷":138, "|":142, "=":152, "<-":196, "←":198};
464
+ const spec_consym = {__proto__:null,"::":136, ":":247};
465
+ const parser = LRParser.deserialize({
466
+ version: 14,
467
+ states: "!)[O`QsOOO#zQ!]O'#GOQOQqOOOcQsOOO$RQyO'#CeOOQ_'#Cp'#CpO$ZQqO'#CpOOQ_'#Cq'#CqOOQZ'#Cs'#CsO$cQqO'#CsOOQZ'#Ct'#CtO&[Q!PO'#DTOOQX'#Fz'#FzO'kQ!PO'#FzO*bQ{O'#FzO,rQyO'#E_OOQR'#GP'#GPOOQR,5<j,5<jO,|QsO,5<jOOQR'#F|'#F|OOQZ'#G^'#G^OOQR'#F{'#F{O-UQ{O'#F{O.lQyO'#DSO/yQ{O'#FyOOQR'#Fy'#FyOOQZ'#Ga'#GaO1aQ{O'#GbOOQR'#Er'#ErO2yQyO'#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%Z%[%_%c%f&p&s&u&y'R'W(P(V(Y(^(_Q$v#YS)[(i)XQ)|)rR)}){SQORQ#v!UQ%}$TR&Q$YQbPR$]!m!Z#j{|}!O!P!c#g#k#s$e%T%X%Z%[%_%c%f&p&s&u&y'R'W(P(V(Y(^(_Q!c_!Y#i{|}!O!P!c#g#k#s$e%T%X%Z%[%_%c%f&p&s&u&y'R'W(P(V(Y(^(_Q$e!vQ%c#qQ&u%UQ'R%eQ'W%hQ(^'TR(_'VS#Oq$lS$p#S&cT%U#h&vQ%]#mR%^#nS!l_!TR$V!iQ$Z!jQ'm&RR)r)^Q&P$XR'[%lQ#y!WR#{!YQ%o#xR(e']Seg!q!dfPop!V!X!j!k!m#x$f$k$v%i%j%p&P&R&T&b'Z'[']'b'o(a)U)W)[)^)_)k)|)}Q!ukQ$c!sR&W$aQ'c%rR(h'aQ)](iR)n)X!dmPop!V!X!j!k!m#x$f$k$v%i%j%p&P&R&T&b'Z'[']'b'o(a)U)W)[)^)_)k)|)}R!uk!dlPop!V!X!j!k!m#x$f$k$v%i%j%p&P&R&T&b'Z'[']'b'o(a)U)W)[)^)_)k)|)}S!pfmQ!tkR$d!uQ(p'eR)v)b",
470
+ nodeNames: "⚠ LineComment BlockComment DocComment PropertyName Qualifier OperatorQualifier DeclName Module ModuleHeader module ModuleName ) ( ExportList ModuleExport ExportItem type class kind Variable Constructor ParenOperator Operator ConstructorOperator ` BacktickOperator Wildcard Boolean true false Number String Char Hole ? ParenExpression Annotated ApplyExpression Callee AsPattern @ LambdaExpression \\ -> -> LetExpression let ImportDeclaration import hiding ImportList , as FixityDeclaration infixl infixr infix TypeSynonym Type TypeConstructor TypeVariable TypeOperator TypeConstructorOperator forall forall => => :: :: ParenType | } { RecordType FieldDeclaration = DataDeclaration data ConstructorDeclaration NewtypeDeclaration newtype ClassDeclaration FunctionalDependencies WhereBlock where InstanceDeclaration instance InstanceChain else DeriveDeclaration derive ForeignDeclaration foreign TypeSignature Bind GuardedEquation LetStatement <- <- in IfExpression if then AdoExpression ado BindStatement CaseExpression case of CaseAlternative GuardedEquation DoExpression do OperatorExpression ApplyExpression ApplyExpression ApplyExpression ] [ ArrayExpression Record FieldBind : FieldAccess RecordUpdate RecordUpdateFields FieldUpdate SubordinateList",
471
+ maxTerm: 191,
472
+ context: trackLayout,
473
+ nodeProps: [
474
+ ["openedBy", 12,"(",72,"{",118,"["],
475
+ ["closedBy", 13,")",73,"}",119,"]"],
476
+ ["isolate", 32,""]
477
+ ],
478
+ skippedNodes: [0,1,2,3],
479
+ repeatNodeCount: 17,
480
+ tokenData: "5d~R!OXY$RYZ$RZ[$R[]$R]^$Rpq$Rqr$jrs&Qst$jtu$juv$jvw$jwx,uxy.ryz.wz{$j{|$j|}.|}!O$j!O!P$j!P!Q$j!Q!R/R!R![0s![!]1s!^!_$j!_!`$j!`!a$j!a!b$j!b!c$j!c!}3Z!}#O4R#O#P$j#P#Q4W#Q#R$j#R#S4]#S#T5T#T#o4]#o#p5Y#p#q$j#q#r5_#r#s$j$g$Ii4]%#t%+t$j%3d;'S4];'S;=`4}<%lO4]~$WU$_~XY$RYZ$RZ[$R[]$R]^$Rpq$R~$oe$e~qr$jst$jtu$juv$jvw$jz{$j{|$j}!O$j!O!P$j!P!Q$j![!]$j!^!_$j!_!`$j!`!a$j!a!b$j!b!c$j#O#P$j#Q#R$j#p#q$j#r#s$j%#t%+t$j~&TWOY&mZr&mrs+Vs#O&m#O#P'_#P;'S&m;'S;=`+P<%lO&m~&pWOY&mZr&mrs'Ys#O&m#O#P'_#P;'S&m;'S;=`+P<%lO&m~'_Op~~'bYOX&mXY(QYZ)PZ]&m]^(Q^p&mpq(Qq;'S&m;'S;=`+P<%lO&m~(T^OX&mXY(QYZ)PZ]&m]^(Q^p&mpq(Qqr&mrs'Ys#O&m#O#P)c#P;'S&m;'S;=`+P<%lO&m~)STXY)PYZ)P]^)Ppq)P#O#P&m~)f^OX&mXY(QYZ)PZ]&m]^(Q^p&mpq(Qqr&mrs*bs#O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: 159, get: (value) => spec_varsym[value] || -1},{term: 160, get: (value) => spec_consym[value] || -1}],
484
+ tokenPrec: 0
485
+ });
486
+
487
+ /// Snippets for the constructs people write most often in PureScript.
488
+ const snippets = [
489
+ snippetCompletion("${name} :: ${Type}\n${name} ${args} = ${}", {
490
+ label: "fun",
491
+ detail: "function with signature",
492
+ type: "keyword",
493
+ }),
494
+ snippetCompletion("${name} ${args}\n | ${condition} = ${}\n | otherwise = ${}", {
495
+ label: "guard",
496
+ detail: "function with guards",
497
+ type: "keyword",
498
+ }),
499
+ snippetCompletion("case ${expression} of\n ${pattern} -> ${}", {
500
+ label: "case",
501
+ detail: "expression",
502
+ type: "keyword",
503
+ }),
504
+ snippetCompletion("if ${condition} then ${} else ${}", {
505
+ label: "if",
506
+ detail: "then else",
507
+ type: "keyword",
508
+ }),
509
+ snippetCompletion("let\n ${name} = ${value}\nin ${}", {
510
+ label: "let",
511
+ detail: "in",
512
+ type: "keyword",
513
+ }),
514
+ snippetCompletion("where\n ${name} = ${}", {
515
+ label: "where",
516
+ detail: "block",
517
+ type: "keyword",
518
+ }),
519
+ snippetCompletion("do\n ${x} <- ${action}\n ${}", {
520
+ label: "do",
521
+ detail: "block",
522
+ type: "keyword",
523
+ }),
524
+ snippetCompletion("\\${x} -> ${}", {
525
+ label: "\\",
526
+ detail: "lambda",
527
+ type: "keyword",
528
+ }),
529
+ snippetCompletion("foldl (\\${acc} ${x} -> ${}) ${initial} ${xs}", {
530
+ label: "foldl",
531
+ detail: "fold with a lambda",
532
+ type: "keyword",
533
+ }),
534
+ snippetCompletion("data ${Name} = ${Constructor}", {
535
+ label: "data",
536
+ detail: "type definition",
537
+ type: "keyword",
538
+ }),
539
+ snippetCompletion("newtype ${Name} = ${Name} ${Type}", {
540
+ label: "newtype",
541
+ detail: "definition",
542
+ type: "keyword",
543
+ }),
544
+ snippetCompletion("type ${Name} = { ${field} :: ${Type} }", {
545
+ label: "type",
546
+ detail: "record synonym",
547
+ type: "keyword",
548
+ }),
549
+ snippetCompletion("class ${Name} ${a} where\n ${method} :: ${a} -> ${}", {
550
+ label: "class",
551
+ detail: "definition",
552
+ type: "keyword",
553
+ }),
554
+ snippetCompletion("instance ${Class} ${Type} where\n ${method} = ${}", {
555
+ label: "instance",
556
+ detail: "definition",
557
+ type: "keyword",
558
+ }),
559
+ snippetCompletion("derive instance ${Eq} ${Type}", {
560
+ label: "derive",
561
+ detail: "instance",
562
+ type: "keyword",
563
+ }),
564
+ snippetCompletion("import ${Data.Map} as ${Map}", {
565
+ label: "import",
566
+ detail: "as",
567
+ type: "keyword",
568
+ }),
569
+ snippetCompletion("module ${Name} (${exports}) where\n\nimport Prelude\n\n${}", {
570
+ label: "module",
571
+ detail: "header",
572
+ type: "keyword",
573
+ }),
574
+ ];
575
+ const keywords = ("module import as hiding where let in do ado case of if then else " +
576
+ "data newtype type class instance derive foreign infix infixl infixr forall")
577
+ .split(" ")
578
+ .map((label) => ({ label, type: "keyword" }));
579
+ const constants = ["true", "false", "unit"].map((label) => ({ label, type: "constant" }));
580
+ // The functions exported by Prelude, and the ones people most often import
581
+ // from Data.Array, Data.Foldable, Data.Maybe, Data.String, Data.Tuple,
582
+ // Data.Either, Data.Map, Data.Int and Effect.Console.
583
+ const functions = [
584
+ // Prelude
585
+ "add", "append", "apply", "bind", "between", "bottom", "clamp", "compare",
586
+ "comparing", "conj", "const", "disj", "discard", "div", "eq", "flap", "flip",
587
+ "gcd", "identity", "join", "lcm", "liftA1", "liftM1", "map", "max", "mempty",
588
+ "min", "mod", "mul", "negate", "not", "notEq", "one", "otherwise", "pure",
589
+ "recip", "show", "sub", "top", "unless", "void", "when", "zero",
590
+ // Data.Array and Data.Foldable
591
+ "all", "any", "catMaybes", "concat", "concatMap", "cons", "drop", "dropWhile",
592
+ "elem", "filter", "find", "findIndex", "foldl", "foldMap", "foldr", "for_",
593
+ "fromFoldable", "group", "head", "index", "init", "insertAt", "intercalate",
594
+ "last", "length", "mapMaybe", "mapWithIndex", "maximum", "minimum", "notElem",
595
+ "nub", "null", "partition", "product", "range", "replicate", "reverse",
596
+ "singleton", "snoc", "sort", "sortBy", "sortWith", "span", "sum", "tail",
597
+ "take", "takeWhile", "toUnfoldable", "traverse", "traverse_", "uncons",
598
+ "unzip", "updateAt", "zip", "zipWith", "sequence", "for", "and", "or",
599
+ // Data.Maybe and Data.Either
600
+ "fromJust", "fromMaybe", "isJust", "isNothing", "maybe", "either", "isLeft",
601
+ "isRight", "hush", "note",
602
+ // Data.String and Data.String.CodeUnits
603
+ "charAt", "contains", "fromCharArray", "indexOf", "joinWith", "replace",
604
+ "replaceAll", "split", "toCharArray", "toLower", "toUpper", "trim",
605
+ // Data.Tuple
606
+ "curry", "fst", "snd", "swap", "uncurry",
607
+ // Data.Map
608
+ "alter", "empty", "insert", "insertWith", "keys", "lookup", "member",
609
+ "unionWith", "update", "values", "delete",
610
+ // Data.Int and Data.Char
611
+ "ceil", "even", "floor", "fromString", "odd", "pow", "quot", "rem", "round",
612
+ "toNumber", "fromCharCode", "toCharCode",
613
+ // Effect.Console
614
+ "log", "logShow",
615
+ ];
616
+ const types = [
617
+ "Array", "Boolean", "Char", "Effect", "Either", "Int", "List", "Map", "Maybe",
618
+ "Number", "Ordering", "Record", "Set", "String", "Tuple", "Type", "Unit",
619
+ "Applicative", "Apply", "Bind", "Bounded", "CommutativeRing", "Eq",
620
+ "EuclideanRing", "Field", "Foldable", "Functor", "HeytingAlgebra", "Monad",
621
+ "Monoid", "Ord", "Ring", "Semigroup", "Semiring", "Show", "Traversable",
622
+ ].map((label) => ({ label, type: "type" }));
623
+ const constructors = [
624
+ "Just", "Nothing", "Left", "Right", "Tuple", "LT", "EQ", "GT", "Nil", "Cons",
625
+ "Pattern", "Replacement",
626
+ ].map((label) => ({ label, type: "constant" }));
627
+ const globals = [
628
+ ...snippets,
629
+ ...keywords,
630
+ ...constants,
631
+ ...[...new Set(functions)].map((label) => ({ label, type: "function" })),
632
+ ...types,
633
+ ...constructors,
634
+ ];
635
+ // Every node here opens a scope: the names it binds are visible inside it and
636
+ // nowhere else. A `where` belongs to the binding or alternative above it, so it
637
+ // is read as part of that node's scope.
638
+ const ScopeNodes = new Set([
639
+ "Module",
640
+ "Bind",
641
+ "LambdaExpression",
642
+ "CaseAlternative",
643
+ "DoExpression",
644
+ "AdoExpression",
645
+ "LetExpression",
646
+ "GuardedEquation",
647
+ ]);
648
+ // A pattern is written as an expression, so its variables are the unqualified
649
+ // `Variable` nodes in it. In a record pattern, `{ name }` binds `name`, and
650
+ // `{ name: n }` binds `n`.
651
+ const notPattern = new Set([
652
+ "Callee",
653
+ "Type",
654
+ "LambdaExpression",
655
+ "CaseAlternative",
656
+ "CaseExpression",
657
+ "DoExpression",
658
+ "AdoExpression",
659
+ "LetExpression",
660
+ ]);
661
+ function patternVariables(node, def) {
662
+ var _a;
663
+ if (node.name == "Variable") {
664
+ if (!node.firstChild)
665
+ def(node, "variable");
666
+ }
667
+ else if (node.name == "FieldBind") {
668
+ const label = node.firstChild;
669
+ const value = (_a = label === null || label === void 0 ? void 0 : label.nextSibling) === null || _a === void 0 ? void 0 : _a.nextSibling;
670
+ if (value)
671
+ patternVariables(value, def);
672
+ else if ((label === null || label === void 0 ? void 0 : label.name) == "PropertyName")
673
+ def(label, "variable");
674
+ }
675
+ else if (!notPattern.has(node.name)) {
676
+ for (let ch = node.firstChild; ch; ch = ch.nextSibling)
677
+ patternVariables(ch, def);
678
+ }
679
+ }
680
+ function isRhs(node) {
681
+ return (node.name == "=" || node.name == "->" || node.name == "GuardedEquation" || node.name == "WhereBlock");
682
+ }
683
+ // `x <+> y = ...` defines an operator, and the operands are its parameters.
684
+ function definesOperator(lhs) {
685
+ if (lhs.name != "OperatorExpression")
686
+ return false;
687
+ for (let ch = lhs.firstChild; ch; ch = ch.nextSibling)
688
+ if (ch.name == "Operator" || ch.name == "BacktickOperator")
689
+ return true;
690
+ return false;
691
+ }
692
+ // The name a type declaration introduces is the first constructor in its head,
693
+ // after any context. `class Eq a <= Ord a` declares `Ord`, and
694
+ // `class (Eq a) => Ord a` does too.
695
+ function declaredType(type) {
696
+ if (!type)
697
+ return null;
698
+ let found = null;
699
+ for (let ch = type.firstChild; ch; ch = ch.nextSibling) {
700
+ if (ch.name == "=>")
701
+ found = null;
702
+ else if (ch.name == "TypeOperator" && ch.to - ch.from == 2)
703
+ found = null;
704
+ else if (ch.name == "TypeConstructor" && !found)
705
+ found = ch;
706
+ }
707
+ return found;
708
+ }
709
+ function gatherTypeDeclaration(node, def) {
710
+ const name = declaredType(node.getChild("Type"));
711
+ if (name)
712
+ def(name, node.name == "ClassDeclaration" ? "class" : "type");
713
+ for (const con of node.getChildren("ConstructorDeclaration")) {
714
+ const type = con.getChild("Type");
715
+ const name = type === null || type === void 0 ? void 0 : type.getChild("TypeConstructor");
716
+ if (name)
717
+ def(name, "constant");
718
+ }
719
+ }
720
+ // What a node declares into the scope around it. Returning true stops the walk
721
+ // going into the node.
722
+ const gatherers = {
723
+ Bind(node, def) {
724
+ const first = node.firstChild;
725
+ if ((first === null || first === void 0 ? void 0 : first.name) == "DeclName") {
726
+ const hasParams = first.nextSibling && !isRhs(first.nextSibling);
727
+ def(first, hasParams ? "function" : "variable");
728
+ }
729
+ else if (first && !definesOperator(first)) {
730
+ patternVariables(first, def);
731
+ }
732
+ return true;
733
+ },
734
+ TypeSignature(node, def) {
735
+ var _a;
736
+ const isFunction = !!((_a = node.getChild("Type")) === null || _a === void 0 ? void 0 : _a.getChild("->"));
737
+ for (const n of node.getChildren("DeclName"))
738
+ def(n, isFunction ? "function" : "variable");
739
+ return true;
740
+ },
741
+ ForeignDeclaration(node, def) {
742
+ var _a, _b;
743
+ const isFunction = !!((_a = node.getChild("Type")) === null || _a === void 0 ? void 0 : _a.getChild("->"));
744
+ const name = (_b = node.getChild("DeclName")) !== null && _b !== void 0 ? _b : node.getChild("TypeConstructor");
745
+ if (name)
746
+ def(name, name.name == "DeclName" ? (isFunction ? "function" : "variable") : "type");
747
+ return true;
748
+ },
749
+ DataDeclaration(node, def) {
750
+ gatherTypeDeclaration(node, def);
751
+ return true;
752
+ },
753
+ NewtypeDeclaration(node, def) {
754
+ gatherTypeDeclaration(node, def);
755
+ return true;
756
+ },
757
+ TypeSynonym(node, def) {
758
+ gatherTypeDeclaration(node, def);
759
+ return true;
760
+ },
761
+ ClassDeclaration(node, def) {
762
+ gatherTypeDeclaration(node, def);
763
+ return false;
764
+ },
765
+ BindStatement(node, def) {
766
+ if (node.firstChild)
767
+ patternVariables(node.firstChild, def);
768
+ return false;
769
+ },
770
+ ImportDeclaration(node, def) {
771
+ var _a;
772
+ const alias = (_a = node.getChild("as")) === null || _a === void 0 ? void 0 : _a.nextSibling;
773
+ if ((alias === null || alias === void 0 ? void 0 : alias.name) == "ModuleName")
774
+ def(alias, "namespace");
775
+ return true;
776
+ },
777
+ InstanceDeclaration() {
778
+ return true;
779
+ },
780
+ };
781
+ // The names a scope node binds itself: a function's parameters, a lambda's
782
+ // arguments, the variables in a `case` pattern or a pattern guard.
783
+ function ownBindings(node, def) {
784
+ var _a;
785
+ switch (node.name) {
786
+ case "Bind": {
787
+ const first = node.firstChild;
788
+ if ((first === null || first === void 0 ? void 0 : first.name) == "DeclName") {
789
+ for (let ch = first.nextSibling; ch && !isRhs(ch); ch = ch.nextSibling)
790
+ patternVariables(ch, def);
791
+ }
792
+ else if (first && definesOperator(first)) {
793
+ patternVariables(first, def);
794
+ }
795
+ break;
796
+ }
797
+ case "LambdaExpression":
798
+ for (let ch = (_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.nextSibling; ch && ch.name != "->"; ch = ch.nextSibling)
799
+ patternVariables(ch, def);
800
+ break;
801
+ case "CaseAlternative":
802
+ for (let ch = node.firstChild; ch && !isRhs(ch); ch = ch.nextSibling)
803
+ patternVariables(ch, def);
804
+ break;
805
+ case "GuardedEquation":
806
+ for (let ch = node.firstChild; ch; ch = ch.nextSibling)
807
+ if (ch.name == "<-" && ch.prevSibling)
808
+ patternVariables(ch.prevSibling, def);
809
+ break;
810
+ }
811
+ }
812
+ const cache = new NodeWeakMap();
813
+ function getScope(doc, node) {
814
+ const cached = cache.get(node);
815
+ if (cached)
816
+ return cached;
817
+ const completions = [];
818
+ const seen = new Set();
819
+ const def = (n, type) => {
820
+ const label = doc.sliceString(n.from, n.to);
821
+ if (!label || seen.has(label))
822
+ return;
823
+ seen.add(label);
824
+ completions.push({ label, type });
825
+ };
826
+ ownBindings(node, def);
827
+ const walk = (parent) => {
828
+ for (let ch = parent.firstChild; ch; ch = ch.nextSibling) {
829
+ const gather = gatherers[ch.name];
830
+ if (gather && gather(ch, def))
831
+ continue;
832
+ if (!ScopeNodes.has(ch.name))
833
+ walk(ch);
834
+ }
835
+ };
836
+ walk(node);
837
+ cache.set(node, completions);
838
+ return completions;
839
+ }
840
+ const Identifier = /^[\w'\xa1-￿]*$/;
841
+ const dontComplete = ["String", "Char", "Number", "LineComment", "BlockComment", "DocComment"];
842
+ // True if the word being typed follows a dot, as in `Map.l` or `person.n`.
843
+ // Neither asks for a name declared in scope.
844
+ function afterDot(context, from) {
845
+ return context.state.sliceDoc(Math.max(0, from - 1), from) == ".";
846
+ }
847
+ /// Completes the names declared in the file that are in scope at the cursor:
848
+ /// top-level functions, types and constructors, parameters, pattern
849
+ /// variables, and the bindings of `let`, `where`, `do` and `ado`.
850
+ const localCompletionSource = (context) => {
851
+ const inner = syntaxTree(context.state).resolveInner(context.pos, -1);
852
+ if (dontComplete.includes(inner.name))
853
+ return null;
854
+ const word = context.matchBefore(/[\w'\xa1-￿]+/);
855
+ if (!word && !context.explicit)
856
+ return null;
857
+ const from = word ? word.from : context.pos;
858
+ if (afterDot(context, from))
859
+ return null;
860
+ let options = [];
861
+ for (let pos = inner; pos; pos = pos.parent)
862
+ if (ScopeNodes.has(pos.name))
863
+ options = options.concat(getScope(context.state.doc, pos));
864
+ return { options, from, validFor: Identifier };
865
+ };
866
+ /// Completes a field name after `record.`, from the record fields declared
867
+ /// and written in the file.
868
+ const fieldCompletionSource = (context) => {
869
+ const word = context.matchBefore(/[\w'\xa1-￿]*/);
870
+ const from = word ? word.from : context.pos;
871
+ const before = context.state.sliceDoc(Math.max(0, from - 2), from);
872
+ if (before.length < 2 || before[1] != "." || !/[\w')\]}]/.test(before[0]))
873
+ return null;
874
+ const tree = syntaxTree(context.state);
875
+ if (dontComplete.includes(tree.resolveInner(context.pos, -1).name))
876
+ return null;
877
+ const seen = new Set();
878
+ const options = [];
879
+ tree.iterate({
880
+ enter(node) {
881
+ if (node.name != "PropertyName" || (node.from <= context.pos && node.to >= context.pos))
882
+ return;
883
+ const label = context.state.sliceDoc(node.from, node.to);
884
+ if (seen.has(label))
885
+ return;
886
+ seen.add(label);
887
+ options.push({ label, type: "property" });
888
+ },
889
+ });
890
+ return { options, from, validFor: Identifier };
891
+ };
892
+ /// Keywords, snippets, and the functions, types and constructors from Prelude
893
+ /// and the most common modules. It offers nothing in strings and comments, or
894
+ /// after a dot.
895
+ const purescriptCompletion = ifNotIn(dontComplete, (context) => {
896
+ const word = context.matchBefore(/[\w'\xa1-￿]+/);
897
+ if (word && afterDot(context, word.from))
898
+ return null;
899
+ if (!word && context.matchBefore(/\.$/))
900
+ return null;
901
+ return completeFromList(globals)(context);
902
+ });
903
+
904
+ // Folding a block keeps its first line in view, which is the line that says
905
+ // what was folded away.
906
+ function foldBody(node, state) {
907
+ const line = state.doc.lineAt(node.from);
908
+ return node.to > line.to ? { from: line.to, to: node.to } : null;
909
+ }
910
+ // The tree can't say where a new line belongs, because a block ends at its last
911
+ // token and the new line is past that. So the line above decides. If it opens a
912
+ // block or leaves an expression unfinished, the new line is indented one step
913
+ // further. Otherwise the new line keeps the same indentation.
914
+ const opensBlock = /(^|[^\w'])(do|ado|where|of|let)$/;
915
+ const continuesLine = /(=|->|<-|=>|\$|#|\||,|\(|\[|\{|`|::|\bif|\bthen|\belse|\bcase)$/;
916
+ const wantsIndent = /^\s*(where|then|else)\b/;
917
+ const indentPurescript = indentService.of((context, pos) => {
918
+ const inside = syntaxTree(context.state).resolveInner(pos, -1).name;
919
+ if (inside == "BlockComment" || inside == "DocComment")
920
+ return null;
921
+ let line = context.lineAt(pos, -1);
922
+ while (!/\S/.test(line.text) && line.from > 0)
923
+ line = context.lineAt(line.from - 1, -1);
924
+ if (!/\S/.test(line.text))
925
+ return 0;
926
+ const code = line.text.replace(/\s*--(\s.*|-*)$/, "").trimEnd();
927
+ const base = context.lineIndent(line.from);
928
+ if (opensBlock.test(code) || continuesLine.test(code))
929
+ return base + context.unit;
930
+ if (wantsIndent.test(context.state.doc.sliceString(pos, pos + 20)))
931
+ return base + context.unit;
932
+ return base;
933
+ });
934
+ const purescriptLanguage = LRLanguage.define({
935
+ name: "purescript",
936
+ parser: parser.configure({
937
+ props: [
938
+ foldNodeProp.add({
939
+ "WhereBlock DoExpression AdoExpression CaseExpression LetExpression LetStatement": foldBody,
940
+ "DataDeclaration ClassDeclaration InstanceDeclaration Bind ExportList": foldBody,
941
+ "Record RecordType BlockComment DocComment": foldBody,
942
+ }),
943
+ styleTags({
944
+ "module import": tags.moduleKeyword,
945
+ "data newtype type class instance derive foreign": tags.definitionKeyword,
946
+ "where let in of": tags.definitionKeyword,
947
+ "case if then else do ado": tags.controlKeyword,
948
+ "infix infixl infixr as hiding kind forall": tags.keyword,
949
+ Boolean: tags.bool,
950
+ Number: tags.number,
951
+ String: tags.string,
952
+ Char: tags.character,
953
+ Wildcard: tags.atom,
954
+ "Hole/Variable": tags.special(tags.variableName),
955
+ "?": tags.special(tags.variableName),
956
+ LineComment: tags.lineComment,
957
+ BlockComment: tags.blockComment,
958
+ DocComment: tags.docComment,
959
+ Qualifier: tags.namespace,
960
+ OperatorQualifier: tags.namespace,
961
+ ModuleName: tags.namespace,
962
+ "ModuleName/Qualifier": tags.namespace,
963
+ DeclName: tags.definition(tags.variableName),
964
+ "Bind/DeclName": tags.definition(tags.function(tags.variableName)),
965
+ PropertyName: tags.propertyName,
966
+ "FieldDeclaration/PropertyName": tags.definition(tags.propertyName),
967
+ "Callee/Variable": tags.function(tags.variableName),
968
+ Variable: tags.variableName,
969
+ Constructor: tags.className,
970
+ TypeConstructor: tags.typeName,
971
+ TypeVariable: tags.typeName,
972
+ "Operator ConstructorOperator BacktickOperator": tags.operator,
973
+ "TypeOperator TypeConstructorOperator": tags.typeOperator,
974
+ "= <-": tags.definitionOperator,
975
+ ":: -> =>": tags.typeOperator,
976
+ '| @ \\ ":"': tags.operator,
977
+ fieldDot: tags.derefOperator,
978
+ "` ,": tags.separator,
979
+ "( )": tags.paren,
980
+ "[ ]": tags.squareBracket,
981
+ "{ }": tags.brace,
982
+ }),
983
+ ],
984
+ }),
985
+ languageData: {
986
+ commentTokens: { line: "--", block: { open: "{-", close: "-}" } },
987
+ closeBrackets: { brackets: ["(", "[", "{", '"'] },
988
+ indentOnInput: /^\s*(where|in|then|else|of)$/,
989
+ },
990
+ });
991
+ /// PureScript language support, with completion for keywords, snippets,
992
+ /// common library names, record fields and the names declared in the file.
993
+ function purescript() {
994
+ return new LanguageSupport(purescriptLanguage, [
995
+ indentPurescript,
996
+ purescriptLanguage.data.of({ autocomplete: purescriptCompletion }),
997
+ purescriptLanguage.data.of({ autocomplete: localCompletionSource }),
998
+ purescriptLanguage.data.of({ autocomplete: fieldCompletionSource }),
999
+ ]);
1000
+ }
1001
+
1002
+ export { fieldCompletionSource, localCompletionSource, parser, purescript, purescriptCompletion, purescriptLanguage, snippets };