Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (27 sloc) 1.068 kb
-- Copyright (c) 2007-2008 by Leif Frenzel <himself@leiffrenzel.de>
-- All rights reserved.
module ValidateCabalFile where
import Data.Maybe( fromMaybe )
import Distribution.PackageDescription( parsePackageDescription )
import Distribution.InstalledPackageInfo( ParseResult(..) )
import Distribution.ParseUtils( locatedErrorMsg )
import Cohatoe.API
import Cohatoe.Data
resource :: Interface
resource = plugin {
pluginMain = performPluginMain
}
performPluginMain :: [String] -> IO [String]
performPluginMain [] = return []
performPluginMain (cabalFile:_) = do
descs <- validateCabalFile cabalFile
return $ concatMap marshal descs
validateCabalFile :: FilePath -> IO [MarkerDesc]
validateCabalFile fpath = do
str <- readFile fpath
case parsePackageDescription str of
ParseFailed err -> do
let (lineNo, msg) = locatedErrorMsg err
let ln = fromMaybe (-1) lineNo
return [ MarkerDesc fpath ln unspecified msg unspecified unspecified Error ]
ParseOk warns _ -> return $ map (mkWarning fpath) warns
Jump to Line
Something went wrong with that request. Please try again.