lib: clarify journalBalanceTransactions

This commit is contained in:
Simon Michael 2017-05-30 13:04:34 -07:00
parent 13c4643a09
commit aca7c0d93b

View File

@ -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. -- depends on display precision. Reports only the first error encountered.
journalBalanceTransactions :: Bool -> Journal -> Either String Journal journalBalanceTransactions :: Bool -> Journal -> Either String Journal
journalBalanceTransactions assrt j = journalBalanceTransactions assrt j =
runST $ journalBalanceTransactionsST assrt (journalNumberTransactions j) runST $
(newArray_ (1, genericLength $ jtxns j) journalBalanceTransactionsST
:: forall s. ST s (STArray s Integer Transaction)) assrt -- check balance assertions also ?
(\arr tx -> writeArray arr (tindex tx) tx) (journalNumberTransactions j) -- journal to process
$ fmap (\txns -> j{ jtxns = txns}) . getElems (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 -- | Generalization used in the definition of