Reputation: 43
if i try to run this function :
function :: Int -> Int -> Int
function =
\case 5 -> 1
im getting this error message :
parse error (possibly incorrect indentation or mismatched brackets)
Failed, modules loaded: none.
or this if i implement the function like this :
function :: Int -> Int -> Int
function = \case 5 -> 1
parse error on input ‘case’
Failed, modules loaded: none.
could anyone tell me why i am getting this error message?
Upvotes: 0
Views: 141
Reputation: 11913
The \case (...) -> (...)
syntax requires the language extension LambdaCase
.
To set this in your file, either compile with the flag -XLambdaCase
, or write this at the top of your file:
{-# LANGUAGE LambdaCase #-}
Note that non-GHC compilers may not support this extension.
Upvotes: 4