summaryrefslogtreecommitdiff
path: root/src/Candidate.hs
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2017-01-14 14:05:02 +1100
committerJed Barber <jjbarber@y7mail.com>2017-01-14 14:05:02 +1100
commitb7bcf8a3377bc3b847234baaf24fe6e46d7f85b7 (patch)
tree580d54267de7ed4cc650c5d07345532699c803b1 /src/Candidate.hs
parentcedc60f86a22eddef26d8db4cb3ec36d50a7fd75 (diff)
Some code/style cleanup
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)