1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE FlexibleInstances #-}
4 {-# LANGUAGE StandaloneDeriving #-}
5 {-# LANGUAGE TupleSections #-}
6 {-# LANGUAGE TypeFamilies #-}
7 {-# OPTIONS_GHC -fno-warn-orphans #-}
8 module Hcompta.Amount where
10 import Data.Data (Data)
11 import Data.Eq (Eq(..))
12 import Data.Functor (Functor(..))
13 import Data.Ord (Ord(..), Ordering)
14 import Data.Tuple (fst, snd)
15 import Prelude (($), (.))
17 import Hcompta.Polarize
18 import Hcompta.Quantity
19 import Hcompta.Unit (Unit(..))
25 , Eq (Amount_Quantity a)
26 , Zero (Amount_Quantity a)
27 , Unit (Amount_Unit a)
29 type Amount_Quantity a
31 amount_quantity :: a -> Amount_Quantity a
32 amount_unit :: a -> Amount_Unit a
37 ) => Amount (unit, quantity) where
38 type Amount_Quantity (unit, quantity) = quantity
39 type Amount_Unit (unit, quantity) = unit
43 ( Polarizable quantity
44 ) => Polarizable (unit, quantity) where
45 polarizable_positive (u, q) = fmap (u,) $ polarizable_positive q
46 polarizable_negative (u, q) = fmap (u,) $ polarizable_negative q
50 , Ord (Amount_Quantity a)
53 quantity_sign . amount_quantity