summaryrefslogtreecommitdiff
path: root/src/HStyle/Checker.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/HStyle/Checker.hs')
-rw-r--r--src/HStyle/Checker.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/HStyle/Checker.hs b/src/HStyle/Checker.hs
new file mode 100644
index 0000000..684f15d
--- /dev/null
+++ b/src/HStyle/Checker.hs
@@ -0,0 +1,20 @@
+module HStyle.Checker
+ ( Checker
+ , checkLines
+ ) where
+
+import Data.Text (Text)
+
+import HStyle.Block
+
+-- | Takes a number of lines, and notifies of problems on each line. Indices
+-- in the result are 1-based.
+type Checker = Block -> [(Int, Text)]
+
+-- | Check every line of the block, possibly returning a problem description
+checkLines :: (Text -> Maybe Text) -> Checker
+checkLines checker block = do
+ (ln, text) <- zip [1 ..] (toLines block)
+ case checker text of
+ Nothing -> []
+ Just p -> [(ln , p)]