Missing LambdaCase [GHC-51179]
Language extension: LambdaCase
The Lambda Case extension
enables a syntactic sugar for a lambda function that pattern matches its argument immediately.
Using LambdaCase
,
\case {"1" -> 1; "2" -> 2}
is equivalent to
\x -> case x of {"1" -> 1; "2" -> 2}
When the extension is missing, the expression is interpreted as a regular lambda expression that is incorrectly formatted.
Examples
Missing LambdaCase language extension
Cannot use lambda case expressions - LambdaCase
language extension is missing.
Error Message
error: [GHC-51179]
Illegal \case
Suggested fix: Perhaps you intended to use LambdaCase
|
3 | f = \case
| ^^^^
ErrLambdaCase.hs
Before
module ErrLambdaCase where
f = \case
"1" -> 1
"2" -> 2
_ -> 3
After
{-# LANGUAGE LambdaCase #-}
module ErrLambdaCase where
f = \case
"1" -> 1
"2" -> 2
_ -> 3