Good Haskell Style

David Roundy droundy at
Wed Aug 1 16:21:41 EDT 2007

On Wed, Aug 01, 2007 at 01:06:07PM -0700, Iavor Diatchki wrote:
> Hi,
> > * Don't leave trailing white space in your code
> > * Don't use tabs
> > * Aim to keep lines under 80 characters
> > * Use the CamelCase variable naming convention
> > * Don't use explicit braces and semicolons
> I like using underscores in values, and CamelCase in types---I find
> that the extra space makes the identifiers more readable.  Despite the
> fact that I tend to write code that follows these conventions (except
> for bullet 4), I find the rules to be extremely arbitrary and I do not
> think that they should be given any special status.

The use of tabs can easily make code unreadable on other developers'
editors.  It's a bad idea, not an arbitrary convention.

Keeping the line width down is useful for making code readable on folks
with smaller monitors or larger fonts.  And note that it says "Aim", which
means that if it impairs readability in the judgement of the developer,
it's not a violation.

Trailing white space doesn't particularly hurt, except if you're using
version control, in which case any removal of white space is liable to
conflict with actual coding changes, so it's better to have a policy that
it shouldn't be included.  I've certainly never heard of a scenario in
which trailing white space is beneficial.

The last one "Don't use explicit braces and semicolons" does seem a bit
arbitrary and heavy-handed.  I'd rather not use them myself, but wouldn't
complain of a developer who does so.

> PS: While we are discussing style, what should be the blessed amount
> of indentation ;-)  I vote for 2 spaces.

That's certainly something that shouldn't be in a coding guide.
David Roundy
Department of Physics
Oregon State University

More information about the Libraries mailing list