[Haskell-cafe] Code layout in Emacs' haskell-mode

Roberto Zunino zunino at di.unipi.it
Mon May 14 13:05:46 EDT 2007


Nick Meyer wrote:
> main = do putStrLn "Enter a number: "
>          inp <- getLine
>          let n = read inp
>          if n == 0
>          then putStrLn "Zero"
>          else putStrLn "NotZero"
> 
> (that's with all the expressions in the do block lining up vertically, if
> that doesn't show up in a fixed-width font), it works!  I would think that
> your original indentation gave an error in that GHC would see "then" and
> "else" and assume they were new expressions, but then I would expect that
> this would have the same problem.  If anyone can shed some light on this,
> that would be nice.

http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse
says "already implemented in GHC and Hugs".

Zun.


More information about the Haskell-Cafe mailing list