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

Christopher L Conway cconway at cs.nyu.edu
Mon May 14 12:57:32 EDT 2007


On 5/14/07, David House <dmhouse at gmail.com> wrote:
> You should install 2.3 from the haskell-mode page [1]. Isaac Jones,
> maintainer of the Debian haskell-mode package has been contacted in
> order to get the latest version in the Debian repository, so it should
> happen soon, but in the mean time you could download and install the
> latest version yourself. It features quite a few bugfixes and new
> features that I imagine are documented on the aforementioned page.

I've installed 2.3 and it exhibits the same indentation behavior: any
entity appearing on a new line immediately after "module X where"
wants to be indented 4 spaces, including function definitions and
variable bindings. "if-then-else" want to be lined up with one
another, although both GHC and Hugs reject this layout.

Here's the result of indent-region on the prior example:

module Num where

    import IO

        main = do
             putStrLn "Enter a number: "
                      inp <- getLine
                             let n = read inp
                                     if n == 0
                                     then putStrLn "Zero"
                                     else putStrLn "NotZero"

This is distressing, because I've gotten rather used to letting Emacs
worry about indentation for me. (This works well in tuareg-mode for
OCaml. But, as I said earlier, I am a layout-sensitive-language
newbie.)

Chris


More information about the Haskell-Cafe mailing list