[Haskell-cafe] do and ifthenelse indentation in GHC

Stefan Monnier monnier at iro.umontreal.ca
Thu Jun 19 17:07:13 EDT 2008

http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse says
(and my memory seems to agree) that GHC has been changed to accept
things like

   readnums f n = do eof <- hIsEOF f
                     if eof
                     then return n
                     else do l <- hGetLine f
                             readnums f (n + read l)

where the `then' and `else' are aligned with the `if' rather than being
slightly more indented as the Haskell 98 standard requires.
Yet, when I try it with GHCi 6.8.2 I get an error:

   Prelude> :load "/home/monnier/tmp/foo.hs"
   [1 of 1] Compiling Main      ( /home/monnier/tmp/foo.hs, interpreted )
       parse error (possibly incorrect indentation)
   Failed, modules loaded: none.

Does anybody know what's up with that?


More information about the Haskell-Cafe mailing list