Where is accepted in LambdaCase
Summary
This example should not compile in my opinion:
{-# LANGUAGE LambdaCase #-}
import Data.Function ((&))
main = () & (\case () -> x where x = pure ())
But the following code does produce a parse error:
{-# LANGUAGE LambdaCase #-}
import Data.Function ((&))
main = () & (\case () -> x
where x = pure ())
And this also produces an error:
{-# LANGUAGE LambdaCase #-}
import Data.Function ((&))
main = () & (\case () -> x where
x = pure ())
I think all of those should be rejected, because I want the following to be accepted:
{-# LANGUAGE LambdaCase, BlockArguments #-}
import Data.Function ((&))
main = () & \case () -> x where
x = pure ()
Here the where
block should be on the whole right hand side of the main function, but currently I think it parses it as being on the lambda case. I expected it would be parsed the same as:
{-# LANGUAGE LambdaCase, BlockArguments #-}
import Data.Function ((&))
main = (() & \case () -> x) where
x = pure ()
Which does work properly, but it has ugly seemingly redundant parentheses.
Environment
- GHC version used: 9.0.1
Optional:
- Operating System: NixOS 21.05
- System Architecture: x86_64