]> Git — Sourcephile - haskell/literate-accounting.git/blob - src/Literate/Accounting/Move.hs
iface: rename {Haccounting => Literate.Accounting}
[haskell/literate-accounting.git] / src / Literate / Accounting / Move.hs
1 module Literate.Accounting.Move where
2
3 import GHC.Stack (HasCallStack)
4 import Data.Function ((.))
5 import Literate.Accounting.Math
6 import Literate.Accounting.Unit
7 import Literate.Accounting.Chart
8
9 {-
10 data Account = Account
11 data Amount qty = Amount
12 { amountUnit :: Unit
13 , amountQuantity :: qty
14 }
15 instance Negable qty => Negable (Amount qty) where
16 negate Amount{..} = Amount{ amountQuantity = negate amountQuantity, ..}
17 -}
18
19 type family AmountOf a
20 type family AccountOf a
21 type family AccountSectionOf a
22
23 type instance AmountOf [a] = AmountOf a
24 type instance AccountOf [a] = AccountOf a
25 type instance AccountSectionOf [a] = AccountSectionOf a
26
27 -- * Class 'Postable'
28 -- class Postable post where
29 -- post :: HasCallStack => AccountOf post -> AmountOf post -> post
30
31 class Postable acct unit qty post where
32 (+=) ::
33 HasCallStack =>
34 Postable acct unit qty post =>
35 Account acct -> Amounts unit qty -> post
36 infixr 4 +=
37
38 (-=) ::
39 HasCallStack =>
40 Postable acct unit qty post =>
41 Negable qty =>
42 Account acct -> Amounts unit qty -> post
43 (-=) acct = (+=) acct . negate
44 infixr 4 -=