indention of guards in functions inside instance declaration

Rick Hu 1.rick.hu at gmail.com
Thu Jun 14 20:37:41 BST 2012


Hi,

I am using latest haskell-mode (as of now) cloned from git-hub, and emacs
version 23.1.1 on Ubuntu 10.04 LTS.

When I try to write guard in a function inside an instance declaration, the
indention of guards is wrong.  Haskell mode wants to start the first guard
at the beginning of the line, and subsequent guards at two spaces(?) to the
right, like the following

instance Monoid.Monoid IntFlag where
  mempty = IntFlag 0
  mappend (IntFlag x) (IntFlag y)
| x > 0 = IntFlag 1
  | x < 0 = IntFlag (-1)
  | otherwise = IntFlag y
  mconcat [] = IntFlag 0
  mconcat ((IntFlag x):xs)
  | x > 0 = IntFlag 1
  | x < 0 = IntFlag (-1)
    | otherwise = Monoid.mconcat xs

I think the correct indention should be

instance Monoid.Monoid IntFlag where
  mempty = IntFlag 0
  mappend (IntFlag x) (IntFlag y)
    | x > 0 = IntFlag 1
    | x < 0 = IntFlag (-1)
    | otherwise = IntFlag y
  mconcat [] = IntFlag 0
  mconcat ((IntFlag x):xs)
    | x > 0 = IntFlag 1
    | x < 0 = IntFlag (-1)
    | otherwise = Monoid.mconcat xs

Thanks for your help!

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://projects.haskell.org/pipermail/haskellmode-emacs/attachments/20120614/541ad31a/attachment.htm>


More information about the Haskellmode-emacs mailing list