summaryrefslogtreecommitdiff
path: root/src/HStyle/Checker.hs
blob: 684f15d7a60cc7fa8ae7671c3b462ea2835377ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)]