Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
majorityJudgment
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
delanoe
majorityJudgment
Commits
5ced3c2d
Commit
5ced3c2d
authored
Dec 20, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Error Messages.
parent
4178a1b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
Lib.hs
src/Lib.hs
+11
-6
No files found.
src/Lib.hs
View file @
5ced3c2d
...
...
@@ -78,23 +78,28 @@ ballots4 = [ Ballot "Fascism" (ratedAs [(90, Excellent)])
-- | Select the Winner
-- TODO: sortBy and intersect according to Result
-- sort then take While equality
winnerIs
::
MajorityJudgment
->
Either
Text
(
Maybe
Ballot
)
winnerIs
::
MajorityJudgment
->
Either
Unfair
(
Maybe
Ballot
)
winnerIs
mj
=
case
isFair
mj
of
False
->
Left
"Unfair Election"
True
->
Right
$
(
headMay
.
reverse
.
sort
)
mj
Just
unfair
->
Left
unfair
Nothing
->
Right
$
(
headMay
.
reverse
.
sort
)
mj
data
Unfair
=
NoChoice
|
NoRepresentativity
deriving
(
Show
)
-- | Asserts is the Election with Majority Judgment is Fair
-- e.g. methodology of vote is respected to collect the ballots
-- Number of vote per Ballot must be equal
-- add an axiom: must not be Poor at least by one voter ?
-- TODO: be more explicit why election is not fair
isFair
::
MajorityJudgment
->
Bool
isFair
mj
=
length
vs
>
2
&&
all
(
==
head
vs
)
vs
isFair
::
MajorityJudgment
->
Maybe
Unfair
isFair
mj
=
case
length
vs
<
2
of
True
->
Just
NoChoice
False
->
case
all
(
==
head
vs
)
vs
of
False
->
Just
NoRepresentativity
True
->
Nothing
where
vs
=
map
(
length
.
votes
)
mj
data
Unfair
=
NoChoice
|
NoRepresentativity
instance
Eq
Ballot
where
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment