I'm having a weird error in this simple haskell code. I confirm I'm using spaces everywhere and I don't see any problem with indentation.
Am I missing something to have this syntax error?
it "I can play with Maybe a bit" $ do
let b = Just "whatever"
let res = case b of
Just val -> "There is a value, and it is a value" --parse error on input ‘->’
Nothing -> "There is nothing!"
res `shouldBe` "There is a value, and it is a value"
The indentation level of the cases should be at least one space more than the start of the variable name of the let statement, like:
let res = case b of
Just val -> "There is a value, and it is a value"
Nothing -> "There is nothing!"
If you write it on the same level as where res
starts, it is parsed as if it is part of the let
block, and not of the case
in the let
block.
Similarly, if you write it less indented than res
, it is parsed as if it is part of the do
block, and not of the case
.
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