summaryrefslogtreecommitdiff
path: root/src/Counter.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Counter.hs')
-rw-r--r--src/Counter.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Counter.hs b/src/Counter.hs
index 2bcd2d7..bf2ee7e 100644
--- a/src/Counter.hs
+++ b/src/Counter.hs
@@ -113,7 +113,9 @@ doCount sen criteria = do
r <- testFunc n 1 1
if r then tailFunc (n + 1) (p + 1) else tailFunc (n + 1) p
- tailFunc 1 0
+ if (all (isValid (ballotMap sen)) criteria)
+ then tailFunc 1 0
+ else return 0
@@ -130,6 +132,13 @@ toInternal ballot (Right cs) =
+isValid :: Typ.BelowLineBallot -> Either Typ.CandidateID [Typ.CandidateID] -> Bool
+isValid ballot (Left x) = x `elem` ballot
+isValid ballot (Right xs) = all (`elem` ballot) xs
+
+
+
+
getBallot :: SenateCounter -> Typ.BelowLineBallot
getBallot = ballotMap