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

Safe HaskellNone
LanguageHaskell98

Language.Nomyx.Vote

Description

Voting system

Synopsis

Documentation

type AssessFunction = VoteStats -> Maybe Bool Source

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

data VoteStats Source

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

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

finishVote :: AssessFunction -> RuleInfo -> [(PlayerNumber, Maybe Bool)] -> Nomex () Source

actions to do when the vote is finished

callVote :: AssessFunction -> UTCTime -> String -> RuleNumber -> ([(PlayerNumber, Maybe Bool)] -> Nomex ()) -> Nomex () Source

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

voteWith :: UTCTime -> AssessFunction -> String -> Event [(PlayerNumber, Maybe Bool)] Source

vote with a function able to assess the ongoing votes. | the vote can be concluded as soon as the result is known.

unanimity :: AssessFunction Source

assess the vote results according to a unanimity

majority :: AssessFunction Source

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

majorityWith :: Int -> AssessFunction Source

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

numberVotes :: Int -> AssessFunction Source

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

withQuorum :: AssessFunction -> Int -> AssessFunction Source

adds a quorum to an assessing function

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

voteQuota :: Int -> VoteStats -> Maybe Bool Source

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 -> Int Source

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