Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Split Types into (Selector, Checker)

  • Loading branch information...
commit 344f74ce559b790cc82580ef8f5d01f9c30fd000 1 parent 7044918
@jaspervdj jaspervdj authored
View
12 src/HStyle.hs
@@ -13,7 +13,11 @@ import qualified Language.Haskell.Exts.Annotated as H
import HStyle.Alignment
import HStyle.Block
-import HStyle.Types
+import HStyle.Selector
+import HStyle.Checker
+
+-- | A selector and a check...
+type Rule = (Selector, Check)
runRule :: Block -> H.Module H.SrcSpanInfo -> Rule -> IO ()
runRule block md (selector, check) = forM_ (selector md block) $ \block' -> do
@@ -47,12 +51,6 @@ typeSigCheck block = case checkAlignment alignment of
where
alignment = alignmentOf ["::", "=>", "->"] $ toLines block
-selectAll :: Selector
-selectAll _ = return
-
-selectLines :: Selector
-selectLines _ = perLine
-
tabsCheck :: Check
tabsCheck block = do
(ln, text) <- zip [1 ..] (toLines block)
View
12 src/HStyle/Types.hs → src/HStyle/Checker.hs
@@ -1,7 +1,5 @@
-module HStyle.Types
- ( Selector
- , Check
- , Rule
+module HStyle.Checker
+ ( Check
) where
import Data.Text (Text)
@@ -9,12 +7,6 @@ import Language.Haskell.Exts.Annotated (Module, SrcSpanInfo)
import HStyle.Block
--- | Selects a portion from a haskell module
-type Selector = Module SrcSpanInfo -> Block -> [Block]
-
-- | Takes a number of lines, and notifies of problems on each line. Indices in
-- the result are 1-based.
type Check = Block -> [(Int, Text)]
-
--- | A selector and a check...
-type Rule = (Selector, Check)
View
18 src/HStyle/Selector.hs
@@ -0,0 +1,18 @@
+module HStyle.Selector
+ ( Selector
+ , selectAll
+ , selectLines
+ ) where
+
+import Language.Haskell.Exts.Annotated (Module, SrcSpanInfo)
+
+import HStyle.Block
+
+-- | Selects a portion from a haskell module
+type Selector = Module SrcSpanInfo -> Block -> [Block]
+
+selectAll :: Selector
+selectAll _ = return
+
+selectLines :: Selector
+selectLines _ = perLine
Please sign in to comment.
Something went wrong with that request. Please try again.