module Projmd.Config ( Config (..) , loadConfig ) where import Data.List ( isPrefixOf ) data Config = Config { darcsRepoDir :: FilePath , excludedProjects :: [FilePath] , pageUrlPattern :: String , srcUrlPattern :: String } deriving (Read, Show) loadConfig :: FilePath -> IO Config loadConfig path = (read . removeComments) <$> readFile path {- Auto-derived Read instancing has no idea how to handle Haskell source code commenting. This will strip out very simple -- style comments. -} removeComments :: String -> String removeComments = unlines . map removeComment . lines where removeComment = unwords . (takeWhile (not . isPrefixOf "--")) . words