I am sure this is an artifact of intentionally changing the GHC in the indentation rule . Good catch!
Ghc reads this
foo = do item if a then b else c item
but
foo = do { item ; if a ; then b ; else c ; item }
which should cause a parsing error.
However, it was so common that at some point, the GHC developers decided to enable the option ; to then and else . This change in the if grammar makes code compilation.
This means that if become βspecialβ since it should not be indented anymore, but only as much as the previous element. In the code placed in the question, then is indented in the same way as the previous element, so there is an implicit one in front of it ; , and it does code compilation.
I would still try to avoid this "style", though, since itβs bizarre.
(Personally, I would not add this special case to the GHC, but this is not very important.)
Now I noticed that Wikibook mentions this option as a "suggestion" for a future version of Haskell. This is a bit outdated now, and has since been implemented in the GHC.
chi
source share