ghc-mod/Lint.hs
2010-05-07 16:03:57 +09:00

21 lines
557 B
Haskell

module Lint where
import Control.Applicative
import Data.List
import System.IO
import System.Process
import Types
lintSyntax :: Options -> String -> IO String
lintSyntax cmd file = pretty <$> lint cmd file
where
pretty = unlines . map (concat . intersperse "\0")
. filter (\x -> length x > 1)
. groupBy (\a b -> a /= "" && b /= "")
. lines
lint :: Options -> String -> IO String
lint cmd file = do
(_,hout,_,_) <- runInteractiveProcess (hlint cmd) ["-i","Use camelCase",file] Nothing Nothing
hGetContents hout