Reputation: 11
data Nat = Zero | Succ Nat
data NatSig val = NatSig {zero_ :: val, succ :: val -> val}
foldNat :: NatSig val -> Nat -> val
foldNat alg = \case Zero -> zero_ alg
Succ n -> succ alg $ foldNat alg sn
Hello this is a code from my University but if i want to run it i get an error
Illegal lambda-case (use -XLambdaCase)
some one know why?
Upvotes: 1
Views: 1252
Reputation: 48672
The syntax \case
isn't in the Haskell Report, so it isn't allowed in standard Haskell. To use it, you have to enable the LambdaCase
extension. There are several different ways you can do so, including:
-XLambdaCase
on the command line{-# LANGUAGE LambdaCase #-}
at the top of the file:set -XLambdaCase
at the GHCi promptUpvotes: 9