From 0601150a1554dcda13c90880deb306aeea357a72 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 28 Jan 2017 23:31:35 +1100 Subject: Rationals instead of floats --- src/Election.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Election.hs') 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 } -- cgit