Curry Style Guide

There is a preferred style for writing Curry programs. Following this style make it easier for others to read your programs. Of course, there might be personal preferences but, if there are no good reasons, one should follow this style. Changes of this style should be discussed in the Curry mailing list.

The style guide is available as a separate web page.

There is also some automatic support to check whether a Curry program follows some parts of this style guide. The recent releases of the Curry systems PAKCS and KiCS2 contain a style checker which can be invoked by the command

  curry style <Curry program>

It should be noted that these tools checks only a small part of the style rules (mainly indentation rules).

For instance, consider the following ugly Curry program:

  module Test where
  fib n | n==0      = 0
         | n==1 = 1
          | otherwise = fib (n-1) + fib (n-2)
  fac n = if n==0 then 1
          else n * fac (n-1)
  echo = getChar >>= \c -> if    ord c == (-1) then    done    else putChar c >> echo

Then the Curry style checker produces the following style violations:

  > curry style Test
  Line 3.7 GuardedRhs: Bars are not aligned.
  Line 3.19 GuardedRhs: Equality signs are not aligned.
  Line 7.9 IfThenElse: Wrong indentation of keywords.
  Line 10.0 Line is longer than 80 characters.
  Line 10.26 IfThenElse: Wrong indentation of subexpressions.
/srv/dokuwiki/currywiki/data/pages/documentation/style_guide.txt · Last modified: Y-m-d H:i by mh
Back to top
CC Attribution-Noncommercial-Share Alike 3.0 Unported = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0