cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

Add `"constructor"` scope type

Open wenkokke opened this issue 1 year ago • 6 comments

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 avatar Jan 22 '24 19:01 wenkokke

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

wenkokke avatar Jan 22 '24 19:01 wenkokke

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

pokey avatar Jan 22 '24 21:01 pokey

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.

wenkokke avatar Jan 23 '24 01:01 wenkokke

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

pokey avatar Jan 23 '24 13:01 pokey

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

wenkokke avatar Jan 23 '24 14:01 wenkokke

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

pokey avatar Jan 23 '24 18:01 pokey