Extend the effects of both BlockArguments and LambdaCase to arrow notation
This MR bundles two distinct (minor) improvements to arrow notation:
-
When
BlockArgumentsis 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
LambdaCaseis enabled,\caseis now valid syntax for an arrow command, combining the behavior of lambda commands andcasecommands 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") |) xThis change is slightly more involved, since it requires extending the grammar of
HsCmdto 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 bothHsCmdCaseandHsCmdLamCase.
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.