[Haskell-beginners] How to include {-# LANGUAGE LambdaCase #-} at the ghci prompt
Francesco Ariis
fa-ml at ariis.it
Fri Mar 26 17:31:53 UTC 2021
Il 26 marzo 2021 alle 12:20 Galaxy Being ha scritto:
> I've got this code I've entered into the ghci by hand between :{ and :}
>
> :{
> {-# LANGUAGE LambdaCase #-}
> data List a = Empty | Cons a (List a) deriving (Eq, Ord, Show)
> infixr 5 `Cons`
>
> subst_c :: (a -> Bool) -> (a, MyList a) -> MyList a
> subst_c pred = \ case
> (_, Empty) -> Empty
> (n, Cons e t)
> | pred e -> Cons n $ subst_c pred (n, t)
> | otherwise -> Cons e $ subst_c pred (n, t)
> :}
>
λ> :set -XLambdaCase
More information about the Beginners
mailing list