Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type Choices = HashSet
- choices :: (Bounded choice, Enum choice, Eq choice, Hashable choice) => Choices choice
- type Grades = Set
- grades :: [grade] -> Grades (Ranked grade)
- newtype Ranked a = Ranked (G, a)
- zipRank :: [a] -> [Ranked a]
- rankKey :: [(k, a)] -> [(Ranked k, a)]
- type G = Integer
- rank :: Ranked a -> G
- unRank :: Ranked a -> a
- enum :: (Bounded a, Enum a, Ord a) => Set a
- type Judges = HashMap
- judges :: Eq judge => Hashable judge => [judge] -> grade -> Judges judge grade
- type Opinions judge grade = HashMap judge (Distribution grade)
- opinions :: Eq judge => Hashable judge => Judges judge grade -> Opinions judge grade -> (Opinions judge grade, HashSet judge)
- type Distribution grade = Map grade Share
- singleGrade :: grade -> Distribution grade
- type Share = Rational
- type OpinionsByChoice choice judge grade = HashMap choice (Opinions judge grade)
- opinionsByChoice :: Eq choice => Hashable choice => [(choice, Opinions judge grade)] -> OpinionsByChoice choice judge grade
- newtype Merit grade = Merit {}
- merit :: Ord grade => Foldable opinions => opinions (Distribution grade) -> Merit grade
- meritFromList :: Ord grade => Foldable opinions => Functor opinions => opinions grade -> Merit grade
- normalizeMerit :: Merit grade -> Merit grade
- newtype MeritByChoice choice grade = MeritByChoice {
- unMeritByChoice :: HashMap choice (Merit grade)
- meritByChoice :: (Ord grade, Eq choice, Hashable choice) => OpinionsByChoice choice judge grade -> MeritByChoice choice grade
Type Choices
choices :: (Bounded choice, Enum choice, Eq choice, Hashable choice) => Choices choice Source #
Return a set of Choices
by enumerating the alternatives of its type. Useful on sum types.
Type Grades
How many grade
s should be used?
A greater number of grade
s permits a finer distinction but demands
a higher degree of expertise and discernment.
The optimal number is the highest number of grade
s that constitutes a common language,
that is, that allows Judges
to make absolute judgments.
Too little grade
s may lead too often to ties.
Note, however, that if the inputs or grades depend on the set of choice
s,
i.e. if judges change their grades when choice
s are added or dropped,
then the Arrow paradox cannot be avoided.
To avoid this the scale of grades must be fixed and absolute
so that more or fewer choice
s does not change
the inputs or messages of other choice
s.
Type Ranked
Helper type to rank data without a good Ord
instance.
Type G
enum :: (Bounded a, Enum a, Ord a) => Set a Source #
Return the Set
enumerating the alternatives
of its type parameter. Useful on sum types.
Type Judges
type Judges = HashMap Source #
Map each judge
to its default grade
(usually the same for all judge
s but not necessarily).
For instance, when a judge
gives no grade
or has “no opinion”,
this default grade could mean that the judge
chooses “To Reject” the choice
:
the rationale being that a judge
having “no opinion”
concerning a choice
has not even taken the time to evaluate it
and thus has implicitly rejected it.
Type Opinions
type Opinions judge grade = HashMap judge (Distribution grade) Source #
Profile of opinions of some judge
s about a single choice
.
opinions :: Eq judge => Hashable judge => Judges judge grade -> Opinions judge grade -> (Opinions judge grade, HashSet judge) Source #
(ok, ko) =
returns:opinions
js os
- in
ok
the opinions of thejudge
sjs
updated by those inos
, - in
ko
the opinions ofjudge
s not injs
.
Type Distribution
type Distribution grade = Map grade Share Source #
Usually, a judge
gives a singleGrade
to a given choice
.
However, when applying the Majority Judgment to a Tree
of Section
s,
what a judge
gives to a parent Section
is composed by the grade
s he or she has given
to the sub-Section
s, and those can be different.
In that case, each grade
given to a sub-Section
contributes to a Share
of the parent Section
which therefore is not necessarily a singleGrade
,
but more generally a Distribution
of grade
s.
And the sub-Section
s can actually themselves have sub-Section
s,
hence not being given a grade
, but a Distribution
of grade
s too.
singleGrade :: grade -> Distribution grade Source #
Type Share
type Share = Rational Source #
Usually a judge
attributes a singleGrade
to a given choice
,
and then the Share
of this grade
is 1.
However, when introducing vote colleges (giving more power to some judge
s),
or when introducing Section
s (decomposing a judgment into several sub-judgments),
it becomes possible that only a percentage of grade
is attributed by a judge
to a given choice
.
This is what a Share
is used for.
Type OpinionsByChoice
type OpinionsByChoice choice judge grade = HashMap choice (Opinions judge grade) Source #
Profile of opinions of some Judges
about some choice
s.
opinionsByChoice :: Eq choice => Hashable choice => [(choice, Opinions judge grade)] -> OpinionsByChoice choice judge grade Source #
Type Merit
Profile of merit about a single choice
.
Instances
(Ord grade, Show grade) => IsList (Merit grade) Source # | |
Eq grade => Eq (Merit grade) Source # | |
Ord grade => Ord (Merit grade) Source # | |
Defined in Majurity.Judgment.Value | |
Show grade => Show (Merit grade) Source # | |
Ord grade => Semigroup (Merit grade) Source # | |
type Item (Merit grade) Source # | |
Defined in Majurity.Judgment.Merit |
merit :: Ord grade => Foldable opinions => opinions (Distribution grade) -> Merit grade Source #
merit os
returns the Merit
given by opinions os
meritFromList :: Ord grade => Foldable opinions => Functor opinions => opinions grade -> Merit grade Source #
normalizeMerit :: Merit grade -> Merit grade Source #
Type MeritByChoice
newtype MeritByChoice choice grade Source #
Profile of merit about some choice
s.
MeritByChoice | |
|
Instances
(Eq choice, Hashable choice, Show choice) => IsList (MeritByChoice choice grade) Source # | |
Defined in Majurity.Judgment.Merit type Item (MeritByChoice choice grade) # fromList :: [Item (MeritByChoice choice grade)] -> MeritByChoice choice grade # fromListN :: Int -> [Item (MeritByChoice choice grade)] -> MeritByChoice choice grade # toList :: MeritByChoice choice grade -> [Item (MeritByChoice choice grade)] # | |
(Eq choice, Eq grade) => Eq (MeritByChoice choice grade) Source # | |
Defined in Majurity.Judgment.Merit (==) :: MeritByChoice choice grade -> MeritByChoice choice grade -> Bool # (/=) :: MeritByChoice choice grade -> MeritByChoice choice grade -> Bool # | |
(Show choice, Show grade) => Show (MeritByChoice choice grade) Source # | |
Defined in Majurity.Judgment.Merit showsPrec :: Int -> MeritByChoice choice grade -> ShowS # show :: MeritByChoice choice grade -> String # showList :: [MeritByChoice choice grade] -> ShowS # | |
(Eq choice, Hashable choice, Ord grade) => Semigroup (MeritByChoice choice grade) Source # | |
Defined in Majurity.Judgment.Merit (<>) :: MeritByChoice choice grade -> MeritByChoice choice grade -> MeritByChoice choice grade # sconcat :: NonEmpty (MeritByChoice choice grade) -> MeritByChoice choice grade # stimes :: Integral b => b -> MeritByChoice choice grade -> MeritByChoice choice grade # | |
type Item (MeritByChoice choice grade) Source # | |
Defined in Majurity.Judgment.Merit |
meritByChoice :: (Ord grade, Eq choice, Hashable choice) => OpinionsByChoice choice judge grade -> MeritByChoice choice grade Source #