Module Hygiene


module Hygiene: sig .. end
Module for checking that the source tree is not polluted by object files.


type rule =
| Implies_not of pattern * pattern (*The rule Implies_not(".mll",".ml") is broken if there is a file foo.mll together with a file foo.ml int the same directory. The second file can get sanitized.*)
| Not of pattern
Sanity rules to abide. Not to be confused with compilation rules.
type pattern = suffix 
Suffix matching is enough for the purpose of this module.
type suffix = string 
And a suffix is a string.

type penalty =
| Warn
| Fail
A warning is simply displayed. A failures stops the compilation.

type law = {
   law_name : string; (*The name of the law that will be printed when it is violated.*)
   law_rules : rule list; (*Breaking any of these rules is breaking this law.*)
   law_penalty : penalty; (*Breaking the law gives you either a warning or a failure.*)
}
This type is used to encode laws that will be checked by this module.
val check : ?sanitize:string ->
law list -> bool Slurp.entry -> (law * string list) list
check ~sanitize laws entry will scan the directory tree entry for violation to the given laws. Any warnings or errors will be printed on the stdout. If sanitize is Some fn, a shell script will be written into the file fn with commands to delete the offending files. The command will return a pair (fatal, penalties) where fatal is true when serious hygiene violations have been spotted, and penalties is a list of laws and messages describing the offenses.