Safe Haskell | None |
---|
Voting system
- data VoteType a
- = ExclusiveVote (Maybe (Alts a))
- | NonExclusiveVote [Alts a]
- class (Eq (Alts a), Show (Alts a), Ord (Alts a), Typeable a) => Votable a where
- type ForAgainst = Alts Rule
- type Vote a = (PlayerNumber, Maybe (Alts a))
- type VoteResult a = VoteStats a -> [Alts a]
- data VoteStats a = VoteStats {
- voteCounts :: Map (Maybe (Alts a)) Int
- voteFinished :: Bool
- data VoteData a = VoteData {
- msgEnd :: Msg [Alts a]
- voteVar :: ArrayVar PlayerNumber (Alts a)
- inputNumbers :: [EventNumber]
- assessFunction :: VoteResult a
- type Assessor a = StateT (VoteData a) Nomex ()
- voteWith :: Votable a => VoteResult a -> Assessor a -> a -> [Alts a] -> Nomex (Msg [Alts a])
- voteWith_ :: Votable a => VoteResult a -> Assessor a -> a -> Nomex (Msg [Alts a])
- assessOnEveryVote :: Votable a => Assessor a
- assessOnTimeLimit :: Votable a => UTCTime -> Assessor a
- assessOnTimeDelay :: Votable a => NominalDiffTime -> Assessor a
- assessWhenEverybodyVoted :: Votable a => Assessor a
- cleanVote :: Votable a => VoteData a -> Nomex ()
- quorum :: Votable a => Int -> VoteStats a -> Bool
- withQuorum :: Votable a => VoteResult a -> Int -> VoteResult a
- unanimity :: Votable a => VoteStats a -> [Alts a]
- majority :: Votable a => VoteStats a -> [Alts a]
- majorityWith :: Votable a => Int -> VoteStats a -> [Alts a]
- numberVotes :: Votable a => Int -> VoteStats a -> [Alts a]
- voteQuota :: forall a. Votable a => Int -> VoteStats a -> [Alts a]
- exclusiveVoteQuota :: Votable a => Int -> VoteStats a -> (Alts a, Alts a) -> Maybe (Alts a)
- nbVoters :: Votable a => VoteStats a -> Int
- totalVoters :: Votable a => VoteStats a -> Int
- notVoted :: Votable a => VoteStats a -> Int
- voted :: Votable a => VoteStats a -> Int
- getVoteStats :: Votable a => [Vote a] -> Bool -> VoteStats a
- counts :: (Eq a, Ord a) => [a] -> [(a, Int)]
- data Referendum = Referendum String
- referendum :: String -> Nomex () -> RuleFunc
- data Election = Election String
- elections :: String -> [PlayerInfo] -> (PlayerNumber -> Nomex ()) -> Nomex ()
Documentation
ExclusiveVote (Maybe (Alts a)) | |
NonExclusiveVote [Alts a] |
class (Eq (Alts a), Show (Alts a), Ord (Alts a), Typeable a) => Votable a whereSource
type ForAgainst = Alts RuleSource
type Vote a = (PlayerNumber, Maybe (Alts a))Source
type VoteResult a = VoteStats a -> [Alts a]Source
VoteStats | |
|
VoteData | |
|
:: Votable a | |
=> VoteResult a | the function used to count the votes. |
-> Assessor a | assessors: when and how to perform the vote assessment (several assessors can be chained). |
-> a | toVote: the matter to be voted. |
-> [Alts a] | the vote alternatives. |
-> Nomex (Msg [Alts a]) | return value: a message containing the result of the vote. |
Perform a vote.
voteWith_ :: Votable a => VoteResult a -> Assessor a -> a -> Nomex (Msg [Alts a])Source
Performs a vote, all the possible alternatives are selected.
assessOnEveryVote :: Votable a => Assessor aSource
assess the vote on every new vote with the assess function, and as soon as the vote has an issue (positive of negative), sends a signal
assessOnTimeLimit :: Votable a => UTCTime -> Assessor aSource
assess the vote with the assess function when time is reached, and sends a signal with the issue (positive of negative)
assessOnTimeDelay :: Votable a => NominalDiffTime -> Assessor aSource
assess the vote with the assess function when time is elapsed, and sends a signal with the issue (positive of negative)
assessWhenEverybodyVoted :: Votable a => Assessor aSource
assess the vote only when every body voted. An error is generated if the assessing function returns Nothing.
cleanVote :: Votable a => VoteData a -> Nomex ()Source
clean events and variables necessary for the vote
quorum :: Votable a => Int -> VoteStats a -> BoolSource
a quorum is the neccessary number of voters for the validity of the vote
withQuorum :: Votable a => VoteResult a -> Int -> VoteResult aSource
adds a quorum to an assessing function
unanimity :: Votable a => VoteStats a -> [Alts a]Source
assess the vote results according to a unanimity (everybody votes for)
majority :: Votable a => VoteStats a -> [Alts a]Source
assess the vote results according to an absolute majority (half voters plus one, no quorum is needed)
majorityWith :: Votable a => Int -> VoteStats a -> [Alts a]Source
assess the vote results according to a majority of x (in %)
numberVotes :: Votable a => Int -> VoteStats a -> [Alts a]Source
assess the vote results according to a necessary number of positive votes
voteQuota :: forall a. Votable a => Int -> VoteStats a -> [Alts a]Source
return the vote alternatives that are above threshold
nbVoters :: Votable a => VoteStats a -> IntSource
number of people that voted if the voting is finished, total number of people that should vote otherwise
totalVoters :: Votable a => VoteStats a -> IntSource
Referendum & elections
data Referendum Source
referendum :: String -> Nomex () -> RuleFuncSource
elections :: String -> [PlayerInfo] -> (PlayerNumber -> Nomex ()) -> Nomex ()Source