[html docu
Christian.Maeder@dfki.de**20100316145817
Ignore-this: 2f9903d57c83ccb83d74a1e758fac155
] addfile ./doc/index.html
hunk ./doc/index.html 1
+
+
+
+style scanner
+
+
+
+Haskell style scanner
+
+The program was inspired by a python script (called
+haskell_style_check) from
+www.cs.caltech.edu/courses/cs11/material/haskell/misc/haskell_style_guide.html
+that reports:
+
+- TABS
+- LINE IS TOO LONG
+- PUT SPACE AFTER COMMA
+- PUT SPACE AROUND OPERATORS
+- PUT SPACE AFTER OPEN COMMENT
+
+
+The program scan is
+supposed to serve the same purpose (although it does not yet follow all of the
+above style guides itself, i.e. displaying a usage message).
+
+
+The main difference is that the scanner is better aware about the haskell tokens
+and comments (and that it is written in Haskell).
+
+
+Usage
+
+scan [-] <filename>+
+
+scan expects at least one filename on the command line. The
+corresponding file is scanned and diagnostic messages are output. If
+scan seems to do nothing despite a valid filename it simply means that
+the file passed all style checks, which is a good sign but pretty unlikely for
+haskell code that has not been scanned before.
+
+scan
+ does not change your file unless you add the
+-
+ option
+that is explained below.
+
+
Examples
+missing
+
+Related application
+
+Another inspiration for the scanner
+was hlint that is based
+on a parser from
+haskell-src-exts
+and also gives you hints to improve your source code on the expression level,
+like:
+
+
+- Redundant
+ - brackets
+ - lambda
+ - return
+ - do
+ - if
+ - $
+
+ - Use camelCase
+- Eta reduce
+- Use null, etc.
+
+
+Combined application
+
+Assuming that you install scan and hlint using "cabal
+ install" (in your local repository), you can use a combined checking
+shell script:
+
+
+#!/bin/sh
+for f in $@
+do
+ $HOME/.cabal/bin/scan $f
+ $HOME/.cabal/bin/hlint -i "Use infix" $f
+## haddock -w $f
+done
+
+
+You may pass any (or none) -i option to hlint you want.
+(The example just reflects my preference to use identifiers as prefixes.)
+
+
+Calling haddock on a file
+without knowing the ghc compiler flags is usually a bad idea, but
+might be used to spot haddock parsing problems earlier.
+
+
+
+
+The -i option of scan allows you to write back an adjusted
+source file, that may, however, be no longer valid haskell due to insertion or
+deletion of blanks. At the moment the following changes are applied:
+
+
+ - spaces are insert after commas
+ - spaces are insert around infix operators
+ - spaces between parens and infix operators within sections are
+ removed
+ - tabs are replaced by blanks (but not within comments)
+ - carriage returns will be removed (but not within comments)
+
- trailing white spaces are removed (but not within comments)
+ - more than one leading blank line, or more than two consecutive blanks,
+ and any final blank lines are removed
+ - the file will end with a single final newline
+
+
+It needs to be pointed out, that the notion of infix operators is broader here
+than the haskell notion of it. The key symbols like |, \, =, <-, ->, =>,
+ :: are also treated like infix operators (but not @, ~).
+
+
+The unary and binary minus are distinguished. I.e. (-x) requires no
+space but y - x does.
+
+
+
+To keep the loss risk low, backup files will be created with
+the extension .bak and not more than three files on the command line
+will be accepted.
+
+
+Things to do
+
+
+- add more options and support different styles
+
+ - option for line length (currently 80)
+
+
+- also support cleaning white spaces in comments
+
+
+
+