Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Voting system
- type AssessFunction = VoteStats -> Maybe Bool
- data VoteStats = VoteStats {
- voteCounts :: Map Bool Int
- nbParticipants :: Int
- voteFinished :: Bool
- data VoteBegin = VoteBegin {}
- data VoteEnd = VoteEnd {
- veRule :: RuleInfo
- veVotes :: [(PlayerNumber, Maybe Bool)]
- vePassed :: Bool
- veFinishedAt :: UTCTime
- voteBegin :: Msg VoteBegin
- voteEnd :: Msg VoteEnd
- 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 EventNumber
- voteWith :: UTCTime -> AssessFunction -> String -> Event [(PlayerNumber, Maybe Bool)]
- displayVotes :: Nomex ()
- 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
- displayOnGoingVote :: VoteBegin -> Nomex ()
- getVotes :: [PlayerNumber] -> [(PlayerNumber, Bool)] -> [(PlayerNumber, Maybe Bool)]
- getBooleanResult :: (PlayerNumber, SomeData) -> (PlayerNumber, Bool)
- showOnGoingVote :: [(PlayerNumber, Maybe Bool)] -> RuleNumber -> UTCTime -> Nomex String
- displayFinishedVote :: VoteEnd -> Nomex ()
- showFinishedVote :: RuleNumber -> Bool -> [(PlayerNumber, Maybe Bool)] -> UTCTime -> Nomex String
- showVote :: (PlayerNumber, Maybe Bool) -> Nomex (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 | |
|
information broadcasted when a vote begins
information broadcasted when a vote ends
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 EventNumber 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.
displayVotes :: Nomex () Source #
display the votes (ongoing and finished)
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
displayOnGoingVote :: VoteBegin -> Nomex () Source #
display an on going vote
getVotes :: [PlayerNumber] -> [(PlayerNumber, Bool)] -> [(PlayerNumber, Maybe Bool)] Source #
getBooleanResult :: (PlayerNumber, SomeData) -> (PlayerNumber, Bool) Source #
showOnGoingVote :: [(PlayerNumber, Maybe Bool)] -> RuleNumber -> UTCTime -> Nomex String Source #
displayFinishedVote :: VoteEnd -> Nomex () Source #
display a finished vote
showFinishedVote :: RuleNumber -> Bool -> [(PlayerNumber, Maybe Bool)] -> UTCTime -> Nomex String Source #