aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--queries/haskell/highlights.scm148
-rw-r--r--tests/query/highlights/haskell/test.hs61
2 files changed, 142 insertions, 67 deletions
diff --git a/queries/haskell/highlights.scm b/queries/haskell/highlights.scm
index ecd267cc4..bf9692136 100644
--- a/queries/haskell/highlights.scm
+++ b/queries/haskell/highlights.scm
@@ -163,46 +163,6 @@
(signature name: (variable) @function)
-((signature name: (variable) @variable)
- . (function
- name: (variable) @_name
- rhs: [
- (exp_literal)
- (exp_apply
- (exp_name
- [(constructor)
- (variable)
- ]))
- (quasiquote)
- ((exp_name) . (operator))
- ])
- (#eq? @variable @_name))
-
-((signature name: (variable) @variable)
- . (function
- name: (variable) @_name
- rhs: (exp_infix
- [
- (exp_literal)
- (exp_apply
- (exp_name
- [(constructor)
- (variable)
- ]))
- (quasiquote)
- ((exp_name) . (operator))
- ]))
- (#eq? @variable @_name))
-
-((signature name: (variable) @function)
- . (function
- name: (variable) @_name
- patterns: (patterns))
- (#eq? @function @_name))
-
-;; For some reason, `(signature name: (variable) type: (fun))` doesn't work here
-(signature (variable) @function . (fun))
-
(function name: (variable) @function)
(function
@@ -231,18 +191,40 @@
((exp_name) . (operator))
]))
+;; Consider signatures (and accompanying functions)
+;; with only one value on the rhs as variables
+(signature . (variable) @variable . (_) . )
+((signature . (variable) @_name . (_) . )
+ . (function name: (variable) @variable)
+ (#eq? @_name @variable))
+;; but consider a type that involves 'IO' a function
+(signature name: (variable) @function
+ . (type_apply (type_name) @_type)
+ (#eq? @_type "IO"))
+((signature name: (variable) @_name
+ . (type_apply (type_name) @_type)
+ (#eq? @_type "IO"))
+ . (function name: (variable) @function)
+ (#eq? @_name @function))
+
+;; functions with parameters
+;; + accompanying signatures
(function
name: (variable) @function
patterns: (patterns))
+((signature) @function
+ . (function
+ name: (variable) @function
+ patterns: (patterns)))
(function
name: (variable) @function
rhs: (exp_lambda))
-((signature (variable) @function (fun)) . (function (variable)))
-((signature (variable) @_type (fun)) . (function (variable) @function) (#eq? @function @_type))
-((signature (variable) @function (context (fun))) . (function (variable)))
-((signature (variable) @_type (context (fun))) . (function (variable) @function) (#eq? @function @_type))
-((signature (variable) @function (forall (context (fun)))) . (function (variable)))
-((signature (variable) @_type (forall (context (fun)))) . (function (variable) @function) (#eq? @function @_type))
+
+; view patterns
+(pat_view (exp_name [
+ ((variable) @function.call)
+ (qualified_variable (variable) @function.call)
+]))
; consider infix functions as operators
(exp_infix [
@@ -253,11 +235,11 @@
(exp_section_right [
((variable) @operator)
(qualified_variable (variable) @operator)
- ])
+])
(exp_section_left [
((variable) @operator)
(qualified_variable (variable) @operator)
- ])
+])
; function calls with an infix operator
; e.g. func <$> a <*> b
@@ -272,9 +254,15 @@
. (operator))
; infix operators applied to variables
((exp_name (variable) @variable) . (operator))
-((operator) . (exp_name (variable) @variable))
+((operator) . (exp_name [
+ ((variable) @variable)
+ (qualified_variable (variable) @variable)
+]))
; function calls with infix operators
-((exp_name (variable) @function.call) . (operator) @_op
+((exp_name [
+ ((variable) @function.call)
+ (qualified_variable (variable) @function.call)
+ ]) . (operator) @_op
(#any-of? @_op "$" "<$>" ">>=" "=<<"))
; right hand side of infix operator
((exp_infix
@@ -284,7 +272,7 @@
(qualified_variable (variable) @function.call)
])) . (operator) @_op
(#any-of? @_op "$" "<$>" "=<<"))
-; function composition, arrows, monadic composition (rhs)
+; function composition, arrows, monadic composition (lhs)