1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
module Config.Types where
import List (isInfixOf)
import Pretty ((<+>), (<$$>), pPrint, text)
data Check
= CDataBars
| CDataComponents
| CDataConstructors
| CCase
| CExportList
| CIfThenElseKW
| CIfThenElseSubExpr
| CImport
| CLet
| CLineLength
| CRecordCommas
| CRecordDoubleColons
| CRecordFieldNames
| CRecordTypes
| CRhsBars
| CRhsEq
| CTypeArrow
cvCheck :: String -> Check
cvCheck s
| isInfixOf "LineLength" s = CLineLength
| isInfixOf "Data.Bars" s = CDataBars
| isInfixOf "Data.Components" s = CDataComponents
| isInfixOf "Data.Constructors" s = CDataConstructors
| isInfixOf "Export.List" s = CExportList
| isInfixOf "Expression.Case" s = CCase
| isInfixOf "Expression.IfThenElseKW" s = CIfThenElseKW
| isInfixOf "Expression.IfThenElseSubExpr" s = CIfThenElseSubExpr
| isInfixOf "Expression.Let" s = CLet
| isInfixOf "Import.Explicit" s = CImport
| isInfixOf "Record.Commas" s = CRecordCommas
| isInfixOf "Record.DoubleColons" s = CRecordDoubleColons
| isInfixOf "Record.FieldNames" s = CRecordFieldNames
| isInfixOf "Record.Types" s = CRecordTypes
| isInfixOf "Rhs.Bars" s = CRhsBars
| isInfixOf "Rhs.Eq" s = CRhsEq
| isInfixOf "Type.Arrow" s = CTypeArrow
| otherwise = error help
configName :: String
configName = ".cascrc"
defaultCfg :: [(Check, Int)]
defaultCfg = map (\ c -> (c, 1))
[ CDataBars
, CDataComponents
, CDataConstructors
, CCase
, CExportList
, CIfThenElseKW
, CIfThenElseSubExpr
, CImport
, CLet
, CLineLength
, CRecordCommas
, CRecordDoubleColons
, CRecordFieldNames
, CRecordTypes
, CRhsBars
, CRhsEq
, CTypeArrow
]
defaultLgth :: Int
defaultLgth = 80
defaultAutoC :: String
defaultAutoC = "no"
help :: String
help = pPrint $
text "Syntax error in config file. Here are some tips:"
<$$> text "* Comments start with '--'"
<$$> text "* The list of available checks has to be completed"
<+> text "with numbers 0-2 like this:"
<$$> text "** 0: don't check"
<$$> text "** 1: check and show warn message"
<$$> text "** 2: check and correct automatically if possible"
<$$> text "* maxLength specifies the desired maximum for the check"
<+> text "LineLength and has to be a natural number < 1000."
|