I\'m learning Haskell in the hope that it will help me get closer to functional programming. Previously, I\'ve mostly used languages with C-like syntax, like C, Java, and D.
The way Haskell interprets if ... then ... else
within a do
block is very much in keeping with the whole of Haskell's syntax.
But many people prefer a slightly different syntax, permitting then
and else
to appear at the same indentation level as the corresponding if
. Therefore, GHC comes with an opt-in language extension called DoAndIfThenElse
, which permits this syntax.
The DoAndIfThenElse
extension is made into part of the core language in the latest revision of the Haskell specification, Haskell 2010.