DoAndIfThenElse

Christian Maeder Christian.Maeder at dfki.de
Fri Nov 27 13:14:03 EST 2009


S. Doaitse Swierstra schrieb:
[..]
>> \begin{code}
>> main = do
>>  if True then putStrLn "1";
>>  else putStrLn "2"
>> \end{code}
>>
>> This does also not work with hugs (";" at the end)
> 
> This does not work since now you have two ";"'s; one because you wrote
> one and one because you did not indent the else. Allowing this
> additional ; was done to prevent confusion, and as you can see even more
> confusion pops up now;-{{ That is why I expressed my concerns about this
> grammar patch.
> 
>  Doaitse

Indeed, these semicolons are confusing. I think it should be possible to
allow "then" and "else" starting in the same column as "if" without
these ";"s (in a do block).

Christian



More information about the Haskell-prime mailing list