module Literate.Accounting.Move where import Data.Function ((.)) import GHC.Stack (HasCallStack) import Literate.Accounting.Chart import Literate.Accounting.Math import Literate.Accounting.Unit {- data Account = Account data Amount qty = Amount { amountUnit :: Unit , amountQuantity :: qty } instance Negable qty => Negable (Amount qty) where negate Amount{..} = Amount{ amountQuantity = negate amountQuantity, ..} -} type family AmountOf a type family AccountOf a type family AccountSectionOf a type instance AmountOf [a] = AmountOf a type instance AccountOf [a] = AccountOf a type instance AccountSectionOf [a] = AccountSectionOf a -- * Class 'Postable' -- class Postable post where -- post :: HasCallStack => AccountOf post -> AmountOf post -> post class Postable acct unit qty post where (+=) :: HasCallStack => Postable acct unit qty post => Account acct -> Amounts unit qty -> post infixr 4 += (-=) :: HasCallStack => Postable acct unit qty post => Negable qty => Account acct -> Amounts unit qty -> post (-=) acct = (+=) acct . negate infixr 4 -=