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. A style checker for Curry is available in the Curry package `stylechecker` which can be installed via the command
cypm update && cypm install stylechecker
This installs the executable
curry-stylechecker into the directory
~/.cpm/bin (which should be added to your path).
After the successful installation,
the style checker which can be invoked by the command
curry-stylecheck <Curry program>
It should be noted that this tool 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-stylecheck Test ... Test: 3:1-5:43: Warning: `type signature` missing Hint: `top level functions` should have `type signatures` ... Test: 3:7-5:43: Warning: `guards` not aligned Hint: align `guards` ... Test: 3:7-5:43: Warning: `guard` equal signs not aligned Hint: align `guard` equal signs ... Test: 7:1-8:26: Warning: `type signature` missing Hint: `top level functions` should have `type signatures` ... Test: 7:9-8:26: Warning: `then` and `else` wrong alignement Hint: align `then` and `else` ... Test: 10:1-10:83: Warning: line too long Hint: line should be under `80` character(s) ... Test: 10:1-10:83: Warning: `type signature` missing Hint: `top level functions` should have `type signatures`