I have the following code
{-# LANGUAGE Arrows #-}
test :: Int -> Int
test =
proc x -> do
let x = case x of
3 -> 2
2 -> 1
_ -> 0
returnA -< x
test2 =
proc x -> do
let x =
case x of
3 -> 2
2 -> 1
_ -> 0
returnA -< x
test compiles, but test2 does not parse. Is it possible to have the case on a separate line after the =?
This is unrelated to proc
notation. The case
must be at least as indented as one character after the start name being bound by let
.
For example, this compiles:
test x =
let y =
case x of
3 -> 2
1 -> 1
_ -> 0
in ()
and so does this:
test2 x =
let abcdefghi =
case x of
3 -> 2
1 -> 1
_ -> 0
in ()
but this doesn't:
test3 x =
let abcdefghi =
case x of
3 -> 2
1 -> 1
_ -> 0
in ()
because the case
is at the same level as the first character of abcdefghi
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With