1 module Literate.Accounting.Move where
3 import GHC.Stack (HasCallStack)
4 import Data.Function ((.))
5 import Literate.Accounting.Math
6 import Literate.Accounting.Unit
7 import Literate.Accounting.Chart
10 data Account = Account
11 data Amount qty = Amount
13 , amountQuantity :: qty
15 instance Negable qty => Negable (Amount qty) where
16 negate Amount{..} = Amount{ amountQuantity = negate amountQuantity, ..}
19 type family AmountOf a
20 type family AccountOf a
21 type family AccountSectionOf a
23 type instance AmountOf [a] = AmountOf a
24 type instance AccountOf [a] = AccountOf a
25 type instance AccountSectionOf [a] = AccountSectionOf a
28 -- class Postable post where
29 -- post :: HasCallStack => AccountOf post -> AmountOf post -> post
31 class Postable acct unit qty post where
34 Postable acct unit qty post =>
35 Account acct -> Amounts unit qty -> post
40 Postable acct unit qty post =>
42 Account acct -> Amounts unit qty -> post
43 (-=) acct = (+=) acct . negate