|
3 | 3 | {- |
4 | 4 | Detect uses of capitalisms |
5 | 5 |
|
6 | | - Only allow up to two consecutive capital letters in top level |
7 | | - identifiers. |
| 6 | + Do not allow two consecutive capital letters in top level |
| 7 | + identifiers of types, classes, values and constructors. |
8 | 8 |
|
9 | 9 | Identifiers containing underscores are exempted from thus rule. |
10 | 10 | Identifiers of FFI bindings are exempted from thus rule. |
11 | 11 |
|
12 | 12 | Locally bound identifiers and module names are not checked. |
13 | 13 |
|
14 | 14 | <TEST> |
15 | | -data LHsDecl |
| 15 | +data IO -- @Ignore |
| 16 | +data PersonID = P -- @Ignore |
| 17 | +sendIO :: IO () -- @Ignore |
| 18 | +sendIO = _ -- @Ignore |
| 19 | +class HasIO where -- @Ignore |
| 20 | +data Foo = FO -- @Ignore |
| 21 | +data LHsDecl -- @Ignore |
16 | 22 | class FOO a where -- @Ignore |
17 | 23 | class Foo a where getFOO :: Bool |
18 | 24 | data Foo = Bar | BAAZ -- @Ignore |
@@ -72,13 +78,13 @@ hasUnderscore :: String -> Bool |
72 | 78 | hasUnderscore = elem '_' |
73 | 79 |
|
74 | 80 | hasCapitalism :: String -> Bool |
75 | | -hasCapitalism s = any isAllUpper (trigrams s) |
| 81 | +hasCapitalism s = any isAllUpper (bigrams s) |
76 | 82 | where |
77 | 83 | isAllUpper = all isUpper |
78 | 84 |
|
79 | | -trigrams :: String -> [String] |
80 | | -trigrams = \case |
81 | | - a:b:c:as -> [a,b,c] : trigrams (b:c:as) |
| 85 | +bigrams :: String -> [String] |
| 86 | +bigrams = \case |
| 87 | + a:b:as -> [a,b] : bigrams (b:as) |
82 | 88 | _otherwise -> [] |
83 | 89 |
|
84 | 90 | --- these are copied from Hint.Naming --- |
|
0 commit comments