@willbooster/tree-sitter-haskell 6.0.4 → 7.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/README.md CHANGED
@@ -29,10 +29,6 @@ The fork's main differences from upstream 0.23.1 are:
29
29
  Unmarked continuation lines remain in their preceding Haddock block, including space or tab indentation and LF or CRLF newlines.
30
30
  First-column ordinary comments combine with LF line endings.
31
31
  CRLF and indented ordinary comments remain separate comment nodes.
32
- - **`queries/highlights.scm`**: three patterns that match fields of the supertype `decl` are written through its
33
- subtypes (`decl/function`, `decl/bind`, `decl/signature`), as upstream's repository has them since
34
- `tree-sitter/tree-sitter-haskell@0b2ebf7`. A parser of ABI 15 or later carries the supertypes, and the runtime then
35
- rejects the 0.23.1 patterns as impossible; upstream's own CLI 0.27.0 does so as well.
36
32
  - **`test/corpus/varsym.txt`**: the expected recovery tree for the invalid `f = a | a` input matches this generator; the input still reports an error.
37
33
  - **`test/corpus/null-characters.txt`** is added, because the fuzz job checks that every NUL character of the corpus
38
34
  reaches the fuzz seeds and upstream's corpus has none.
@@ -83,12 +79,14 @@ parser.setLanguage(await Language.load(haskell));
83
79
 
84
80
  The package also ships `grammar.js` with the files in `grammar/` it loads, the queries in `queries/`, and the node types in `src/node-types.json`.
85
81
 
86
- For code navigation, use `queries/tags.scm` (or `TAGS_QUERY` in Rust). It indexes module headers, top-level named functions and simple named bindings, named types and classes, class and instance methods, and syntactic variable/operator calls. A signature and each equation have separate definition locations. Call references identify the called name without resolving its binding.
82
+ For code navigation, use `queries/tags.scm` (or `TAGS_QUERY` in Rust). It indexes module headers, top-level named functions and bindings, named types and classes, class and instance methods, and syntactic variable/operator calls. A signature and each equation have separate definition locations. Call references identify the called name without resolving its binding.
87
83
 
88
- Declaration names and variable/operator callees remain indexed through nested parentheses. Class and instance equations retain their method roles; grouping a value without applying it does not create a call reference. Destructuring bindings, local pattern bindings and constructors (including pattern synonyms) are not indexed.
84
+ Declaration names and variable/operator callees remain indexed through nested parentheses. Class and instance equations retain their method roles; grouping a value without applying it does not create a call reference. Destructuring bindings contribute their explicit names at every nesting depth, including as-pattern binders and record puns. Local pattern bindings, names bound by patterns inside declaration quotes and constructors (including pattern synonyms) are not indexed.
89
85
 
90
86
  Function and type declaration-head parentheses are anonymous syntax: the enclosing declaration directly exposes its `name`, parameter groups and infix `head` fields. Parentheses inside parameters and types retain their existing nodes. A grouped variable name, including a qualified name, uses one `parenthesized_name` node with a direct name child, independent of grouping depth. A symbolic variable operator keeps its required prefix parentheses in `prefix_id`: `(<+>)` and `(Demo.<+>)` remain `prefix_id`, while redundant grouping such as `((<+>))` adds one `parenthesized_name` wrapper around that node. This also applies to unapplied names; only function position creates a call reference or call highlight. A parenthesized simple binding name uses `parenthesized_name` in the `bind` node's `name` field, retaining one wrapper at any grouping depth. Complex expressions retain ordinary `parens` nodes. These changes affect public syntax trees.
91
87
 
88
+ Module binding patterns use the `binding_pattern` supertype; ordinary patterns use `pattern`. Both retain the same concrete node names. A `binding_field_pattern/field_pattern` with a `field` field and no `pattern` field is a module binding record pun. The `decl` supertype covers bindings in local blocks and declaration quotes; module declarations use `declaration`.
89
+
92
90
  In a repository checkout, configure the CLI parser directories to include the grammar, then run `script/tree-sitter tags file.hs` to inspect the tags.
93
91
 
94
92
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-haskell) and on
@@ -98,7 +96,7 @@ fuzzed with:
98
96
  ```toml
99
97
  [dependencies]
100
98
  tree-sitter = { package = "willbooster-tree-sitter", version = "7.0.5" }
101
- tree-sitter-haskell = { package = "willbooster-tree-sitter-haskell", version = "6" }
99
+ tree-sitter-haskell = { package = "willbooster-tree-sitter-haskell", version = "7" }
102
100
  ```
103
101
 
