equal
deleted
inserted
replaced
54 repConfig k rv conf = let f _ = Just rv |
54 repConfig k rv conf = let f _ = Just rv |
55 in M.alter f k conf |
55 in M.alter f k conf |
56 |
56 |
57 -- |Reads a file and parses to a Map String String. |
57 -- |Reads a file and parses to a Map String String. |
58 readConfig :: FilePath -> IO Conf |
58 readConfig :: FilePath -> IO Conf |
59 readConfig path = liftM (M.fromList . map ((\(a, b) -> (filter (not . isSpace) a, dropWhile isSpace b)) . break (== '=')) . filter (not . null) . lines) $ readFile path |
59 readConfig path = liftM (M.fromList . map ((\(a, b) -> (filter (not . isSpace) a, dropWhile isSpace $ tail b)) . break (== '=')) . filter (not . null) . lines) $ readFile path |
60 |
60 |
61 -- |Parses a parsed configuration back to a file. |
61 -- |Parses a parsed configuration back to a file. |
62 writeConfig :: FilePath -> Conf -> IO () |
62 writeConfig :: FilePath -> Conf -> IO () |
63 writeConfig path = writeFile path . unlines . map (\(a, b) -> a ++ " = " ++ b) . M.toList |
63 writeConfig path = writeFile path . unlines . map (\(a, b) -> a ++ " = " ++ b) . M.toList |