| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hjugement.Majority
Contents
- 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
Constructors
| Scale | |
Fields
| |
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 propositions.
opinion :: (Enum prop, Bounded prop, Ord prop) => judge -> [grade] -> (judge, Opinion prop grade) Source #
Construct the Opinion of a judge about some propositions implicit from their type.
Type Opinions
newtype Opinions prop grade judge Source #
Profile of opinions of some judges about some propositions.
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 judges.
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 majorityGrades
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 grades
given to a choice by the judges.
It is the highest grade approved by an absolute majority of the judges:
more than 50% of the judges 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 judges is even, there is a middle-interval
(which can, of course, be reduced to a single grade
if the two middle grades 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 grades.
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 majorityValues.