Safe Haskell | None |
---|---|
Language | Haskell2010 |
Majority.Value
Synopsis
- newtype MajorityValue grade = MajorityValue {
- unMajorityValue :: [Middle grade]
- data Middle grade = Middle {
- middleShare :: Share
- lowGrade :: grade
- highGrade :: grade
- majorityValue :: Ord grade => Merit grade -> MajorityValue grade
- majorityGrade :: Show grade => Ord grade => Merit grade -> Maybe grade
- type MajorityRanking choice grade = [(choice, MajorityValue grade)]
- majorityValueByChoice :: Show grade => Ord grade => MeritByChoice choice grade -> HashMap choice (MajorityValue grade)
- majorityRanking :: Show grade => Ord grade => MeritByChoice choice grade -> MajorityRanking choice grade
Type
MajorityValue
newtype MajorityValue grade Source #
A MajorityValue
is a list of grade
s
made from the successive lower middlemosts of a Merit
,
i.e. from the most consensual majorityGrade
to the least.
Constructors
MajorityValue | |
Fields
|
Instances
Eq grade => Eq (MajorityValue grade) Source # | |
Defined in Majority.Value Methods (==) :: MajorityValue grade -> MajorityValue grade -> Bool # (/=) :: MajorityValue grade -> MajorityValue grade -> Bool # | |
Ord grade => Ord (MajorityValue grade) Source # | |
Defined in Majority.Value Methods compare :: MajorityValue grade -> MajorityValue grade -> Ordering # (<) :: MajorityValue grade -> MajorityValue grade -> Bool # (<=) :: MajorityValue grade -> MajorityValue grade -> Bool # (>) :: MajorityValue grade -> MajorityValue grade -> Bool # (>=) :: MajorityValue grade -> MajorityValue grade -> Bool # max :: MajorityValue grade -> MajorityValue grade -> MajorityValue grade # min :: MajorityValue grade -> MajorityValue grade -> MajorityValue grade # | |
Show grade => Show (MajorityValue grade) Source # | |
Defined in Majority.Value Methods showsPrec :: Int -> MajorityValue grade -> ShowS # show :: MajorityValue grade -> String # showList :: [MajorityValue grade] -> ShowS # |
Type
Middle
A centered middle of a Merit
.
Needed to handle the Fractional
capabilities of a Share
.
By construction in majorityValue
,
lowGrade
is always lower or equal to highGrade
.
Constructors
Middle | |
Instances
Eq grade => Eq (Middle grade) Source # | |
Ord grade => Ord (Middle grade) Source # | |
Defined in Majority.Value | |
Show grade => Show (Middle grade) Source # | |
majorityValue :: Ord grade => Merit grade -> MajorityValue grade Source #
The majorityValue
is the list of the Middle
s of the Merit
of a choice
,
from the most consensual to the least.
majorityGrade :: Show grade => Ord grade => Merit grade -> Maybe grade Source #
The majorityGrade
is the lower middlemost
(also known as median by experts) of the grade
s
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 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
MajorityRanking
type MajorityRanking choice grade = [(choice, MajorityValue grade)] Source #
majorityValueByChoice :: Show grade => Ord grade => MeritByChoice choice grade -> HashMap choice (MajorityValue grade) Source #
majorityRanking :: Show grade => Ord grade => MeritByChoice choice grade -> MajorityRanking choice grade Source #
The majorityRanking
ranks all the choice
s 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 choice
s have precisely the same majorityValue
s.
Orphan instances
(Show grade, Ord grade) => Ord (Merit grade) Source # | |