Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type Choices prop = Set prop
- choices :: (Bounded prop, Enum prop, Ord prop) => Choices prop
- data Scale grade = Scale {
- scaleGrades :: Set grade
- scaleDefault :: grade
- scale :: (Bounded grade, Enum grade, Ord grade) => Scale grade
- scaleOfList :: Eq a => [a] -> a -> Scale Int
- gradeOfScale :: [a] -> Int -> a
- type Jury judge = Set judge
- jury :: (Bounded judge, Enum judge, Ord judge) => Jury judge
- type Opinion prop grade = Map prop grade
- opinion :: (Enum prop, Bounded prop, Ord prop) => judge -> [grade] -> (judge, Opinion prop grade)
- newtype Opinions prop grade judge = Opinions (Map judge (Opinion prop grade))
- newtype Merit grade = Merit (Map grade Count)
- type Count = Int
- merit :: (Ord grade, Ord prop) => Scale grade -> prop -> Opinions prop grade judge -> Merit grade
- newtype Merits prop grade = Merits (Map prop (Merit grade))
- merits :: (Ord grade, Ord prop) => Scale grade -> Choices prop -> Opinions prop grade judge -> Merits prop grade
- newtype Value grade = Value [(grade, Count)]
- majorityValue :: Ord grade => Merit grade -> Value grade
- majorityGrade :: Ord grade => Merit grade -> grade
- type Ranking prop = [prop]
- majorityRanking :: Ord grade => Merits prop grade -> Ranking prop
- majorityValueByChoice :: Ord grade => Merits prop grade -> [(prop, Value grade)]
Type Choices
choices :: (Bounded prop, Enum prop, Ord prop) => Choices prop Source #
Return a set of Choices
by enumerating the alternatives of its type. Useful on sum types.
Type Scale
Scale | |
|
scale :: (Bounded grade, Enum grade, Ord grade) => Scale grade Source #
Return a Scale
by enumerating the alternatives of its type. Useful on sum types.
gradeOfScale :: [a] -> Int -> a Source #
Type Jury
jury :: (Bounded judge, Enum judge, Ord judge) => Jury judge Source #
Return a Jury
by enumerating the alternatives of its type. Useful on sum types.
Type Opinion
type Opinion prop grade = Map prop grade Source #
Profile of opinions of one single judge
about some prop
ositions.
opinion :: (Enum prop, Bounded prop, Ord prop) => judge -> [grade] -> (judge, Opinion prop grade) Source #
Construct the Opinion
of a judge
about some prop
ositions implicit from their type.
Type Opinions
newtype Opinions prop grade judge Source #
Profile of opinions of some judge
s about some prop
ositions.
Type Merit
Profile of merits about a choice.
merit :: (Ord grade, Ord prop) => Scale grade -> prop -> Opinions prop grade judge -> Merit grade Source #
merit grad
returns the Merit
of a single choice
by some judge
s.
Type Merits
merits :: (Ord grade, Ord prop) => Scale grade -> Choices prop -> Opinions prop grade judge -> Merits prop grade Source #
Type Value
majorityValue :: Ord grade => Merit grade -> Value grade Source #
The majorityValue
is the list of the majorityGrade
s
of a choice, each one replicated their associated Count
times,
from the most consensual to the least,
ie. by removing the grade
of the previous majorityGrade
to compute the next.
majorityGrade :: Ord grade => Merit grade -> grade Source #
The majorityGrade
is the lower middlemost
(also known as median by experts) of the grade
s
given to a choice by the judge
s.
It is the highest grade
approved by an absolute majority of the judge
s:
more than 50% of the judge
s give the choice at least a grade
of majorityGrade
,
but every grade
lower than majorityGrade
is rejected by an absolute majority
Thus the majorityGrade
of a choice
is the final grade
wished by the majority.
The majorityGrade
is necessarily a word that belongs to grades
,
and it has an absolute meaning.
When the number of judge
s is even, there is a middle-interval
(which can, of course, be reduced to a single grade
if the two middle grade
s are the same),
then the majorityGrade
is the lowest grade
of the middle-interval
(the “lower middlemost” when there are two in the middle),
which is the only one which respects consensus:
any other choice whose grades are all within this middle-interval,
has a majorityGrade
which is greater or equal to this lower middlemost.
Type Ranking
majorityRanking :: Ord grade => Merits prop grade -> Ranking prop Source #
The majorityRanking
ranks all the choices on the basis of their grade
s.
Choice A ranks higher than choice B in the majorityRanking
if and only if A’s majorityValue
is lexicographically above B’s.
There can be no tie unless two choices have precisely the same majorityValue
s.