@willbooster/tree-sitter-haskell 0.0.0-stage → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,76 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-haskell",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "Haskell grammar for tree-sitter",
5
+ "keywords": [
6
+ "incremental",
7
+ "parsing",
8
+ "tree-sitter",
9
+ "haskell"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/WillBooster/tree-sitter-haskell.git"
14
+ },
15
+ "license": "MIT",
16
+ "author": "WillBooster Inc.",
17
+ "files": [
18
+ "grammar.js",
19
+ "grammar/*.js",
20
+ "queries/*.scm",
21
+ "src/node-types.json",
22
+ "tree-sitter.json",
23
+ "*.wasm"
24
+ ],
25
+ "scripts": {
26
+ "build-wasm": "script/generate --build-wasm",
27
+ "build/ci": "bun run build-wasm",
28
+ "cleanup": "bun wb lint --fix --format",
29
+ "format": "bun wb lint --format",
30
+ "generate": "script/generate",
31
+ "lint": "bun wb lint",
32
+ "lint-fix": "bun wb lint --fix",
33
+ "prepare": "(bun lefthook install || true) && (test ! -f .lefthook/normalize-bun-lockfile.sh || bash .lefthook/normalize-bun-lockfile.sh)",
34
+ "release": "wb release",
35
+ "prestart": "bun run build-wasm",
36
+ "start": "script/tree-sitter playground",
37
+ "test": "bun wb test",
38
+ "test/ci": "bun wb test-on-ci",
39
+ "test/ci-setup": "playwright install --with-deps chromium",
40
+ "typecheck": "bun wb typecheck",
41
+ "verify": "bun wb verify",
42
+ "verify-full": "bun wb verify --full"
43
+ },
44
+ "devDependencies": {
45
+ "@tsconfig/bun": "1.0.11",
46
+ "@types/bun": "1.4.2",
47
+ "@vitest/browser-playwright": "5.0.3",
48
+ "@willbooster/oxfmt-config": "1.2.2",
49
+ "@willbooster/oxlint-config": "1.4.8",
50
+ "@willbooster/wb": "22.24.0",
51
+ "@willbooster/web-tree-sitter": "2.0.2",
52
+ "conventional-changelog-conventionalcommits": "10.4.0",
53
+ "lefthook": "2.1.16",
54
+ "oxfmt": "0.71.0",
55
+ "oxlint": "1.86.0",
56
+ "oxlint-tsgolint": "7.0.2003",
57
+ "playwright": "1.63.0",
58
+ "semantic-release": "25.0.9",
59
+ "sort-package-json": "4.0.0",
60
+ "typescript": "7.0.2",
61
+ "vitest": "5.0.3",
62
+ "wrangler": "4.147.0"
63
+ },
64
+ "peerDependencies": {
65
+ "@willbooster/web-tree-sitter": "^2.0.0"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "@willbooster/web-tree-sitter": {
69
+ "optional": true
70
+ }
71
+ },
72
+ "publishConfig": {
73
+ "access": "public",
74
+ "registry": "https://registry.npmjs.org/"
75
+ }
76
+ }
@@ -0,0 +1,448 @@
1
+ ; ----------------------------------------------------------------------------
2
+ ; Parameters and variables
3
+ ; NOTE: These are at the top, so that they have low priority,
4
+ ; and don't override destructured parameters
5
+ (variable) @variable
6
+
7
+ (pattern/wildcard) @variable
8
+
9
+ (decl/function
10
+ patterns: (patterns
11
+ (_) @variable.parameter))
12
+
13
+ (expression/lambda
14
+ (_)+ @variable.parameter
15
+ "->")
16
+
17
+ (decl/function
18
+ (infix
19
+ (pattern) @variable.parameter))
20
+
21
+ ; ----------------------------------------------------------------------------
22
+ ; Literals and comments
23
+ (integer) @number
24
+
25
+ (negation) @number
26
+
27
+ (expression/literal
28
+ (float)) @number.float
29
+
30
+ (char) @character
31
+
32
+ (string) @string
33
+
34
+ (unit) @string.special.symbol ; unit, as in ()
35
+
36
+ (comment) @comment
37
+
38
+ ((haddock) @comment.documentation)
39
+
40
+ ; ----------------------------------------------------------------------------
41
+ ; Punctuation
42
+ [
43
+ "("
44
+ ")"
45
+ "{"
46
+ "}"
47
+ "["
48
+ "]"
49
+ ] @punctuation.bracket
50
+
51
+ [
52
+ ","
53
+ ";"
54
+ ] @punctuation.delimiter
55
+
56
+ ; ----------------------------------------------------------------------------
57
+ ; Keywords, operators, includes
58
+ [
59
+ "forall"
60
+ ; "∀" ; utf-8 is not cross-platform safe
61
+ ] @keyword.repeat
62
+
63
+ (pragma) @keyword.directive
64
+
65
+ [
66
+ "if"
67
+ "then"
68
+ "else"
69
+ "case"
70
+ "of"
71
+ ] @keyword.conditional
72
+
73
+ [
74
+ "import"
75
+ "qualified"
76
+ "module"
77
+ ] @keyword.import
78
+
79
+ [
80
+ (operator)
81
+ (constructor_operator)
82
+ (all_names)
83
+ (wildcard)
84
+ "."
85
+ ".."
86
+ "="
87
+ "|"
88
+ "::"
89
+ "=>"
90
+ "->"
91
+ "<-"
92
+ "\\"
93
+ "`"
94
+ "@"
95
+ ] @operator
96
+
97
+ ; TODO broken, also huh?
98
+ ; ((qualified_module
99
+ ; (module) @constructor)
100
+ ; .
101
+ ; (module))
102
+
103
+ (module
104
+ (module_id) @module)
105
+
106
+ [
107
+ "where"
108
+ "let"
109
+ "in"
110
+ "class"
111
+ "instance"
112
+ "pattern"
113
+ "data"
114
+ "newtype"
115
+ "family"
116
+ "type"
117
+ "as"
118
+ "hiding"
119
+ "deriving"
120
+ "via"
121
+ "stock"
122
+ "anyclass"
123
+ "do"
124
+ "mdo"
125
+ "rec"
126
+ "infix"
127
+ "infixl"
128
+ "infixr"
129
+ ] @keyword
130
+
131
+ ; ----------------------------------------------------------------------------
132
+ ; Functions and variables
133
+ [
134
+ (decl/function name: (variable) @function)
135
+ (decl/bind name: (variable) @function)
136
+ (decl/signature name: (variable) @function)
137
+ (decl/signature names: (binding_list (variable) @function))
138
+ ]
139
+
140
+ (decl/bind
141
+ name: (variable) @variable)
142
+
143
+ ; Consider signatures (and accompanying functions)
144
+ ; with only one value on the rhs as variables
145
+ (decl/signature
146
+ name: (variable) @variable
147
+ type: (type))
148
+
149
+ ((decl/signature
150
+ name: (variable) @_name
151
+ type: (type))
152
+ .
153
+ [
154
+ (decl/function name: (variable) @variable)
155
+ (decl/bind name: (variable) @variable)
156
+ ]
157
+ match: (_)
158
+ (#eq? @_name @variable))
159
+
160
+ ; but consider a type that involves 'IO' a decl/function
161
+ (decl/signature
162
+ name: (variable) @function
163
+ type: (type/apply
164
+ constructor: (name) @_type)
165
+ (#eq? @_type "IO"))
166
+
167
+ ((decl/signature
168
+ name: (variable) @_name
169
+ type: (type/apply
170
+ constructor: (name) @_type)
171
+ (#eq? @_type "IO"))
172
+ .
173
+ [
174
+ (decl/function name: (variable) @function)
175
+ (decl/bind name: (variable) @function)
176
+ ]
177
+ match: (_)
178
+ (#eq? @_name @function))
179
+
180
+ ((decl/signature) @function
181
+ .
182
+ (decl/function
183
+ name: (variable) @function))
184
+
185
+ (decl/bind
186
+ name: (variable) @function
187
+ (match
188
+ expression: (expression/lambda)))
189
+
190
+ ; view patterns
191
+ (view_pattern
192
+ [
193
+ (expression/variable) @function.call
194
+ (expression/qualified
195
+ (variable) @function.call)
196
+ ])
197
+
198
+ ; consider infix functions as operators
199
+ (infix_id
200
+ [
201
+ (variable) @operator
202
+ (qualified
203
+ (variable) @operator)
204
+ ])
205
+
206
+ ; decl/function calls with an infix operator
207
+ ; e.g. func <$> a <*> b
208
+ (infix
209
+ [
210
+ (variable) @function.call
211
+ (qualified
212
+ ((module) @module
213
+ (variable) @function.call))
214
+ ]
215
+ .
216
+ (operator))
217
+
218
+ ; infix operators applied to variables
219
+ ((expression/variable) @variable
220
+ .
221
+ (operator))
222
+
223
+ ((operator)
224
+ .
225
+ [
226
+ (expression/variable) @variable
227
+ (expression/qualified
228
+ (variable) @variable)
229
+ ])
230
+
231
+ ; decl/function calls with infix operators
232
+ ([
233
+ (expression/variable) @function.call
234
+ (expression/qualified
235
+ (variable) @function.call)
236
+ ]
237
+ .
238
+ (operator) @_op
239
+ (#any-of? @_op "$" "<$>" ">>=" "=<<"))
240
+
241
+ ; right hand side of infix operator
242
+ ((infix
243
+ [
244
+ (operator)
245
+ (infix_id (variable))
246
+ ] ; infix or `func`
247
+ .
248
+ [
249
+ (variable) @function.call
250
+ (qualified
251
+ (variable) @function.call)
252
+ ])
253
+ .
254
+ (operator) @_op
255
+ (#any-of? @_op "$" "<$>" "=<<"))
256
+
257
+ ; decl/function composition, arrows, monadic composition (lhs)
258
+ (
259
+ [
260
+ (expression/variable) @function
261
+ (expression/qualified
262
+ (variable) @function)
263
+ ]
264
+ .
265
+ (operator) @_op
266
+ (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
267
+
268
+ ; right hand side of infix operator
269
+ ((infix
270
+ [
271
+ (operator)
272
+ (infix_id (variable))
273
+ ] ; infix or `func`
274
+ .
275
+ [
276
+ (variable) @function
277
+ (qualified
278
+ (variable) @function)
279
+ ])
280
+ .
281
+ (operator) @_op
282
+ (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
283
+
284
+ ; function composition, arrows, monadic composition (rhs)
285
+ ((operator) @_op
286
+ .
287
+ [
288
+ (expression/variable) @function
289
+ (expression/qualified
290
+ (variable) @function)
291
+ ]
292
+ (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
293
+
294
+ ; function defined in terms of a function composition
295
+ (decl/function
296
+ name: (variable) @function
297
+ (match
298
+ expression: (infix
299
+ operator: (operator) @_op
300
+ (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))))
301
+
302
+ (apply
303
+ [
304
+ (expression/variable) @function.call
305
+ (expression/qualified
306
+ (variable) @function.call)
307
+ ])
308
+
309
+ ; function compositions, in parentheses, applied
310
+ ; lhs
311
+ (apply
312
+ .
313
+ (expression/parens
314
+ (infix
315
+ [
316
+ (variable) @function.call
317
+ (qualified
318
+ (variable) @function.call)
319
+ ]
320
+ .
321
+ (operator))))
322
+
323
+ ; rhs
324
+ (apply
325
+ .
326
+ (expression/parens
327
+ (infix
328
+ (operator)
329
+ .
330
+ [
331
+ (variable) @function.call
332
+ (qualified
333
+ (variable) @function.call)
334
+ ])))
335
+
336
+ ; variables being passed to a function call
337
+ (apply
338
+ (_)
339
+ .
340
+ [
341
+ (expression/variable) @variable
342
+ (expression/qualified
343
+ (variable) @variable)
344
+ ])
345
+
346
+ ; main is always a function
347
+ ; (this prevents `main = undefined` from being highlighted as a variable)
348
+ (decl/bind
349
+ name: (variable) @function
350
+ (#eq? @function "main"))
351
+
352
+ ; scoped function types (func :: a -> b)
353
+ (signature
354
+ pattern: (pattern/variable) @function
355
+ type: (quantified_type))
356
+
357
+ ; signatures that have a function type
358
+ ; + binds that follow them
359
+ (decl/signature
360
+ name: (variable) @function
361
+ type: (quantified_type))
362
+
363
+ ((decl/signature
364
+ name: (variable) @_name
365
+ type: (quantified_type))
366
+ .
367
+ (decl/bind
368
+ (variable) @function)
369
+ (#eq? @function @_name))
370
+
371
+ ; ----------------------------------------------------------------------------
372
+ ; Types
373
+ (name) @type
374
+
375
+ (type/star) @type
376
+
377
+ (variable) @type
378
+
379
+ (constructor) @constructor
380
+
381
+ ; True or False
382
+ ((constructor) @boolean
383
+ (#any-of? @boolean "True" "False"))
384
+
385
+ ; otherwise (= True)
386
+ ((variable) @boolean
387
+ (#eq? @boolean "otherwise"))
388
+
389
+ ; ----------------------------------------------------------------------------
390
+ ; Quasi-quotes
391
+ (quoter) @function.call
392
+
393
+ (quasiquote
394
+ [
395
+ (quoter) @_name
396
+ (_
397
+ (variable) @_name)
398
+ ]
399
+ (#eq? @_name "qq")
400
+ (quasiquote_body) @string)
401
+
402
+ (quasiquote
403
+ (_
404
+ (variable) @_name)
405
+ (#eq? @_name "qq")
406
+ (quasiquote_body) @string)
407
+
408
+ ; namespaced quasi-quoter
409
+ (quasiquote
410
+ (_
411
+ (module) @module
412
+ .
413
+ (variable) @function.call))
414
+
415
+ ; Highlighting of quasiquote_body for other languages is handled by injections.scm
416
+ ; ----------------------------------------------------------------------------
417
+ ; Exceptions/error handling
418
+ ((variable) @keyword.exception
419
+ (#any-of? @keyword.exception
420
+ "error" "undefined" "try" "tryJust" "tryAny" "catch" "catches" "catchJust" "handle" "handleJust"
421
+ "throw" "throwIO" "throwTo" "throwError" "ioError" "mask" "mask_" "uninterruptibleMask"
422
+ "uninterruptibleMask_" "bracket" "bracket_" "bracketOnErrorSource" "finally" "fail"
423
+ "onException" "expectationFailure"))
424
+
425
+ ; ----------------------------------------------------------------------------
426
+ ; Debugging
427
+ ((variable) @keyword.debug
428
+ (#any-of? @keyword.debug
429
+ "trace" "traceId" "traceShow" "traceShowId" "traceWith" "traceShowWith" "traceStack" "traceIO"
430
+ "traceM" "traceShowM" "traceEvent" "traceEventWith" "traceEventIO" "flushEventLog" "traceMarker"
431
+ "traceMarkerIO"))
432
+
433
+ ; ----------------------------------------------------------------------------
434
+ ; Fields
435
+
436
+ (field_name
437
+ (variable) @variable.member)
438
+
439
+ (import_name
440
+ (name)
441
+ .
442
+ (children
443
+ (variable) @variable.member))
444
+
445
+
446
+ ; ----------------------------------------------------------------------------
447
+ ; Spell checking
448
+ (comment) @spell
@@ -0,0 +1,76 @@
1
+ ; -----------------------------------------------------------------------------
2
+ ; General language injection
3
+ (quasiquote
4
+ (quoter) @injection.language
5
+ (quasiquote_body) @injection.content)
6
+
7
+ ((comment) @injection.content
8
+ (#set! injection.language "comment"))
9
+
10
+ ; -----------------------------------------------------------------------------
11
+ ; shakespeare library
12
+ ; NOTE: doesn't support templating
13
+ ; TODO: add once CoffeeScript parser is added
14
+ ; ; CoffeeScript: Text.Coffee
15
+ ; (quasiquote
16
+ ; (quoter) @_name
17
+ ; (#eq? @_name "coffee")
18
+ ; ((quasiquote_body) @injection.content
19
+ ; (#set! injection.language "coffeescript")))
20
+ ; CSS: Text.Cassius, Text.Lucius
21
+ (quasiquote
22
+ (quoter) @_name
23
+ (#any-of? @_name "cassius" "lucius")
24
+ (quasiquote_body) @injection.content
25
+ (#set! injection.language "css"))
26
+
27
+ ; HTML: Text.Hamlet
28
+ (quasiquote
29
+ (quoter) @_name
30
+ (#any-of? @_name "shamlet" "xshamlet" "hamlet" "xhamlet" "ihamlet")
31
+ (quasiquote_body) @injection.content
32
+ (#set! injection.language "html"))
33
+
34
+ ; JS: Text.Julius
35
+ (quasiquote
36
+ (quoter) @_name
37
+ (#any-of? @_name "js" "julius")
38
+ (quasiquote_body) @injection.content
39
+ (#set! injection.language "javascript"))
40
+
41
+ ; TS: Text.TypeScript
42
+ (quasiquote
43
+ (quoter) @_name
44
+ (#any-of? @_name "tsc" "tscJSX")
45
+ (quasiquote_body) @injection.content
46
+ (#set! injection.language "typescript"))
47
+
48
+ ; -----------------------------------------------------------------------------
49
+ ; HSX
50
+ (quasiquote
51
+ (quoter) @_name
52
+ (#eq? @_name "hsx")
53
+ (quasiquote_body) @injection.content
54
+ (#set! injection.language "html"))
55
+
56
+ ; -----------------------------------------------------------------------------
57
+ ; Inline JSON from aeson
58
+ (quasiquote
59
+ (quoter) @_name
60
+ (#eq? @_name "aesonQQ")
61
+ (quasiquote_body) @injection.content
62
+ (#set! injection.language "json"))
63
+
64
+ ; -----------------------------------------------------------------------------
65
+ ; SQL
66
+ ; postgresql-simple
67
+ (quasiquote
68
+ (quoter) @injection.language
69
+ (#eq? @injection.language "sql")
70
+ (quasiquote_body) @injection.content)
71
+
72
+ (quasiquote
73
+ (quoter) @_name
74
+ (#any-of? @_name "persistUpperCase" "persistLowerCase" "persistWith")
75
+ (quasiquote_body) @injection.content
76
+ (#set! injection.language "haskell_persistent"))
@@ -0,0 +1,4 @@
1
+ (signature name: (variable)) @local.definition
2
+ (function name: (variable)) @local.definition
3
+ (pattern/variable) @local.definition
4
+ (expression/variable) @local.reference