From 453ca1206e641cded15caf21c8142da5d2a32c56 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 10 Mar 2007 21:21:04 +0000 Subject: [PATCH] a distinct Account data type --- Account.hs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Account.hs b/Account.hs index 36c7951cf..c6337c049 100644 --- a/Account.hs +++ b/Account.hs @@ -13,17 +13,20 @@ import Ledger -- an Account caches an account's name, balance (including sub-accounts) -- and transactions (not including sub-accounts) -type Account = (AccountName,[EntryTransaction],Amount) +data Account = Account { + aname :: AccountName, + atransactions :: [EntryTransaction], + abalance :: Amount +} -nullacct = ("",[],nullamt) - -aname (a,_,_) = a -atransactions (_,ts,_) = ts -abalance (_,_,b) = b +nullacct = Account "" [] nullamt mkAccount :: Ledger -> AccountName -> Account mkAccount l a = - (a, transactionsInAccountNamed l a, aggregateBalanceInAccountNamed l a) + Account + a + (transactionsInAccountNamed l a) + (aggregateBalanceInAccountNamed l a) balanceInAccountNamed :: Ledger -> AccountName -> Amount balanceInAccountNamed l a =