From 8e172fab3dade5502088c98cac1f7e1c0ef5c444 Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Fri, 2 Aug 2024 09:52:13 -0400 Subject: [PATCH] . --- src/Hint/Comment.hs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Hint/Comment.hs b/src/Hint/Comment.hs index cc410e8d..a20fa1fa 100644 --- a/src/Hint/Comment.hs +++ b/src/Hint/Comment.hs @@ -34,20 +34,15 @@ directives = words $ "CONLIKE LINE SPECIALIZE SPECIALISE UNPACK NOUNPACK SOURCE" data Comments = Comments - { commBlocks :: [[LEpaComment]] - , commRuns :: [[LEpaComment]] - , commLines :: [LEpaComment] + { commBlocks :: ![LEpaComment] + , commRuns :: ![[LEpaComment]] + , commLines :: ![LEpaComment] } classifyComments :: [LEpaComment] -> Comments -classifyComments xs = Comments blocks runs lines - where - blocks = [] - runs = commentRuns xs - lines = [] - -commentBlocks :: [LEpaComment] -> [[LEpaComment]] -commentBlocks = undefined +classifyComments xs = Comments blocks runs lines where + (blocks, singles) = partition isCommentMultiline xs + (concat -> lines, runs) = partition ((== 1) . length) $ commentRuns singles commentRuns :: [LEpaComment] -> [[LEpaComment]] commentRuns comments = @@ -114,6 +109,9 @@ commentHint _ m = -- b) runs of single-line comments -- c) single-line comments -- TODO: Remove (True, _) runs and then run the other checks on the rest. + traceShow ("blocks", commentText <$> blocks) $ + traceShow ("runs", fmap commentText <$> rawRuns) $ + traceShow ("lines", commentText <$> lines) $ if any fst runs then concatMap snd runs else concatMap (check singleLines someLines) comments @@ -127,7 +125,7 @@ commentHint _ m = singleLines = sort $ commentLine <$> filter isSingle comments someLines = sort $ commentLine <$> filter isSingleSome comments - Comments _blocks rawRuns _lines = classifyComments comments + Comments blocks rawRuns lines = classifyComments comments runs = dropBlankLinesHint <$> rawRuns