aboutsummaryrefslogtreecommitdiff
path: root/cmd/Main/DistrictInfo.hs
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2017-06-26 09:09:20 +0300
committerIgor Pashev <pashev.igor@gmail.com>2017-06-26 09:09:20 +0300
commitc82a64701ff64283e95efbbd6df614cd1e775e52 (patch)
tree771140e4a38137796e1bbd9717274b86691a2ba7 /cmd/Main/DistrictInfo.hs
parent6f18125faaf7afa6d543b074eca65836a13a372b (diff)
downloadmolodivo-c82a64701ff64283e95efbbd6df614cd1e775e52.tar.gz
Refactor
Mainly because further development will not preserve bill order in lists and we'll need to maintain mapping internally.
Diffstat (limited to 'cmd/Main/DistrictInfo.hs')
-rw-r--r--cmd/Main/DistrictInfo.hs34
1 files changed, 0 insertions, 34 deletions
diff --git a/cmd/Main/DistrictInfo.hs b/cmd/Main/DistrictInfo.hs
deleted file mode 100644
index f4f9ff1..0000000
--- a/cmd/Main/DistrictInfo.hs
+++ /dev/null
@@ -1,34 +0,0 @@
-{-# LANGUAGE DeriveAnyClass #-}
-{-# LANGUAGE DeriveGeneric #-}
-
-module Main.DistrictInfo
- ( DistrictInfo(..)
- , di2df
- , df2di
- ) where
-
-import Control.Arrow ((&&&))
-import GHC.Generics (Generic)
-
-import Data.Aeson (FromJSON, ToJSON)
-import qualified Data.HashMap.Strict as HM
-
-import Malodivo.Budget (DistrictFunds)
-import Malodivo.Types.District (District)
-
-{-|
-We use this data type instead of 'DistrictFunds', because
-maps other than @HashMap Text _@ are hard to decode/encode see
-<https://github.com/bos/aeson/issues/79>. Anyway, we still have type-checked
-typos-proof structure, and build 'DistrictFunds' out of it.
--}
-data DistrictInfo = DistrictInfo
- { name :: District
- , amount :: Integer
- } deriving (Generic, FromJSON, ToJSON)
-
-di2df :: [DistrictInfo] -> DistrictFunds
-di2df = HM.fromListWith (+) . map (name &&& amount)
-
-df2di :: DistrictFunds -> [DistrictInfo]
-df2di = map (\(n, a) -> DistrictInfo {name = n, amount = a}) . HM.toList