diff options
author | Joey Hess <joey@kitenet.net> | 2011-01-29 23:47:10 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-01-29 23:56:40 -0400 |
commit | 6d3df8a0833fdef290b76681e8ba85ec94b76e36 (patch) | |
tree | 0bb9f96e9562d27786826d3e644a326c63b6b265 /LocationLog.hs | |
parent | c64b50a0ce725df2d5317b7ae4918b61aafa25ee (diff) |
more pure code refactoring
Diffstat (limited to 'LocationLog.hs')
-rw-r--r-- | LocationLog.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/LocationLog.hs b/LocationLog.hs index 56953bc02..f778df386 100644 --- a/LocationLog.hs +++ b/LocationLog.hs @@ -104,11 +104,15 @@ readLog file = do if exists then do s <- readFile file - -- filter out any unparsable lines - return $ filter (\l -> status l /= Undefined ) - $ map read $ lines s + return $ parseLog s else return [] +parseLog :: String -> [LogLine] +parseLog s = filter parsable $ map read $ lines s + where + -- some lines may be unparseable, avoid them + parsable l = status l /= Undefined + {- Writes a set of lines to a log file -} writeLog :: FilePath -> [LogLine] -> IO () writeLog file ls = safeWriteFile file (unlines $ map show ls) |