Adds support for the Haskell programming language#2178
Adds support for the Haskell programming language#2178wenkokke wants to merge 50 commits intocursorless-dev:mainfrom
Conversation
I would expect |
what makes any of them a "branch"? |
tup = (1, 2)
assert (fst tup == 1) |
all top-level defintions are branches, and it'd be odd to exclude single-branch branching constructs, e.g., having "branch" not match the branch in an if statement without an else not :: Bool -> Bool
not True = False
not False = Truethat's equivalent to not :: Bool -> Bool
not x = case x of
True -> False
False -> Trueand equivalent to not :: Bool -> Bool
not x = if x the False else True |
queries/haskell.scm
Outdated
| (patterns | ||
| ( | ||
| (_) @argumentOrParameter | ||
| ) @_.iteration |
There was a problem hiding this comment.
I'm guessing you don't want this to be the iteration scope for functionName, so you probably want
| ) @_.iteration | |
| ) @argumentOrParameter.iteration |
the _ is a wildcard that makes it apply to all scopes defined in the pattern
There was a problem hiding this comment.
wait, so the iteration scopes aren't scoped?
There was a problem hiding this comment.
that would be nice, but no. not worth the complexity. fwiw we don't recommend defining iteration scope at the same time as scope, because it actually generates one copy of the iteration scope per scope, which we then silently merge. it's fine to do if it's significantly easier, but shouldn't be your first instinct
iteration scopes are not like domain / removal / leading / whatever, because the iteration scope is genuinely a different scope, where as the latter are attributes of the original scope itself
|
shall we make a haskell discussion so we can use threading? all the quoting is quickly going to become a headache 😅 |
| "branch.match": { | ||
| description: "A pattern match branch", | ||
| scopeType: "branch", | ||
| }, |
There was a problem hiding this comment.
this introduces a bit of confusion in Python, where a match statement is basically a switch statement with pattern matching
| }, | ||
| "branch.match.iteration": { | ||
| description: | ||
| "Iteration scope for pattern match branches; should be the entire branch", |
There was a problem hiding this comment.
what do you mean by "should be the entire branch"?
| 1| fib 0 = 0 | ||
| >---------< |
There was a problem hiding this comment.
This makes sense as the domain, but I think the range should be just the arg list itself
There was a problem hiding this comment.
Also, this looks like a formal argument, not an actual argument 🤔
| 1| fib 0 = 0 | ||
| >-< |
There was a problem hiding this comment.
as above, this looks like a formal arg not an actual arg
| 0| abs :: Int -> Int | ||
| >< |
There was a problem hiding this comment.
hmm interesting to have zero-width arg here 🤔. tho again, if anything that would be formal
| 0| abs :: Int -> Int | ||
| >------------- | ||
| 1| abs x | ||
| -----< |
There was a problem hiding this comment.
Yeah, that's an odd one. Might be the same issue.
There was a problem hiding this comment.
this looks identical to at least a few of the other 90+ branch.match.iteration test files you have 😅
There was a problem hiding this comment.
I'm all for good test coverage, but >100 test cases for a single facet? 😅. I almost get the impression that you used a script to generate test cases and it went a bit out of control
|
note: this PR is semi-blocked on tree-sitter/tree-sitter-haskell#111, which causes the parse tree to sometimes be wrong. For example see We could try to come up with a workaround if necessary, but for now we're hoping the issue gets fixed soon |
@pokey Would you prefer we (1) move on with incorrect tests, (2) add a workaround which reinstantiates the parser between every run, or (3) fork and temporarily patch tree-sitter-haskell? |
|
Note: This PR is currently blocked on the ongoing rewrite of the Haskell grammar (see #120). |
…nCallee, list, string to main file
Just wanted to circle back to this --- it looks like that rewrite of the Haskell grammar has been merged in. But not trying to rush you or anything like that, obviously. |
It was, but it took a very long time and I got distracted with other things. Feel free to pick this up. |
Got it, that makes sense! I probably won't be able to get to this super soon myself, but I'll at least try to look at it sometime in the next 3 months. |
Adds support for the Haskell programming language.
Roadmap
argumentOrParameter:argument.actualargument.actual.iterationBlocked on one of:
"pattern"scope type #2177argument.formalargument.formal.iterationanonymousFunctionbranchbranch.matchbranch.match.iterationbranch.ifbranch.if.iterationbranch.guardbranch.guard.iterationbranch.ternarycollectionItemcollectionKeykey.mapPairkey.mapPair.iterationcommentcomment.linecomment.blockfunctionCallfunctionCallfunctionCall.constructorfunctionCalleefunctionCalleefunctionCallee.constructorfunctionNameifStatementlistmapnamename.assignmentname.assignment.patternname.functionname.classname.fieldnamedFunctionnamedFunctionnamedFunction.methodstatementstatementstatement.iteration.documentstatement.iteration.blockstringtypeclassclass.instanceclassNametype.adttype.aliastype.annotationtype.constrainttype.dataFamilytype.dataInstancetype.fieldtype.foreignExporttype.foreignImporttype.functiontype.gadttype.newtypetype.typeFamilytype.typeInstancevaluevalue.assignmentvalue.fieldvalue.mapPairvalue.mapPair.iterationvalue.returnconditioncondition.ifcondition.ternarycondition.matchWarning
This is work in progress. In the early stages, I'll be messy.
Discussion and RFCs
See #2186.
Haskell Node Types
adtall_namesaltaltsannotated_type_variablebind_patterncalling_conventioncharclassclass_bodyclass_headclass_namecommacommentcon_listcon_tuplecon_unitconstraintconstructorconstructor_operatorconstructorscontextcppdata_constructordata_constructor_infixdata_constructor_recorddata_familydata_instancedecl_tyfam_sigdecl_typedeclsdefault_declarationdefault_signaturederivingderiving_declarationderiving_strategydo_moduleempty_fileequationexp_applyexp_arithmetic_sequenceexp_caseexp_condexp_doexp_fieldexp_if_guardexp_inexp_infixexp_lambdaexp_lambda_caseexp_letexp_let_inexp_listexp_list_comprehensionexp_literalexp_nameexp_negationexp_parensexp_recordexp_section_leftexp_section_rightexp_sum_emptyexp_th_quoted_nameexp_tupleexp_type_applicationexp_unboxed_sumexp_unboxed_tupleexpentexportexport_namesexportsfieldfixityfloatforallforeign_exportforeign_importfunfunctionfundepfundepsgadt_constructorgdpatguardguard_equationguardshaskellheadimpentimplicit_paramimplicit_paridimportimport_con_namesimport_itemimport_listimport_packageinfixinst_datainstinst_tyinstinstanceinstance_headintegerlabelletmodifiermodulenamespacenewtypenewtype_constructoroperatorpat_applypat_aspat_fieldpat_fieldspat_infixpat_irrefutablepat_listpat_literalpat_namepat_negationpat_parenspat_recordpat_strictpat_tuplepat_typedpat_unboxed_tuplepat_viewpat_wildcardpatternpattern_guardpattern_synonympatternspragmapromotedqualqualified_constructorqualified_constructor_operatorqualified_modulequalified_operatorqualified_typequalified_type_operatorqualified_variablequantifiersquasiquotequasiquote_barquasiquote_bodyquasiquote_startquoterrecrecord_fieldsrole_annotationsafetysignaturesplicestmtstrict_typestringtickedtop_splicetransformtycon_arrowtypetype_aliastype_applytype_familytype_infixtype_instancetype_listtype_literaltype_nametype_operatortype_parenstype_roletype_startype_tupletype_unboxed_sumtype_unboxed_tupletype_variablevariablevaropviawherewildcard