]> Git — Sourcephile - haskell/literate-accounting.git/blob - src/Literate/Accounting/Move.hs
fixup! impl: lint code
[haskell/literate-accounting.git] / src / Literate / Accounting / Move.hs
1 module Literate.Accounting.Move where
2
3 import Data.Function ((.))
4 import GHC.Stack (HasCallStack)
5 import Literate.Accounting.Chart
6 import Literate.Accounting.Math
7 import Literate.Accounting.Unit
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
29 -- class Postable post where
30 -- post :: HasCallStack => AccountOf post -> AmountOf post -> post
31
32 class Postable acct unit qty post where
33 (+=) ::
34 HasCallStack =>
35 Postable acct unit qty post =>
36 Account acct ->
37 Amounts unit qty ->
38 post
39 infixr 4 +=
40
41 (-=) ::
42 HasCallStack =>
43 Postable acct unit qty post =>
44 Negable qty =>
45 Account acct ->
46 Amounts unit qty ->
47 post
48 (-=) acct = (+=) acct . negate
49 infixr 4 -=