104
102
  ```rust
@@ -5,16 +5,24 @@ module.exports = {
5
5
  // disambiguates expressions, patterns and declaration heads after parsing; these alternatives must remain
6
6
  // available until following syntax determines their role, including for top-level expression splices.
7
7
  [$._function_name, $.pattern],
8
+ [$._function_name, $.pattern, $.binding_pattern],
8
9
  [$._function_name, $.pattern, $.expression],
9
- [$._grouped_name, $._function_name, $.pattern, $.expression],
10
+ [$._function_name, $.pattern, $.binding_pattern, $.expression],
10
11
  [$._grouped_name, $.expression],
11
12
  [$._grouped_name, $.pattern, $.expression],
13
+ [$._grouped_name, $.binding_pattern, $.expression],
14
+ [$._grouped_name, $.pattern, $.binding_pattern, $.expression],
12
15
  [$._grouped_name, $.expression, $.pattern, $._function_name, $._binding_name_parens],
16
+ [$._grouped_name, $.expression, $.pattern, $.binding_pattern, $._function_name, $._binding_name_parens],
13
17
  [$.pattern, $._function_name, $._binding_name_parens],
14
18
  [$.pattern, $._binding_name_parens],
15
19
  [$._grouped_name, $.expression, $.pattern, $._binding_name_parens],
16
20
  [$.pattern, $.expression],
21
+ [$.binding_pattern, $.expression],
22
+ [$.pattern, $.binding_pattern, $.expression],
23
+ [$.pattern, $.binding_pattern],
17
24
  [$.signature, $.pattern],
25
+ [$.signature, $.binding_pattern],
18
26
  // The hash opening an unboxed tuple can also begin a symbolic operator.
19
27
  [$._operator_hash_head, $._unboxed_open],
20
28
  ],
package/grammar/decl.js CHANGED
@@ -5,6 +5,16 @@ const {
5
5
  layout,
6
6
  } = require('./util.js')
7
7
 
8
+ const binding = ($, pattern) => prec('bind', seq(
9
+ choice(
10
+ field('pattern', pattern),
11
+ field('name', $._var),
12
+ field('name', alias($._binding_name_parens, $.parenthesized_name)),
13
+ field('implicit', $.implicit_variable),
14
+ ),
15
+ $._bind_matches,
16
+ ))
17
+
8
18
  module.exports = {
9
19
 
10
20
  // ------------------------------------------------------------------------
@@ -112,15 +122,15 @@ module.exports = {
112
122
  * The `implicit_variable` here is for:
113
123
  * g = let ?par = Impy 5 in f
114
124
  */
115
- bind: $ => prec('bind', seq(
116
- choice(
117
- field('pattern', $._pat),
118
- field('name', $._var),
119
- field('name', alias($._binding_name_parens, $.parenthesized_name)),
120
- field('implicit', $.implicit_variable),
121
- ),
122
- $._bind_matches,
123
- )),
125
+ bind: $ => binding($, $._pat),
126
+
127
+ _module_bind: $ => binding($, $._binding_pat),
128
+
129
+ _module_decl: $ => choice(
130
+ $.signature,
131
+ $.function,
132
+ alias($._module_bind, $.bind),
133
+ ),
124
134
 
125
135
  decl: $ => choice(
126
136
  $.signature,
package/grammar/inline.js CHANGED
@@ -56,6 +56,9 @@ module.exports = {
56
56
  $._pat_name,
57
57
  $._pat_texp,
58
58
  $._pat_wildcard,
59
+ $._binding_pat_apply_arg,
60
+ $._binding_pat_name,
61
+ $._binding_pat_texp,
59
62
 
60
63
  // ------------------------------------------------
61
64
  // type
package/grammar/module.js CHANGED
@@ -7,6 +7,28 @@ const {
7
7
  semis,
8
8
  } = require('./util.js')
9
9
 
10
+ const declaration = ($, bindings) => choice(
11
+ bindings,
12
+ $.type_synonym,
13
+ $.kind_signature,
14
+ $.type_family,
15
+ $.type_instance,
16
+ $.role_annotation,
17
+ $.data_type,
18
+ $.newtype,
19
+ $.data_family,
20
+ $.data_instance,
21
+ $.class,
22
+ $.instance,
23
+ $.default_types,
24
+ $.deriving_instance,
25
+ $.pattern_synonym,
26
+ $.foreign_import,
27
+ $.foreign_export,
28
+ $.fixity,
29
+ $.top_splice,
30
+ )
31
+
10
32
  module.exports = {
11
33
 
12
34
  // ------------------------------------------------------------------------
@@ -122,29 +144,8 @@ module.exports = {
122
144
  alias($._cond_layout_end_explicit, '}'),
123
145
  ),
124
146
 
125
- /**
126
- * This is a supertype.
127
- */
128
- declaration: $ => choice(
129
- $.decl,
130
- $.type_synonym,
131
- $.kind_signature,
132
- $.type_family,
133
- $.type_instance,
134
- $.role_annotation,
135
- $.data_type,
136
- $.newtype,
137
- $.data_family,
138
- $.data_instance,
139
- $.class,
140
- $.instance,
141
- $.default_types,
142
- $.deriving_instance,
143
- $.pattern_synonym,
144
- $.foreign_import,
145
- $.foreign_export,
146
- $.fixity,
147
- $.top_splice,
148
- ),
147
+ declaration: $ => declaration($, $._module_decl),
148
+
149
+ _quoted_declaration: $ => declaration($, $.decl),
149
150
 
150
151
  }
package/grammar/pat.js CHANGED
@@ -9,141 +9,161 @@ const {
9
9
  unboxed_sum_single,
10
10
  } = require('./util.js')
11
11
 
12
- module.exports = {
12
+ const patternRules = (name, recordField) => {
13
+ const rule = ($, key) => $[name(key)]
14
+ return {
15
+
16
+ // ------------------------------------------------------------------------
17
+ // tuples and parens
18
+ // ------------------------------------------------------------------------
19
+
20
+ [name('_pat_parens')]: $ => parens($, field('pattern', rule($, '_pat_texp'))),
21
+
22
+ [name('_pat_tuple_elems')]: $ => sep2(',', field('element', rule($, '_pat_texp'))),
23
+
24
+ [name('_pat_tuple')]: $ => parens($, rule($, '_pat_tuple_elems')),
25
+
26
+ [name('_pat_unboxed_tuple')]: $ => unboxed_tuple_full($, rule($, '_pat_texp')),
13
27
 
14
- // ------------------------------------------------------------------------
15
- // tuples and parens
16
- // ------------------------------------------------------------------------
17
-
18
- _pat_parens: $ => parens($, field('pattern', $._pat_texp)),
19
-
20
- _pat_tuple_elems: $ => sep2(',', field('element', $._pat_texp)),
21
-
22
- _pat_tuple: $ => parens($, $._pat_tuple_elems),
23
-
24
- _pat_unboxed_tuple: $ => unboxed_tuple_full($, $._pat_texp),
25
-
26
- _pat_unboxed_sum: $ => unboxed_sum_single($, $._pat_texp),
27
-
28
- _pat_list: $ => brackets($, sep1(',', field('element', $._pat_texp)), optional(',')),
29
-
30
- // ------------------------------------------------------------------------
31
- // record
32
- // ------------------------------------------------------------------------
33
-
34
- field_pattern: $ => choice(
35
- alias('..', $.wildcard),
36
- seq(field('field', $._field_names), optional(seq('=', field('pattern', $._pat_texp)))),
37
- ),
38
-
39
- _pat_record: $ => prec('record', seq(
40
- field('constructor', $.pattern),
41
- braces($, sep(',', field('field', $.field_pattern))),
42
- )),
43
-
44
- // ------------------------------------------------------------------------
45
- // misc
46
- // ------------------------------------------------------------------------
47
-
48
- /**
49
- * This dynamic precedence penalty is relevant for the conflict between `function` and `bind`.
50
- * Consider:
51
- *
52
- * > f (A a) = exp
53
- *
54
- * Because of the "single choice disambiguated with named precedences" approach used for `pattern`, the left node in
55
- * `pat_apply` can be a variable, even though it's not valid Haskell.
56
- * While the static prec 'pat-name' covers this at generation time, Haskell's ambiguity requires us to use a runtime
57
- * conflict for `function`/`bind`, where static prec is ineffective.
58
- * Giving the reduction of `_var` to `pattern` a strong negative dynamic prec ensures that the runtime branch for
59
- * `bind` has lower precedence because of `f`, so `function` always wins.
60
- *
61
- * While `bind` usually has a lower score than `function` anyway in this situation because it is slightly more
62
- * complex, there are never any guarantees for runtime conflicts.
63
- * In particular, the presence of minor parse errors later in the declaration can tip the scales randomly.
64
- */
65
- _pat_name: $ => choice(
66
- prec('pat-name', prec.dynamic(-1000, $._var)),
67
- $._cons,
68
- ),
69
-
70
- _pat_as: $ => prec('prefix', seq(field('bind', $.variable), $._tight_at, field('pattern', $.pattern))),
71
-
72
- _pat_wildcard: _ => '_',
73
-
74
- _pat_strict: $ => prec('prefix', seq($._any_prefix_bang, field('pattern', $.pattern))),
75
-
76
- _pat_irrefutable: $ => prec('prefix', seq($._any_prefix_tilde, field('pattern', $.pattern))),
77
-
78
- // ------------------------------------------------------------------------
79
- // application
80
- // ------------------------------------------------------------------------
81
-
82
- _pat_apply_arg: $ => choice(
83
- $.pattern,
84
- alias($._at_type, $.type_binder),
85
- $.explicit_type,
86
- ),
87
-
88
- _pat_apply: $ => prec.left('apply', seq(
89
- field('function', $.pattern),
90
- field('argument', $._pat_apply_arg),
91
- )),
92
-
93
- // ------------------------------------------------------------------------
94
- // operators
95
- // ------------------------------------------------------------------------
96
-
97
- _pat_negation: $ => seq('-', field('number', $._number)),
98
-
99
- _pat_infix: $ => prec.right('infix', seq(
100
- field('left_operand', $.pattern),
101
- optional($._cond_no_section_op),
102
- field('operator', choice(
103
- $.constructor_operator,
104
- $._conids_ticked,
105
- seq($._cond_qualified_op, $._qconsym),
28
+ [name('_pat_unboxed_sum')]: $ => unboxed_sum_single($, rule($, '_pat_texp')),
29
+
30
+ [name('_pat_list')]: $ => brackets($, sep1(',', field('element', rule($, '_pat_texp'))), optional(',')),
31
+
32
+ // ------------------------------------------------------------------------
33
+ // record
34
+ // ------------------------------------------------------------------------
35
+
36
+ [name('_pat_record')]: $ => prec('record', seq(
37
+ field('constructor', rule($, 'pattern')),
38
+ braces($, sep(',', field('field', recordField($)))),
106
39
  )),
107
- field('right_operand', $.pattern),
108
- )),
109
-
110
- // ------------------------------------------------------------------------
111
- // top level
112
- // ------------------------------------------------------------------------
113
-
114
- pattern: $ => choice(
115
- alias($._pat_infix, $.infix),
116
- alias($._pat_negation, $.negation),
117
- alias($._pat_apply, $.apply),
118
- $._pat_name,
119
- alias($._pat_as, $.as),
120
- alias($._pat_record, $.record),
121
- alias($._pat_wildcard, $.wildcard),
122
- alias($._pat_parens, $.parens),
123
- alias($._pat_tuple, $.tuple),
124
- alias($._pat_unboxed_tuple, $.unboxed_tuple),
125
- alias($._pat_unboxed_sum, $.unboxed_sum),
126
- alias($._pat_list, $.list),
127
- alias($._plist, $.list),
128
- alias($._pat_strict, $.strict),
129
- alias($._pat_irrefutable, $.irrefutable),
130
- $._universal,
131
- ),
132
40
 
133
- patterns: $ => repeat1(prec('patterns', $._pat_apply_arg)),
41
+ // ------------------------------------------------------------------------
42
+ // misc
43
+ // ------------------------------------------------------------------------
44
+
45
+ /**
46
+ * This dynamic precedence penalty is relevant for the conflict between `function` and `bind`.
47
+ * Consider:
48
+ *
49
+ * > f (A a) = exp
50
+ *
51
+ * Because of the "single choice disambiguated with named precedences" approach used for `pattern`, the left node in
52
+ * `pat_apply` can be a variable, even though it's not valid Haskell.
53
+ * While the static prec 'pat-name' covers this at generation time, Haskell's ambiguity requires us to use a runtime
54
+ * conflict for `function`/`bind`, where static prec is ineffective.
55
+ * Giving the reduction of `_var` to `pattern` a strong negative dynamic prec ensures that the runtime branch for
56
+ * `bind` has lower precedence because of `f`, so `function` always wins.
57
+ *
58
+ * While `bind` usually has a lower score than `function` anyway in this situation because it is slightly more
59
+ * complex, there are never any guarantees for runtime conflicts.
60
+ * In particular, the presence of minor parse errors later in the declaration can tip the scales randomly.
61
+ */
62
+ [name('_pat_name')]: $ => choice(
63
+ prec('pat-name', prec.dynamic(-1000, $._var)),
64
+ $._cons,
65
+ ),
66
+
67
+ [name('_pat_as')]: $ => prec('prefix', seq(field('bind', $.variable), $._tight_at, field('pattern', rule($, 'pattern')))),
68
+
69
+ [name('_pat_wildcard')]: _ => '_',
70
+
71
+ [name('_pat_strict')]: $ => prec('prefix', seq($._any_prefix_bang, field('pattern', rule($, 'pattern')))),
72
+
73
+ [name('_pat_irrefutable')]: $ => prec('prefix', seq($._any_prefix_tilde, field('pattern', rule($, 'pattern')))),
74
+
75
+ // ------------------------------------------------------------------------
76
+ // application
77
+ // ------------------------------------------------------------------------
78
+
79
+ [name('_pat_apply_arg')]: $ => choice(
80
+ rule($, 'pattern'),
81
+ alias($._at_type, $.type_binder),
82
+ $.explicit_type,
83
+ ),
84
+
85
+ [name('_pat_apply')]: $ => prec.left('apply', seq(
86
+ field('function', rule($, 'pattern')),
87
+ field('argument', rule($, '_pat_apply_arg')),
88
+ )),
134
89
 
135
- _pat_signature: $ => prec.right('annotated', seq(
136
- field('pattern', $.pattern),
137
- $._type_annotation,
138
- )),
90
+ // ------------------------------------------------------------------------
91
+ // operators
92
+ // ------------------------------------------------------------------------
93
+
94
+ [name('_pat_negation')]: $ => seq('-', field('number', $._number)),
95
+
96
+ [name('_pat_infix')]: $ => prec.right('infix', seq(
97
+ field('left_operand', rule($, 'pattern')),
98
+ optional($._cond_no_section_op),
99
+ field('operator', choice(
100
+ $.constructor_operator,
101
+ $._conids_ticked,
102
+ seq($._cond_qualified_op, $._qconsym),
103
+ )),
104
+ field('right_operand', rule($, 'pattern')),
105
+ )),
106
+
107
+ // ------------------------------------------------------------------------
108
+ // top level
109
+ // ------------------------------------------------------------------------
110
+
111
+ [name('pattern')]: $ => choice(
112
+ alias(rule($, '_pat_infix'), $.infix),
113
+ alias(rule($, '_pat_negation'), $.negation),
114
+ alias(rule($, '_pat_apply'), $.apply),
115
+ rule($, '_pat_name'),
116
+ alias(rule($, '_pat_as'), $.as),
117
+ alias(rule($, '_pat_record'), $.record),
118
+ alias(rule($, '_pat_wildcard'), $.wildcard),
119
+ alias(rule($, '_pat_parens'), $.parens),
120
+ alias(rule($, '_pat_tuple'), $.tuple),
121
+ alias(rule($, '_pat_unboxed_tuple'), $.unboxed_tuple),
122
+ alias(rule($, '_pat_unboxed_sum'), $.unboxed_sum),
123
+ alias(rule($, '_pat_list'), $.list),
124
+ alias($._plist, $.list),
125
+ alias(rule($, '_pat_strict'), $.strict),
126
+ alias(rule($, '_pat_irrefutable'), $.irrefutable),
127
+ $._universal,
128
+ ),
129
+
130
+ [name('_pat_signature')]: $ => prec.right('annotated', seq(
131
+ field('pattern', rule($, 'pattern')),
132
+ $._type_annotation,
133
+ )),
139
134
 
140
- _pat: $ => choice(
141
- alias($._pat_signature, $.signature),
142
- prec.right($.pattern),
143
- ),
135
+ [name('_pat')]: $ => choice(
136
+ alias(rule($, '_pat_signature'), $.signature),
137
+ prec.right(rule($, 'pattern')),
138
+ ),
144
139
 
145
- view_pattern: $ => seq(field('expression', $._exp), $._arrow, field('pattern', $._pat_texp)),
140
+ [name('view_pattern')]: $ => seq(field('expression', $._exp), $._arrow, field('pattern', rule($, '_pat_texp'))),
146
141
 
147
- _pat_texp: $ => choice($.view_pattern, $._pat),
142
+ [name('_pat_texp')]: $ => choice(
143
+ alias(rule($, 'view_pattern'), $.view_pattern),
144
+ rule($, '_pat'),
145
+ ),
148
146
 
147
+ }
148
+ }
149
+
150
+ const bindingRuleName = name => {
151
+ if (['_pat_negation', '_pat_wildcard'].includes(name)) return name
152
+ if (name === 'view_pattern') return '_binding_view_pattern'
153
+ return name.startsWith('_') ? `_binding${name}` : `binding_${name}`
154
+ }
155
+
156
+ const recordField = ($, pattern) => choice(
157
+ alias('..', $.wildcard),
158
+ seq(field('field', $._field_names), optional(seq('=', field('pattern', pattern)))),
159
+ )
160
+
161
+ module.exports = {
162
+ ...patternRules(name => name, $ => $.field_pattern),
163
+ ...patternRules(bindingRuleName, $ => $.binding_field_pattern),
164
+
165
+ binding_field_pattern: $ => choice(alias($._binding_field_pattern, $.field_pattern)),
166
+ _binding_field_pattern: $ => recordField($, $._binding_pat_texp),
167
+ field_pattern: $ => recordField($, $._pat_texp),
168
+ patterns: $ => repeat1(prec('patterns', $._pat_apply_arg)),
149
169
  }
package/grammar/th.js CHANGED
@@ -51,7 +51,7 @@ module.exports = {
51
51
  choice(token('|]'), '⟧'),
52
52
  ),
53
53
 
54
- quoted_decls: $ => layout_sort($, $._cmd_layout_start_quote, field('declaration', $.declaration)),
54
+ quoted_decls: $ => layout_sort($, $._cmd_layout_start_quote, field('declaration', $._quoted_declaration)),
55
55
 
56
56
  /**
57
57
  * An "expression quotation" is valid in an expression, and its body may contain an expression, type, pattern or
package/grammar.js CHANGED
@@ -74,6 +74,8 @@ module.exports = grammar({
74
74
  supertypes: $ => [
75
75
  $.expression,
76
76
  $.pattern,
77
+ $.binding_pattern,
78
+ $.binding_field_pattern,
77
79
  $.type,
78
80
  $.quantified_type,
79
81
  $.constraint,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-haskell",
3
- "version": "6.0.4",
3
+ "version": "7.0.0",
4
4
  "description": "Haskell grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -2,9 +2,9 @@
2
2
  ; and don't override destructured parameters
3
3
  (variable) @variable
4
4
 
5
- (pattern/wildcard) @variable
5
+ [(pattern/wildcard) (binding_pattern/wildcard)] @variable
6
6
 
7
- (decl/function
7
+ (function
8
8
  patterns: (patterns
9
9
  (_) @variable.parameter))
10
10
 
@@ -12,7 +12,7 @@
12
12
  (_)+ @variable.parameter
13
13
  "->")
14
14
 
15
- (decl/function
15
+ (function
16
16
  (infix
17
17
  (pattern) @variable.parameter))
18
18
 
@@ -116,55 +116,58 @@
116
116
  ] @keyword
117
117
 
118
118
  [
119
- (decl/function name: (variable) @function)
120
- (decl/bind name: (variable) @function)
121
- (decl/signature name: (variable) @function)
122
- (decl/signature names: (binding_list (variable) @function))
119
+ (function name: (variable) @function)
120
+ (bind name: (variable) @function)
121
+ (signature name: (variable) @function)
122
+ (signature names: (binding_list (variable) @function))
123
123
  ]
124
124
 
125
- (decl/bind
125
+ (bind
126
126
  name: (variable) @variable)
127
127
 
128
- (decl/signature
128
+ (signature
129
129
  name: (variable) @variable
130
130
  type: (type))
131
131
 
132
- ((decl/signature
132
+ ((signature
133
133
  name: (variable) @_name
134
134
  type: (type))
135
135
  .
136
136
  [
137
- (decl/function name: (variable) @variable)
138
- (decl/bind name: (variable) @variable)
137
+ (function name: (variable) @variable)
138
+ (bind name: (variable) @variable)
139
139
  ]
140
140
  match: (_)
141
141
  (#eq? @_name @variable))
142
142
 
143
- (decl/signature
143
+ (signature
144
144
  name: (variable) @function
145
145
  type: (type/apply
146
146
  constructor: (name) @_type)
147
147
  (#eq? @_type "IO"))
148
148
 
149
- ((decl/signature
149
+ ((signature
150
150
  name: (variable) @_name
151
151
  type: (type/apply
152
152
  constructor: (name) @_type)
153
153
  (#eq? @_type "IO"))
154
154
  .
155
155
  [
156
- (decl/function name: (variable) @function)
157
- (decl/bind name: (variable) @function)
156
+ (function name: (variable) @function)
157
+ (bind name: (variable) @function)
158
158
  ]
159
159
  match: (_)
160
160
  (#eq? @_name @function))
161
161
 
162
- ((decl/signature) @function
162
+ ([
163
+ (signature name: (_))
164
+ (signature names: (_))
165
+ ] @function
163
166
  .
164
- (decl/function
167
+ (function
165
168
  name: (variable) @function))
166
169
 
167
- (decl/bind
170
+ (bind
168
171
  name: (variable) @function
169
172
  (match
170
173
  expression: (expression/lambda)))
@@ -263,7 +266,7 @@
263
266
  ]
264
267
  (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
265
268
 
266
- (decl/function
269
+ (function
267
270
  name: (variable) @function
268
271
  (match
269
272
  expression: (infix
@@ -310,23 +313,23 @@
310
313
  (variable) @variable)
311
314
  ])
312
315
 
313
- (decl/bind
316
+ (bind
314
317
  name: (variable) @function
315
318
  (#eq? @function "main"))
316
319
 
317
320
  (signature
318
- pattern: (pattern/variable) @function
321
+ pattern: [(pattern/variable) (binding_pattern/variable)] @function
319
322
  type: (quantified_type))
320
323
 
321
- (decl/signature
324
+ (signature
322
325
  name: (variable) @function
323
326
  type: (quantified_type))
324
327
 
325
- ((decl/signature
328
+ ((signature
326
329
  name: (variable) @_name
327
330
  type: (quantified_type))
328
331
  .
329
- (decl/bind
332
+ (bind
330
333
  (variable) @function)
331
334
  (#eq? @function @_name))
332
335
 
@@ -1,6 +1,6 @@
1
1
  (signature name: (variable)) @local.definition
2
2
  (function name: (variable)) @local.definition
3
- (pattern/variable) @local.definition
3
+ [(pattern/variable) (binding_pattern/variable)] @local.definition
4
4
  (expression/variable) @local.reference
5
5
  (expression/parenthesized_name (variable) @local.reference)
6
6
  (_ name: (parenthesized_name (variable) @local.definition))
package/queries/tags.scm CHANGED
@@ -15,6 +15,14 @@
15
15
  (parenthesized_name [(variable) @name (prefix_id (operator) @name)])
16
16
  ]) @definition.variable)
17
17
 
18
+ (binding_pattern/variable) @name @definition.variable
19
+ (binding_pattern/prefix_id (operator) @name) @definition.variable
20
+ (binding_pattern/as bind: (variable) @name) @definition.variable
21
+
22
+ (binding_field_pattern/field_pattern
23
+ !pattern
24
+ field: [(field_name) @name (qualified id: (field_name) @name)]) @definition.variable
25
+
18
26
  [
19
27
  (class_declarations
20
28
  [
@@ -1,4 +1,120 @@
1
1
  [
2
+ {
3
+ "type": "binding_field_pattern",
4
+ "named": true,
5
+ "subtypes": [
6
+ {
7
+ "type": "field_pattern",
8
+ "named": true
9
+ }
10
+ ]
11
+ },
12
+ {
13
+ "type": "binding_pattern",
14
+ "named": true,
15
+ "subtypes": [
16
+ {
17
+ "type": "apply",
18
+ "named": true
19
+ },
20
+ {
21
+ "type": "as",
22
+ "named": true
23
+ },
24
+ {
25
+ "type": "constructor",
26
+ "named": true
27
+ },
28
+ {
29
+ "type": "infix",
30
+ "named": true
31
+ },
32
+ {
33
+ "type": "irrefutable",
34
+ "named": true
35
+ },
36
+ {
37
+ "type": "list",
38
+ "named": true
39
+ },
40
+ {
41
+ "type": "literal",
42
+ "named": true
43
+ },
44
+ {
45
+ "type": "negation",
46
+ "named": true
47
+ },
48
+ {
49
+ "type": "parens",
50
+ "named": true
51
+ },
52
+ {
53
+ "type": "prefix_id",
54
+ "named": true
55
+ },
56
+ {
57
+ "type": "prefix_tuple",
58
+ "named": true
59
+ },
60
+ {
61
+ "type": "prefix_unboxed_sum",
62
+ "named": true
63
+ },
64
+ {
65
+ "type": "prefix_unboxed_tuple",
66
+ "named": true
67
+ },
68
+ {
69
+ "type": "qualified",
70
+ "named": true
71
+ },
72
+ {
73
+ "type": "quasiquote",
74
+ "named": true
75
+ },
76
+ {
77
+ "type": "record",
78
+ "named": true
79
+ },
80
+ {
81
+ "type": "splice",
82
+ "named": true
83
+ },
84
+ {
85
+ "type": "strict",
86
+ "named": true
87
+ },
88
+ {
89
+ "type": "tuple",
90
+ "named": true
91
+ },
92
+ {
93
+ "type": "unboxed_sum",
94
+ "named": true
95
+ },
96
+ {
97
+ "type": "unboxed_tuple",
98
+ "named": true
99
+ },
100
+ {
101
+ "type": "unboxed_unit",
102
+ "named": true
103
+ },
104
+ {
105
+ "type": "unit",
106
+ "named": true
107
+ },
108
+ {
109
+ "type": "variable",
110
+ "named": true
111
+ },
112
+ {
113
+ "type": "wildcard",
114
+ "named": true
115
+ }
116
+ ]
117
+ },
2
118
  {
3
119
  "type": "class_decl",
4
120
  "named": true,
@@ -155,6 +271,10 @@
155
271
  "type": "declaration",
156
272
  "named": true,
157
273
  "subtypes": [
274
+ {
275
+ "type": "bind",
276
+ "named": true
277
+ },
158
278
  {
159
279
  "type": "class",
160
280
  "named": true
@@ -171,10 +291,6 @@
171
291
  "type": "data_type",
172
292
  "named": true
173
293
  },
174
- {
175
- "type": "decl",
176
- "named": true
177
- },
178
294
  {
179
295
  "type": "default_types",
180
296
  "named": true
@@ -195,6 +311,10 @@
195
311
  "type": "foreign_import",
196
312
  "named": true
197
313
  },
314
+ {
315
+ "type": "function",
316
+ "named": true
317
+ },
198
318
  {
199
319
  "type": "instance",
200
320
  "named": true
@@ -215,6 +335,10 @@
215
335
  "type": "role_annotation",
216
336
  "named": true
217
337
  },
338
+ {
339
+ "type": "signature",
340
+ "named": true
341
+ },
218
342
  {
219
343
  "type": "top_splice",
220
344
  "named": true
@@ -879,6 +1003,10 @@
879
1003
  "multiple": false,
880
1004
  "required": true,
881
1005
  "types": [
1006
+ {
1007
+ "type": "binding_pattern",
1008
+ "named": true
1009
+ },
882
1010
  {
883
1011
  "type": "explicit_type",
884
1012
  "named": true
@@ -927,6 +1055,10 @@
927
1055
  "multiple": false,
928
1056
  "required": false,
929
1057
  "types": [
1058
+ {
1059
+ "type": "binding_pattern",
1060
+ "named": true
1061
+ },
930
1062
  {
931
1063
  "type": "expression",
932
1064
  "named": true
@@ -1005,6 +1137,10 @@
1005
1137
  "multiple": false,
1006
1138
  "required": true,
1007
1139
  "types": [
1140
+ {
1141
+ "type": "binding_pattern",
1142
+ "named": true
1143
+ },
1008
1144
  {
1009
1145
  "type": "pattern",
1010
1146
  "named": true
@@ -1127,6 +1263,10 @@
1127
1263
  "multiple": false,
1128
1264
  "required": false,
1129
1265
  "types": [
1266
+ {
1267
+ "type": "binding_pattern",
1268
+ "named": true
1269
+ },
1130
1270
  {
1131
1271
  "type": "pattern",
1132
1272
  "named": true
@@ -2439,6 +2579,10 @@
2439
2579
  "multiple": false,
2440
2580
  "required": false,
2441
2581
  "types": [
2582
+ {
2583
+ "type": "binding_pattern",
2584
+ "named": true
2585
+ },
2442
2586
  {
2443
2587
  "type": "pattern",
2444
2588
  "named": true
@@ -3370,6 +3514,10 @@
3370
3514
  "multiple": false,
3371
3515
  "required": true,
3372
3516
  "types": [
3517
+ {
3518
+ "type": "binding_pattern",
3519
+ "named": true
3520
+ },
3373
3521
  {
3374
3522
  "type": "expression",
3375
3523
  "named": true
@@ -3426,6 +3574,10 @@
3426
3574
  "multiple": false,
3427
3575
  "required": true,
3428
3576
  "types": [
3577
+ {
3578
+ "type": "binding_pattern",
3579
+ "named": true
3580
+ },
3429
3581
  {
3430
3582
  "type": "expression",
3431
3583
  "named": true
@@ -3614,6 +3766,10 @@
3614
3766
  "multiple": false,
3615
3767
  "required": true,
3616
3768
  "types": [
3769
+ {
3770
+ "type": "binding_pattern",
3771
+ "named": true
3772
+ },
3617
3773
  {
3618
3774
  "type": "pattern",
3619
3775
  "named": true
@@ -3932,6 +4088,10 @@
3932
4088
  "multiple": true,
3933
4089
  "required": false,
3934
4090
  "types": [
4091
+ {
4092
+ "type": "binding_pattern",
4093
+ "named": true
4094
+ },
3935
4095
  {
3936
4096
  "type": "expression",
3937
4097
  "named": true
@@ -4361,6 +4521,10 @@
4361
4521
  "multiple": false,
4362
4522
  "required": false,
4363
4523
  "types": [
4524
+ {
4525
+ "type": "binding_pattern",
4526
+ "named": true
4527
+ },
4364
4528
  {
4365
4529
  "type": "pattern",
4366
4530
  "named": true
@@ -4903,7 +5067,79 @@
4903
5067
  "required": false,
4904
5068
  "types": [
4905
5069
  {
4906
- "type": "declaration",
5070
+ "type": "class",
5071
+ "named": true
5072
+ },
5073
+ {
5074
+ "type": "data_family",
5075
+ "named": true
5076
+ },
5077
+ {
5078
+ "type": "data_instance",
5079
+ "named": true
5080
+ },
5081
+ {
5082
+ "type": "data_type",
5083
+ "named": true
5084
+ },
5085
+ {
5086
+ "type": "decl",
5087
+ "named": true
5088
+ },
5089
+ {
5090
+ "type": "default_types",
5091
+ "named": true
5092
+ },
5093
+ {
5094
+ "type": "deriving_instance",
5095
+ "named": true
5096
+ },
5097
+ {
5098
+ "type": "fixity",
5099
+ "named": true
5100
+ },
5101
+ {
5102
+ "type": "foreign_export",
5103
+ "named": true
5104
+ },
5105
+ {
5106
+ "type": "foreign_import",
5107
+ "named": true
5108
+ },
5109
+ {
5110
+ "type": "instance",
5111
+ "named": true
5112
+ },
5113
+ {
5114
+ "type": "kind_signature",
5115
+ "named": true
5116
+ },
5117
+ {
5118
+ "type": "newtype",
5119
+ "named": true
5120
+ },
5121
+ {
5122
+ "type": "pattern_synonym",
5123
+ "named": true
5124
+ },
5125
+ {
5126
+ "type": "role_annotation",
5127
+ "named": true
5128
+ },
5129
+ {
5130
+ "type": "top_splice",
5131
+ "named": true
5132
+ },
5133
+ {
5134
+ "type": "type_family",
5135
+ "named": true
5136
+ },
5137
+ {
5138
+ "type": "type_instance",
5139
+ "named": true
5140
+ },
5141
+ {
5142
+ "type": "type_synonym",
4907
5143
  "named": true
4908
5144
  }
4909
5145
  ]
@@ -5024,6 +5260,10 @@
5024
5260
  "multiple": false,
5025
5261
  "required": false,
5026
5262
  "types": [
5263
+ {
5264
+ "type": "binding_pattern",
5265
+ "named": true
5266
+ },
5027
5267
  {
5028
5268
  "type": "pattern",
5029
5269
  "named": true
@@ -5045,11 +5285,11 @@
5045
5285
  "required": false,
5046
5286
  "types": [
5047
5287
  {
5048
- "type": "field",
5288
+ "type": "binding_field_pattern",
5049
5289
  "named": true
5050
5290
  },
5051
5291
  {
5052
- "type": "field_pattern",
5292
+ "type": "field",
5053
5293
  "named": true
5054
5294
  },
5055
5295
  {
@@ -5224,6 +5464,10 @@
5224
5464
  "multiple": false,
5225
5465
  "required": false,
5226
5466
  "types": [
5467
+ {
5468
+ "type": "binding_pattern",
5469
+ "named": true
5470
+ },
5227
5471
  {
5228
5472
  "type": "pattern",
5229
5473
  "named": true
@@ -5352,6 +5596,10 @@
5352
5596
  "multiple": false,
5353
5597
  "required": true,
5354
5598
  "types": [
5599
+ {
5600
+ "type": "binding_pattern",
5601
+ "named": true
5602
+ },
5355
5603
  {
5356
5604
  "type": "pattern",
5357
5605
  "named": true
@@ -5471,6 +5719,10 @@
5471
5719
  "multiple": true,
5472
5720
  "required": false,
5473
5721
  "types": [
5722
+ {
5723
+ "type": "binding_pattern",
5724
+ "named": true
5725
+ },
5474
5726
  {
5475
5727
  "type": "expression",
5476
5728
  "named": true
@@ -5886,6 +6138,10 @@
5886
6138
  "multiple": true,
5887
6139
  "required": true,
5888
6140
  "types": [
6141
+ {
6142
+ "type": "binding_pattern",
6143
+ "named": true
6144
+ },
5889
6145
  {
5890
6146
  "type": "expression",
5891
6147
  "named": true
@@ -5918,6 +6174,10 @@
5918
6174
  "multiple": true,
5919
6175
  "required": true,
5920
6176
  "types": [
6177
+ {
6178
+ "type": "binding_pattern",
6179
+ "named": true
6180
+ },
5921
6181
  {
5922
6182
  "type": "expression",
5923
6183
  "named": true
@@ -5990,6 +6250,10 @@
5990
6250
  "multiple": false,
5991
6251
  "required": true,
5992
6252
  "types": [
6253
+ {
6254
+ "type": "binding_pattern",
6255
+ "named": true
6256
+ },
5993
6257
  {
5994
6258
  "type": "pattern",
5995
6259
  "named": true
Binary file
package/tree-sitter.json CHANGED
@@ -16,7 +16,7 @@
16
16
  }
17
17
  ],
18
18
  "metadata": {
19
- "version": "6.0.4",
19
+ "version": "7.0.0",
20
20
  "license": "MIT",
21
21
  "description": "Haskell grammar for tree-sitter",
22
22
  "authors": [