You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Obviously in their own queries people can write whatever they want, given their editors and themes recognize it. But I'm now wondering what would make for good defaults.
IMO common Tree-sitter captures don't do well even in representing the semantics of traditional imperative languages, and PureScript being relatively distinct doesn't help it, so it's not an easy problem.
Particular points
Function application
Unison queries capture the first identifier in function application expressions as @function, i.e. something like [fun1] var1 var2 <> Qualified.[fun2] var3 var4 where [] is the captured group. This is a nice idea in itself but some things make it less attractive for our grammar:
We also capture the first identifier in the left-hand side of equations as @function, i.e. [fun] pat1 par2 = expr.
In this example snippet, it's not easy to discern between identifiers in equations and identifiers in application expressions. Unfortunately TS query APIs don't distinct between function definition and function application yet.
It wouldn't necessarily represent what people mentally perceive as "the function".
Just consider these examples: fun3 $ fun2 $ fun1 var, fun2 <$> fun1 var, var # fun. In the first two, only fun1 will be captures, and in the third one nothing at all will be captured. Now extend it to <<<, >>>, <#>, sum <*> length, etc.
So I'd like to hear ideas about whether it's worth it or if it's better to keep everything be variables. This is an example of what it'd look like:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The problem
Obviously in their own queries people can write whatever they want, given their editors and themes recognize it. But I'm now wondering what would make for good defaults.
IMO common Tree-sitter captures don't do well even in representing the semantics of traditional imperative languages, and PureScript being relatively distinct doesn't help it, so it's not an easy problem.
Particular points
Function application
Unison queries capture the first identifier in function application expressions as
@function
, i.e. something like[fun1] var1 var2 <> Qualified.[fun2] var3 var4
where[]
is the captured group. This is a nice idea in itself but some things make it less attractive for our grammar:@function
, i.e.[fun] pat1 par2 = expr
.In this example snippet, it's not easy to discern between identifiers in equations and identifiers in application expressions. Unfortunately TS query APIs don't distinct between function definition and function application yet.
Just consider these examples:
fun3 $ fun2 $ fun1 var
,fun2 <$> fun1 var
,var # fun
. In the first two, onlyfun1
will be captures, and in the third one nothing at all will be captured. Now extend it to<<<
,>>>
,<#>
,sum <*> length
, etc.So I'd like to hear ideas about whether it's worth it or if it's better to keep everything be variables. This is an example of what it'd look like:
Beta Was this translation helpful? Give feedback.
All reactions