Safe Haskell | None |
---|---|
Language | Haskell98 |
Voting system
- type AssessFunction = VoteStats -> Maybe Bool
- data VoteStats = VoteStats {
- voteCounts :: Map Bool Int
- nbParticipants :: Int
- voteFinished :: Bool
- unanimityVote :: Nomex ()
- callVoteRule :: AssessFunction -> NominalDiffTime -> RuleInfo -> Nomex ()
- callVoteRule' :: AssessFunction -> UTCTime -> RuleInfo -> Nomex ()
- finishVote :: AssessFunction -> RuleInfo -> [(PlayerNumber, Maybe Bool)] -> Nomex ()
- callVote :: AssessFunction -> UTCTime -> String -> RuleNumber -> ([(PlayerNumber, Maybe Bool)] -> Nomex ()) -> Nomex ()
- voteWith :: UTCTime -> AssessFunction -> String -> Event [(PlayerNumber, Maybe Bool)]
- singleVote :: String -> PlayerNumber -> Event Bool
- unanimity :: AssessFunction
- majority :: AssessFunction
- majorityWith :: Int -> AssessFunction
- numberVotes :: Int -> AssessFunction
- withQuorum :: AssessFunction -> Int -> AssessFunction
- getVoteStats :: [Maybe Bool] -> Bool -> VoteStats
- counts :: (Eq a, Ord a) => [a] -> [(a, Int)]
- voteQuota :: Int -> VoteStats -> Maybe Bool
- nbVoters :: VoteStats -> Int
- voted :: VoteStats -> Int
- notVoted :: VoteStats -> Int
- displayVote :: EventNumber -> RuleNumber -> Nomex ()
- getVotes :: [PlayerNumber] -> [(PlayerNumber, Bool)] -> [(PlayerNumber, Maybe Bool)]
- getBooleanResult :: (PlayerNumber, SomeData) -> (PlayerNumber, Bool)
- showOnGoingVote :: [(PlayerNumber, Maybe Bool)] -> RuleNumber -> NomexNE String
- showFinishedVote :: RuleNumber -> Bool -> [(PlayerNumber, Maybe Bool)] -> NomexNE String
- showVote :: (PlayerNumber, Maybe Bool) -> NomexNE (String, String)
- showChoice :: Maybe Bool -> String
Documentation
type AssessFunction = VoteStats -> Maybe Bool Source
a vote assessing function (such as unanimity, majority...)
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)
VoteStats | |
|
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
callVoteRule' :: AssessFunction -> UTCTime -> RuleInfo -> Nomex () Source
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.
singleVote :: String -> PlayerNumber -> Event Bool Source
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
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
displayVote :: EventNumber -> RuleNumber -> Nomex () Source
getVotes :: [PlayerNumber] -> [(PlayerNumber, Bool)] -> [(PlayerNumber, Maybe Bool)] Source
getBooleanResult :: (PlayerNumber, SomeData) -> (PlayerNumber, Bool) Source
showOnGoingVote :: [(PlayerNumber, Maybe Bool)] -> RuleNumber -> NomexNE String Source
showFinishedVote :: RuleNumber -> Bool -> [(PlayerNumber, Maybe Bool)] -> NomexNE String Source
showChoice :: Maybe Bool -> String Source