Skip to content

Commit f75894c

Browse files
committed
Partition pragmas
1 parent a122f78 commit f75894c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Hint/Comment.hs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@ directives = words $
3434
"CONLIKE LINE SPECIALIZE SPECIALISE UNPACK NOUNPACK SOURCE"
3535

3636
data Comments = Comments
37-
{ commBlocks :: ![LEpaComment]
37+
{ commPragma :: ![LEpaComment]
38+
, commBlocks :: ![LEpaComment]
39+
-- TODO: Process the different types of block comments; [" |",""].
40+
-- * Haddock comments
41+
-- * Simple comments
3842
, commRuns :: ![[LEpaComment]]
3943
, commLines :: ![LEpaComment]
4044
}
4145

4246
classifyComments :: [LEpaComment] -> Comments
43-
classifyComments xs = Comments blocks runs lines where
44-
(blocks, singles) = partition isCommentMultiline xs
47+
classifyComments xs = Comments pragmas blocks runs lines where
48+
(partition isCommentPragma -> (pragmas, blocks), singles) = partition isCommentMultiline xs
4549
(concat -> lines, runs) = partition ((== 1) . length) $ commentRuns singles
4650

4751
commentRuns :: [LEpaComment] -> [[LEpaComment]]
@@ -109,6 +113,7 @@ commentHint _ m =
109113
-- b) runs of single-line comments
110114
-- c) single-line comments
111115
-- TODO: Remove (True, _) runs and then run the other checks on the rest.
116+
traceShow ("pragmas", commentText <$> pragmas) $
112117
traceShow ("blocks", commentText <$> blocks) $
113118
traceShow ("runs", fmap commentText <$> rawRuns) $
114119
traceShow ("lines", commentText <$> lines) $
@@ -125,7 +130,7 @@ commentHint _ m =
125130
singleLines = sort $ commentLine <$> filter isSingle comments
126131
someLines = sort $ commentLine <$> filter isSingleSome comments
127132

128-
Comments blocks rawRuns lines = classifyComments comments
133+
Comments pragmas blocks rawRuns lines = classifyComments comments
129134

130135
runs = dropBlankLinesHint <$> rawRuns
131136

0 commit comments

Comments
 (0)