Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
documentation:style_guide [2017-02-24 13:21]
mh created
documentation:style_guide [2019-10-22 09:15]
mh
Line 13: Line 13:
 There is also some automatic support to check whether a Curry program follows There is also some automatic support to check whether a Curry program follows
 some parts of this style guide. some parts of this style guide.
-The recent releases of the Curry systems +A style checker for Curry is available in the Curry package `stylechecker` 
-[[http://​www.informatik.uni-kiel.de/​~pakcs/​ | PAKCS]] and +which can be installed via the command
-[[http://​www-ps.informatik.uni-kiel.de/​kics2 | KiCS2]] +
-contain a style checker ​which can be invoked by the command+
  
-    ​curry style <Curry program>+    ​cypm update && cypm install stylechecker
  
-It should be noted that these tools checks only a small part of+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). 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`
  
/srv/dokuwiki/currywiki/data/pages/documentation/style_guide.txt · Last modified: 2019-10-22 09:15 by mh
Back to top
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0