1 module Hcompta.Amount where
3 import Data.Data (Data)
4 import Data.Function ((.))
5 import Data.Map.Strict (Map)
6 import qualified Data.MonoTraversable as MT
7 import Data.Ord (Ord(..), Ordering)
8 import Data.Tuple (fst, snd)
9 import Data.Proxy (Proxy(..))
11 import Hcompta.Quantity
12 import Hcompta.Unit (Unit(..))
20 class Amount (MT.Element as) => Amounts as
26 -- , Eq (Amount_Quantity a)
27 , Zero (Amount_Quantity a)
28 , Unit (Amount_Unit a)
30 type Amount_Quantity a
32 amount_quantity :: a -> Amount_Quantity a
33 amount_unit :: a -> Amount_Unit a
34 instance -- (unit, qty)
37 ) => Amount (unit, qty) where
38 type Amount_Quantity (unit, qty) = qty
39 type Amount_Unit (unit, qty) = unit
44 , Ord (Amount_Quantity a)
46 amount_sign = quantity_sign . amount_quantity
49 class Amount (Amounts_Amount amts) => Amounts amts where
50 type Amounts_Amount amts
54 ) => Amounts (Map unit qty) where
55 type Amounts_Amount (Map unit qty) = (unit, qty)