Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from norm2782/master

Make hstyle compile on GHC 7.2
  • Loading branch information...
commit f864167c88d8260aa3fd0247369cacadb9db1d1e 2 parents 1e93c9b + 76eb899
@mightybyte authored
Showing with 11 additions and 12 deletions.
  1. +2 −3 hstyle.cabal
  2. +9 −9 src/Main.hs
View
5 hstyle.cabal
@@ -1,5 +1,5 @@
name: hstyle
-version: 0.1
+version: 0.2
synopsis: Checks Haskell source code for style compliance.
description: Originally intended to automate style checking for the Snap
project. But the project should be general enough to work
@@ -14,14 +14,13 @@ category: Development
extra-source-files:
README.md
-
+
Executable hstyle
hs-source-dirs: src
main-is: Main.hs
build-depends:
base >= 4 && < 5,
- haskell98,
text >= 0.11 && < 0.12
if impl(ghc >= 6.12.0)
View
18 src/Main.hs
@@ -7,7 +7,8 @@ checks and automatic fixes implemented eventually.
-}
module Main where
-import System
+import System.Environment
+import System.Exit
import qualified Data.Text as T
import qualified Data.Text.IO as TI
@@ -69,25 +70,25 @@ lineChecks = [lineLength 78, noTabs, trailingSpaces]
-- | Applies a list of checks to a list of lines. Returns a list of
-- 'Problem's.
onLines :: [Check] -> [Text] -> [Problem]
-onLines fs thelines = concat $ map (go 1 thelines) fs
+onLines fs thelines = concatMap (go 1 thelines) fs
where
go _ [] _ = []
go num (l:ls) f = case f l of
Nothing -> go (num+1) ls f
- Just er -> (Problem num er) : go (num+1) ls f
+ Just er -> Problem num er : go (num+1) ls f
------------------------------------------------------------------------------
-- | Breaks a file into lines and runs all the checks on them.
checkContents :: Text -> [Problem]
-checkContents c = lineChecks `onLines` (T.lines c)
+checkContents c = lineChecks `onLines` T.lines c
------------------------------------------------------------------------------
-- | Runs checks on the specified file.
checkFile :: FilePath -> IO (FilePath, [Problem])
checkFile f = do
- problems <- return . checkContents =<< TI.readFile f
+ problems <- return . checkContents =<< TI.readFile f
return (f,problems)
@@ -103,15 +104,14 @@ checkStyle fs = do
_ -> exitWith (ExitFailure 1)
where
printResults (f,ps) = mapM_ (printRes f) ps
- printRes f p = putStrLn $ f ++ " line " ++ (show $ probLine p) ++
- ": " ++ (probDescription p)
+ printRes f p = putStrLn $ f ++ " line " ++ show (probLine p) ++
+ ": " ++ probDescription p
------------------------------------------------------------------------------
-- | Placeholder for fixing style problems.
fixStyle :: t -> a
-fixStyle _ = do
- error "Not implemented"
+fixStyle _ = error "Not implemented"
------------------------------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.