Reputation: 103
When I run this code:
test1 :: Int -> String
test1 x = do
if x == 1
then "Hello"
I get the following error:
test-if.hs:4:21: error:
parse error (possibly incorrect indentation or mismatched brackets)
I am not sure why this is as I am not using any brackets and I am using 4 spaces as my tabs. Adding brackets doesn't seem to help. What could be the issue?
Thanks
Upvotes: 1
Views: 258
Reputation: 370465
Your if
needs an else
(what do you want the value to be when x
isn't 1?).
Furthermore do
notation is used when working with monads and doesn't make sense in this function.
Upvotes: 5