From 8405072ff6973b492ee2b4b23281de8f849c4967 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 20 Dec 2009 15:50:54 +0000 Subject: [PATCH] refactor --- Ledger/Journal.hs | 20 ++++++++++---------- Ledger/Parse.hs | 2 +- Utils.hs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Ledger/Journal.hs b/Ledger/Journal.hs index b657acfc0..48562d15e 100644 --- a/Ledger/Journal.hs +++ b/Ledger/Journal.hs @@ -29,16 +29,16 @@ instance Show Journal where -- ++ (show $ journalTransactions l) where accounts = flatten $ journalAccountNameTree l -journalEmpty :: Journal -journalEmpty = Journal { jmodifiertxns = [] - , jperiodictxns = [] - , jtxns = [] - , open_timelog_entries = [] - , historical_prices = [] - , final_comment_lines = [] - , filepath = "" - , filereadtime = TOD 0 0 - } +nulljournal :: Journal +nulljournal = Journal { jmodifiertxns = [] + , jperiodictxns = [] + , jtxns = [] + , open_timelog_entries = [] + , historical_prices = [] + , final_comment_lines = [] + , filepath = "" + , filereadtime = TOD 0 0 + } addTransaction :: Transaction -> Journal -> Journal addTransaction t l0 = l0 { jtxns = t : jtxns l0 } diff --git a/Ledger/Parse.hs b/Ledger/Parse.hs index d93b8d778..eb189c8a9 100644 --- a/Ledger/Parse.hs +++ b/Ledger/Parse.hs @@ -73,7 +73,7 @@ parseLedgerFile t f = liftIO (readFile f) >>= parseLedger t f parseLedger :: LocalTime -> FilePath -> String -> ErrorT String IO Journal parseLedger reftime inname intxt = case runParser ledgerFile emptyCtx inname intxt of - Right m -> liftM (journalConvertTimeLog reftime) $ m `ap` return journalEmpty + Right m -> liftM (journalConvertTimeLog reftime) $ m `ap` return nulljournal Left err -> throwError $ show err diff --git a/Utils.hs b/Utils.hs index d9f40a480..68250e35a 100644 --- a/Utils.hs +++ b/Utils.hs @@ -34,7 +34,7 @@ withLedgerDo opts args cmdname cmd = do t <- getCurrentLocalTime tc <- getClockTime let go = cmd opts args . filterAndCacheLedgerWithOpts opts args t rawtext . (\rl -> rl{filepath=f,filereadtime=tc}) - if creating then go journalEmpty else (runErrorT . parseLedgerFile t) f + if creating then go nulljournal else (runErrorT . parseLedgerFile t) f >>= flip either go (\e -> hPutStrLn stderr e >> exitWith (ExitFailure 1))