From aca7c0d93b9f86cd36d266a2ce727ad6ec1509bf Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 30 May 2017 13:04:34 -0700 Subject: [PATCH] lib: clarify journalBalanceTransactions --- hledger-lib/Hledger/Data/Journal.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 4aa57d37b..82a2af098 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -561,11 +561,13 @@ type CurrentBalancesModifier s = R.ReaderT (Env s) (ExceptT String (ST s)) -- depends on display precision. Reports only the first error encountered. journalBalanceTransactions :: Bool -> Journal -> Either String Journal journalBalanceTransactions assrt j = - runST $ journalBalanceTransactionsST assrt (journalNumberTransactions j) - (newArray_ (1, genericLength $ jtxns j) - :: forall s. ST s (STArray s Integer Transaction)) - (\arr tx -> writeArray arr (tindex tx) tx) - $ fmap (\txns -> j{ jtxns = txns}) . getElems + runST $ + journalBalanceTransactionsST + assrt -- check balance assertions also ? + (journalNumberTransactions j) -- journal to process + (newArray_ (1, genericLength $ jtxns j) :: forall s. ST s (STArray s Integer Transaction)) -- initialise state + (\arr tx -> writeArray arr (tindex tx) tx) -- update state + (fmap (\txns -> j{ jtxns = txns}) . getElems) -- summarise state -- | Generalization used in the definition of