cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.13k stars 78 forks source link

Add `"constructor"` scope type #2196

Open wenkokke opened 7 months ago

wenkokke commented 7 months ago

Add a scope type to target data constructors, such as:

compare :: Int -> Int -> Ordering
compare x y
    | x <  y = LT
--             ^^ constructor
    | x == y = EQ
--             ^^ constructor
    | x  > y = GT
--             ^^ constructor
either :: (a -> c) -> (b -> c) -> Either a b -> c
either f g (Left l) = f l
--          ^^^^ constructor
either f g (Right r) = g r
--          ^^^^^ constructor
ifThenElse :: Bool -> a -> a -> a
ifThenElse True  t _ = t
--         ^^^^ constructor
ifThenElse False _ f = f
--         ^^^^^ constructor
wenkokke commented 7 months ago

Could be addressed by #557 even if placing them under function doesn't quite make sense.

pokey commented 7 months ago

Could this be "callee"? What's the domain for these? Ie for the Left example should the domain be the surrounding parens?

wenkokke commented 7 months ago

Could this be "callee"? What's the domain for these? Ie for the Left example should the domain be the surrounding parens?

It'd be good to be able to say something like "change constructor first argument every branch".

Having them be "callee" is possible, but mentally strange.

pokey commented 7 months ago

that should work out of the box with "callee" if everything is implemented correctly

wenkokke commented 7 months ago

I guess that leaves the question: are you comfortable with True and False being addressed as "callee"?

pokey commented 7 months ago

I think that makes sense when one bends one's mind to the Haskell way of thinking, no?