diff options
author | Jed Barber <jjbarber@y7mail.com> | 2017-01-28 23:31:35 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2017-01-28 23:31:35 +1100 |
commit | 0601150a1554dcda13c90880deb306aeea357a72 (patch) | |
tree | 8f3a38608fa1b3774540bd556045328aff5490ac /src/Election.hs | |
parent | 30c8ac408cba49ca4f223252cd1cd3d68ce6ca00 (diff) |
Rationals instead of floats
Diffstat (limited to 'src/Election.hs')
-rw-r--r-- | src/Election.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Election.hs b/src/Election.hs index 5ffba0d..ea23a05 100644 --- a/src/Election.hs +++ b/src/Election.hs @@ -16,10 +16,10 @@ import Data.List ( (\\) ) import qualified Data.List as List import qualified Data.Maybe as Maybe import qualified Data.Either.Unwrap as Either +import Data.Ratio ( (%) ) import qualified Counter as Sen import qualified Candidate as Typ import qualified CSV as CSV -import Miscellaneous ( (.:) ) import qualified Miscellaneous as Misc @@ -52,7 +52,7 @@ data Entry = Entry data Trace = Trace { getCriteria :: Sen.Criteria - , getTransferVal :: Float } + , getTransferVal :: Rational } deriving (Eq) data Status = Running | Elected | Eliminated @@ -61,7 +61,7 @@ data Status = Running | Elected | Eliminated data Transfer = Transfer { getWhoFrom :: Typ.CandidateID , getVoteAmount :: Int - , getNewValue :: Float + , getNewValue :: Rational , getWhatToDist :: [Trace] } @@ -210,7 +210,7 @@ doElectCandidate e = do newTransfer = Transfer { getWhoFrom = getID electedEntry , getVoteAmount = getTotalVotes electedEntry - getQuota e - , getNewValue = (fromIntegral (getTotalVotes electedEntry - getQuota e)) / + , getNewValue = (fromIntegral (getTotalVotes electedEntry - getQuota e)) % (fromIntegral (getTotalVotes electedEntry)) , getWhatToDist = getCritTrace electedEntry } |