aboutsummaryrefslogtreecommitdiff
path: root/lib/Malodivo/Budget.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Malodivo/Budget.hs')
-rw-r--r--lib/Malodivo/Budget.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/Malodivo/Budget.hs b/lib/Malodivo/Budget.hs
index 3a68fdf..c063b2a 100644
--- a/lib/Malodivo/Budget.hs
+++ b/lib/Malodivo/Budget.hs
@@ -167,6 +167,12 @@ that some districts can pay their shares and others can't:
>>> manyToOne low medium == low
True
+
+It works without any districts specified:
+
+>>> manyToOne HM.empty medium
+fromList []
+
-}
manyToOne ::
D.DistrictFunds -- ^ Amounts of available funds per district.
@@ -178,6 +184,30 @@ manyToOne df b = HM.fromList $ zip ds (normalizeDown (B.amount b) fs)
{-|
Districts funding multiple bills. No constraints.
+
+>>> :set -XOverloadedStrings
+>>> import qualified Data.HashMap.Strict as HM
+>>> import qualified Malodivo.Types.Bill as B
+>>> import qualified Malodivo.Types.District as D
+>>> import qualified Malodivo.Types.Ministry as M
+
+>>> let scienceA = B.Bill { B.amount = 10, B.name = "Science A", B.ministry = M.Science }
+>>> let welfareA = B.Bill { B.amount = 100, B.name = "Welfare A", B.ministry = M.Welfare }
+
+
+It works without any districts specified:
+
+>>> snd . head $ manyToMany HM.empty [scienceA]
+fromList []
+
+
+It works without bills:
+
+>>> manyToMany HM.empty []
+[]
+>>> let funds = HM.fromList [(D.Palolene, 100), (D.Lakos, 200)]
+>>> manyToMany funds []
+[]
-}
manyToMany ::
D.DistrictFunds -- ^ Amounts of available funds per district.