Skip to content

Commit 1a107f5

Browse files
committed
change criterion to two consecutive capitals
1 parent bd5cb3c commit 1a107f5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/Hint/NoCapitalisms.hs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
{-
44
Detect uses of capitalisms
55
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.
88
99
Identifiers containing underscores are exempted from thus rule.
1010
Identifiers of FFI bindings are exempted from thus rule.
1111
1212
Locally bound identifiers and module names are not checked.
1313
1414
<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
1622
class FOO a where -- @Ignore
1723
class Foo a where getFOO :: Bool
1824
data Foo = Bar | BAAZ -- @Ignore
@@ -72,13 +78,13 @@ hasUnderscore :: String -> Bool
7278
hasUnderscore = elem '_'
7379

7480
hasCapitalism :: String -> Bool
75-
hasCapitalism s = any isAllUpper (trigrams s)
81+
hasCapitalism s = any isAllUpper (bigrams s)
7682
where
7783
isAllUpper = all isUpper
7884

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)
8288
_otherwise -> []
8389

8490
--- these are copied from Hint.Naming ---

0 commit comments

Comments
 (0)