Nomyx-Language-0.6.2: Language to express rules for Nomic

Safe HaskellNone

Language.Nomyx.Vote

Description

Voting system

Synopsis

Documentation

type AssessFunction = VoteStats -> Maybe BoolSource

a vote assessing function (such as unanimity, majority...)

data VoteStats Source

the vote statistics, including the number of votes per choice (Nothing means abstention), the number of persons called to vote, and if the vote if finished (timeout or everybody voted)

Instances

unanimityVote :: Nomex ()Source

vote at unanimity every incoming rule

callVoteRule :: AssessFunction -> NominalDiffTime -> RuleInfo -> Nomex ()Source

call a vote on a rule for every players, with an assessing function and a delay

callVote :: AssessFunction -> UTCTime -> String -> (Bool -> Nomex ()) -> Nomex ()Source

call a vote for every players, with an assessing function, a delay and a function to run on the result

unanimity :: AssessFunctionSource

assess the vote results according to a unanimity

majority :: AssessFunctionSource

assess the vote results according to an absolute majority (half voters plus one)

majorityWith :: Int -> AssessFunctionSource

assess the vote results according to a majority of x (in %)

numberVotes :: Int -> AssessFunctionSource

assess the vote results according to a fixed number of positive votes

withQuorum :: AssessFunction -> Int -> AssessFunctionSource

adds a quorum to an assessing function

counts :: (Eq a, Ord a) => [a] -> [(a, Int)]Source

voteQuota :: Int -> VoteStats -> Maybe BoolSource

Compute a result based on a quota of positive votes. the result can be positive if the quota if reached, negative if the quota cannot be reached anymore at that point, or still pending.

nbVoters :: VoteStats -> IntSource

number of people that voted if the voting is finished, total number of people that should vote otherwise