ledgerFile cleanup

This commit is contained in:
Simon Michael 2009-04-10 05:40:57 +00:00
parent c14f1c280f
commit 638238dc5c

View File

@ -83,15 +83,16 @@ parseLedger reftime inname intxt = do
Right m -> liftM (rawLedgerConvertTimeLog reftime) $ m `ap` (return rawLedgerEmpty) Right m -> liftM (rawLedgerConvertTimeLog reftime) $ m `ap` (return rawLedgerEmpty)
Left err -> throwError $ show err Left err -> throwError $ show err
-- As all ledger line types can be distinguished by the first
-- character, excepting transactions versus empty (blank or
-- comment-only) lines, can use choice w/o try
ledgerFile :: GenParser Char LedgerFileCtx (ErrorT String IO (RawLedger -> RawLedger)) ledgerFile :: GenParser Char LedgerFileCtx (ErrorT String IO (RawLedger -> RawLedger))
ledgerFile = do ledger_txns <- many1 ledgerItem ledgerFile = do items <- many1 ledgerItem
eof eof
return $ liftM (foldr1 (.)) $ sequence ledger_txns return $ liftM (foldr1 (.)) $ sequence items
where ledgerItem = choice [ ledgerDirective where
-- As all ledger line types can be distinguished by the first
-- character, excepting transactions versus empty (blank or
-- comment-only) lines, can use choice w/o try
ledgerItem = choice [ ledgerDirective
, liftM (return . addLedgerTransaction) ledgerTransaction , liftM (return . addLedgerTransaction) ledgerTransaction
, liftM (return . addModifierTransaction) ledgerModifierTransaction , liftM (return . addModifierTransaction) ledgerModifierTransaction
, liftM (return . addPeriodicTransaction) ledgerPeriodicTransaction , liftM (return . addPeriodicTransaction) ledgerPeriodicTransaction