summaryrefslogtreecommitdiff
path: root/src/Candidate.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Candidate.hs')
-rw-r--r--src/Candidate.hs10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/Candidate.hs b/src/Candidate.hs
index e779051..d07ce14 100644
--- a/src/Candidate.hs
+++ b/src/Candidate.hs
@@ -4,7 +4,6 @@ module Candidate(
CandidateID,
AboveLineBallot,
BelowLineBallot,
- Criteria,
readCandidates
) where
@@ -18,7 +17,6 @@ import qualified System.IO as IO
import qualified Data.List as List
import qualified Data.Either.Unwrap as Either
import qualified Data.Maybe as Maybe
-import qualified Data.Char as Char
@@ -34,18 +32,14 @@ type AboveLineBallot = [[Position]]
-- a list of candidates in the order of how they were placed below the line
type BelowLineBallot = [CandidateID]
--- represents a criteria used for finding ballots that voted a specific
--- way, for example voted for candidate C as #1, candidate F as #2, etc
-type Criteria = [(Ranking,CandidateID)]
-
readCandidates :: FilePath -> String -> IO (AboveLineBallot, BelowLineBallot)
readCandidates inputFile state = do
h <- IO.openFile inputFile IO.ReadMode
- --
e <- IO.hIsEOF h
+
let readFunc r c = if c then return r else do
t0 <- IO.hGetLine h
let t1 = CSV.parseRecord CSV.defaultSettings t0
@@ -56,8 +50,8 @@ readCandidates inputFile state = do
then readFunc (t3:r) tx
else readFunc r tx
raw <- readFunc [] e >>= return . (List.sort)
+
IO.hClose h
- --
return (makeAboveBallot raw, makeBelowBallot raw)