-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for the Haskell programming language #2178
Draft
wenkokke
wants to merge
50
commits into
cursorless-dev:main
Choose a base branch
from
wenkokke:haskell
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+115,815
−2
Draft
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
a6d122f
Start Haskell support
wenkokke 0cf5739
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 30bbad8
Changes
wenkokke 341358c
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 5e61157
take inside funk
wenkokke 2d7ce9d
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 1f91086
Query for functions (~400 LoC)
wenkokke 5a8ca7a
Formatting & restructuring
wenkokke d6e2817
Rename files
wenkokke 91d8f4d
Fixes for namedFunction
wenkokke accfb9a
Try adding values
wenkokke 5a1cec7
Add scope facet support for Haskell
wenkokke 7195124
Test namedFunction/functionName/name.function
wenkokke fd4f30c
Update Haskell scope support facet stuff
wenkokke 24743f7
Update Haskell fixtures
wenkokke 7017a4e
@name tests don't work
wenkokke cf1cbae
@name.function -> @name
wenkokke be3d7af
Fix RFCs.hs
wenkokke 2ad74bb
Remove @name from @namedFunction
wenkokke e7a64a8
Add name.function
wenkokke fe61271
Add @branch.iteration
wenkokke 6c80baa
Restore haskell.namedFunction
wenkokke 773baba
Remove branch.iteration and name
wenkokke 915013e
Split out functionName
wenkokke 8bd3902
Add name
wenkokke 314be8f
Add fixtures for @name.function
wenkokke 721132e
Add @branch and @branch.iteration
wenkokke 858e285
Add @branch and @branch.iteration
wenkokke b856d3e
I don't know what's happening.
wenkokke 4fb6403
Why????
wenkokke 3a31715
consistent comments
wenkokke 9f564c3
Move files & add argumentOrParameter iteration tests
wenkokke 65c2faa
Add call & callee
wenkokke 0aa8ce5
Tests for @argument.actual
wenkokke d3f9b44
Add roadmap
wenkokke 32bb73f
Add name.function
wenkokke aeb580e
Update haskell.md
wenkokke 3241e86
Add anonymousFunction
wenkokke a885b01
Update haskell.md
wenkokke 1ca43d7
Add list & string
wenkokke a0ad642
Basic support for map & move anonymousFunction, functionCall, functio…
wenkokke 122908d
Add some warning comments
wenkokke 95e20f3
Group queries a little bit more closely by relation
wenkokke 4bbbd4f
Fixed generate-scope-tests-for-haskell
wenkokke 45cf49e
Generate wrong fixtures
wenkokke 1b243e4
Remove URL
wenkokke 2d3b08d
*actual -> formal
wenkokke 7bd621d
Fixes to scope support
wenkokke 1d4c887
Rebase on top of HEAD and disable previous queries and supported scopes
wenkokke 12ad364
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- RFC 1: What should "arg" match? | ||
fst :: (a, b) -> a | ||
fst tup@(x, y) = x | ||
-- ^^^^^^^^^^ <- 🎉 the whole pattern | ||
-- ^^^ <- 👀 only the name of the whole argument, if given | ||
-- ^^^ ^ ^ <- 🚀 all names in the pattern | ||
|
||
-- RFC 2: What should "branch" match? | ||
foo = bar | ||
where | ||
bar = 1 | ||
-- 🎉 `foo = bar` and `bar = 1` | ||
-- 👀 `foo = bar where bar = 1` | ||
-- 🚀 `foo = bar where bar = 1` and `bar = 1` | ||
|
||
-- RFC 3: What should "condition" match? | ||
bap :: Int -> Int | ||
bap | 1 == 1, 2 == 2 = undefined | ||
-- 🎉 `1 == 1` and `2 == 2` | ||
-- 👀 `1 == 1, 2 == 2` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
data a :*: b = a :*: b | ||
type a :+: b = Either a b | ||
|
||
fst :: a :*: b -> a | ||
fst (a :*: b) = a | ||
|
||
pair a b = a :*: b | ||
|
||
fromLeft :: a :+: b -> a | ||
fromLeft (Left a) = a | ||
fromLeft _ = undefined | ||
|
||
fib :: Integer -> Integer | ||
fib 0 = 0 | ||
fib 1 = 1 | ||
fib n = fib (n-1) + fib (n-2) | ||
|
||
abs :: Int -> Int | ||
abs x | ||
| x >= 0 = x | ||
| otherwise = -x | ||
|
||
bap :: Int -> Int | ||
bap x | ||
| x > 0, x == 0 = x | ||
| otherwise = -x | ||
|
||
compare :: Int -> Int -> Ordering | ||
compare x y | ||
| x < y = LT | ||
| x == y = EQ | ||
| x > y = GT | ||
|
||
fromEither :: (a -> c) -> (b -> c) -> Either a b -> c | ||
fromEither f g x = case x of | ||
Left l -> f l | ||
Right r -> g r | ||
|
||
someFunction x (y1 : y2 : ys) (a, b, (c, [d])) = undefined | ||
|
||
compose :: (a -> b) -> (b -> c) -> (a -> c) | ||
compose f g x = g (f x) | ||
|
||
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] | ||
zipWith f [] [] = [] | ||
zipWith f (x : xs) (y : ys) = f x y : zipWith f xs ys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
one :: Integer | ||
one = 1 | ||
|
||
type MyInt = Int | ||
|
||
fib :: Integer -> Integer | ||
fib 0 = 0 | ||
fib 1 = 1 | ||
fib n = fib (n-1) + fib (n-2) | ||
|
||
not True = False | ||
not False = True | ||
|
||
wot True = 1 | ||
wot False = crash | ||
where | ||
crash = undefined | ||
|
||
zot = undefined | ||
|
||
pot :: a | ||
pot = | ||
let kettle = undefined | ||
in kettle | ||
|
||
lot = undefined | ||
|
||
type MyDouble = Double | ||
|
||
dot = undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
|
||
import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; | ||
import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; | ||
|
||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; | ||
|
||
export const haskellScopeSupport: LanguageScopeSupportFacetMap = { | ||
list: unsupported, | ||
map: unsupported, | ||
ifStatement: unsupported, | ||
regularExpression: unsupported, | ||
switchStatementSubject: unsupported, | ||
fieldAccess: unsupported, | ||
|
||
statement: unsupported, | ||
"statement.iteration.document": unsupported, | ||
"statement.iteration.block": unsupported, | ||
|
||
class: unsupported, | ||
// "class.instance": unsupported, | ||
className: unsupported, | ||
|
||
namedFunction: unsupported, | ||
"namedFunction.method": unsupported, | ||
anonymousFunction: unsupported, | ||
functionName: unsupported, | ||
|
||
functionCall: unsupported, | ||
"functionCall.constructor": unsupported, | ||
functionCallee: unsupported, | ||
"functionCallee.constructor": unsupported, | ||
|
||
"argument.actual": unsupported, | ||
"argument.actual.iteration": unsupported, | ||
"argument.formal": unsupported, | ||
"argument.formal.iteration": unsupported, | ||
|
||
"comment.line": unsupported, | ||
"comment.block": unsupported, | ||
|
||
"string.singleLine": unsupported, | ||
|
||
"branch.match": unsupported, | ||
"branch.match.iteration": unsupported, | ||
"branch.if": unsupported, | ||
"branch.if.iteration": unsupported, | ||
"branch.ternary": unsupported, | ||
|
||
"condition.if": unsupported, | ||
"condition.ternary": unsupported, | ||
|
||
"name.assignment": unsupported, | ||
"name.assignment.pattern": unsupported, | ||
"name.function": unsupported, | ||
"name.class": unsupported, | ||
"name.field": unsupported, | ||
|
||
"key.mapPair": unsupported, | ||
"key.mapPair.iteration": unsupported, | ||
|
||
"value.assignment": unsupported, | ||
"value.mapPair": unsupported, | ||
"value.mapPair.iteration": unsupported, | ||
"value.return": unsupported, | ||
"value.return.lambda": unsupported, | ||
"value.field": unsupported, | ||
|
||
// "type.adt": unsupported, | ||
// "type.alias": unsupported, | ||
// "type.annotation": unsupported, | ||
// "type.constraint": unsupported, | ||
// "type.dataFamily": unsupported, | ||
// "type.dataInstance": unsupported, | ||
// "type.field": unsupported, | ||
// "type.foreignExport": unsupported, | ||
// "type.foreignImport": unsupported, | ||
// "type.formalParameter": unsupported, | ||
// "type.function": unsupported, | ||
// "type.gadt": unsupported, | ||
// "type.newtype": unsupported, | ||
// "type.typeFamily": unsupported, | ||
// "type.typeInstance": unsupported, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,6 +299,16 @@ export const scopeSupportFacetInfos: Record< | |
scopeType: "disqualifyDelimiter", | ||
}, | ||
|
||
"branch.match": { | ||
description: "A pattern match branch", | ||
scopeType: "branch", | ||
}, | ||
"branch.match.iteration": { | ||
description: | ||
"Iteration scope for pattern match branches; should be the entire branch", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you mean by "should be the entire branch"? |
||
scopeType: "branch", | ||
isIteration: true, | ||
}, | ||
"branch.if": { | ||
description: "An if/elif/else branch", | ||
scopeType: "branch", | ||
|
@@ -308,7 +318,6 @@ export const scopeSupportFacetInfos: Record< | |
"A for / while loop branch. For most languages there will just be one branch for the entire loop, but eg in Python you can have an else branch for a loop.", | ||
scopeType: "branch", | ||
}, | ||
|
||
"branch.if.iteration": { | ||
description: | ||
"Iteration scope for if/elif/else branch; should be the entire if-else statement", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this introduces a bit of confusion in Python, where a match statement is basically a switch statement with pattern matching