Extend the effects of both BlockArguments and LambdaCase to arrow notation
This MR bundles two distinct (minor) improvements to arrow notation:
-
When
BlockArguments
is enabled, its effects now additionally apply to arrow control operators in(|
banana brackets|)
(fixing #18050 (closed)):cmdLam :: () -> () cmdLam = proc () -> (| id \() -> () >- returnA |) ()
This change is extremely simple, affecting only the parser.
-
When
LambdaCase
is enabled,\case
is now valid syntax for an arrow command, combining the behavior of lambda commands andcase
commands the way one would expect.foo :: ArrowChoice p => p (Maybe Int) String foo = proc x -> (| id (\case Just x | x > 100 -> returnA -< "big " ++ show x | otherwise -> returnA -< "small " ++ show x Nothing -> returnA -< "none") |) x
This change is slightly more involved, since it requires extending the grammar of
HsCmd
to include a newHsCmdLamCase
, the command analogue toHsLamCase
. However, the required changes are still quite minimal, and they mostly just amount to moving some code around so it can be shared by bothHsCmdCase
andHsCmdLamCase
.
Both of these are user-facing changes, but they are 100% backwards-compatible, since they don’t change the behavior of any currently-accepted program. Both of them are natural interactions with existing language extensions that were likely just oversights in the first place, seeing as arrow notation doesn’t get much love these days.