Safe Haskell | None |
---|
Basic rules examples.
- autoActivate :: RuleFunc
- legal :: RuleFunc
- illegal :: RuleFunc
- checkWithMetarules :: Rule -> Nomex BoolResp
- maybeMetaRule :: Rule -> Nomex (Maybe (Rule -> Nomex BoolResp))
- onRuleProposed :: (Rule -> Nomex BoolResp) -> RuleFunc
- data ForAgainst
- type Vote = (PlayerNumber, Maybe ForAgainst)
- type CountVotes = [Vote] -> Maybe Bool
- data VoteData = VoteData {}
- type Assessor a = StateT VoteData Nomex a
- voteWith :: CountVotes -> Assessor () -> Rule -> Nomex BoolResp
- assessOnEveryVotes :: Assessor ()
- assessOnTimeLimit :: UTCTime -> Assessor ()
- assessOnTimeDelay :: NominalDiffTime -> Assessor ()
- assessWhenEverybodyVoted :: Assessor ()
- noStatusQuo :: [Vote] -> [Vote]
- cleanVote :: VoteData -> Nomex ()
- assessOnlyVoters :: CountVotes -> CountVotes
- quorum :: Int -> [Vote] -> Bool
- withQuorum :: CountVotes -> Int -> CountVotes
- unanimity :: [Vote] -> Maybe Bool
- majority :: [Vote] -> Maybe Bool
- majorityWith :: Int -> [Vote] -> Maybe Bool
- numberPositiveVotes :: Int -> [Vote] -> Maybe Bool
- voteQuota :: Int -> [Vote] -> Maybe Bool
- nbFor :: [Vote] -> Int
- nbAgainst :: [Vote] -> Int
- voters :: [(PlayerNumber, Maybe ForAgainst)] -> [(PlayerNumber, ForAgainst)]
- getOnlyVoters :: [(PlayerNumber, Maybe ForAgainst)] -> [(PlayerNumber, Maybe ForAgainst)]
- activateOrReject :: Rule -> Bool -> Nomex ()
- forEachPlayer :: (PlayerNumber -> Nomex ()) -> (PlayerNumber -> Nomex ()) -> (PlayerNumber -> Nomex ()) -> Nomex ()
- forEachPlayer_ :: (PlayerNumber -> Nomex ()) -> Nomex ()
- createValueForEachPlayer :: Int -> V [(Int, Int)] -> Nomex ()
- createValueForEachPlayer_ :: V [(Int, Int)] -> Nomex ()
- modifyValueOfPlayer :: PlayerNumber -> V [(Int, Int)] -> (Int -> Int) -> Nomex ()
- modifyAllValues :: V [(Int, Int)] -> (Int -> Int) -> Nomex ()
- noPlayPlayer :: PlayerNumber -> RuleFunc
- autoDelete :: Nomex ()
- eraseAllRules :: PlayerNumber -> Nomex Bool
- oneDay :: NominalDiffTime
- maybeWhen :: Maybe a -> (a -> Nomex ()) -> Nomex ()
Documentation
autoActivate :: RuleFuncSource
This rule will activate automatically any new rule.
This rule will forbid any new rule to delete the rule in parameter immutableRule :: RuleNumber -> RuleFunc immutableRule rn = return $ Meta f where f r = do protectedRule <- getRule rn case protectedRule of Just pr -> case _rRuleFunc r of RuleRule paramRule -> paramRule pr _ -> return $ BoolResp True Nothing -> return $ BoolResp True
A rule will be always legal
checkWithMetarules :: Rule -> Nomex BoolRespSource
active metarules are automatically used to evaluate a given rule
onRuleProposed :: (Rule -> Nomex BoolResp) -> RuleFuncSource
any new rule will be activate if the rule in parameter returns True
data ForAgainst Source
type Vote = (PlayerNumber, Maybe ForAgainst)Source
type CountVotes = [Vote] -> Maybe BoolSource
voteWith :: CountVotes -> Assessor () -> Rule -> Nomex BoolRespSource
Performs a vote for a rule on all players. The provided function is used to count the votes. the assessors allows to configure how and when the vote will be assessed. The assessors can be chained.
assessOnEveryVotes :: Assessor ()Source
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 :: UTCTime -> Assessor ()Source
assess the vote with the assess function when time is reached, and sends a signal with the issue (positive of negative)
assessOnTimeDelay :: NominalDiffTime -> Assessor ()Source
assess the vote with the assess function when time is elapsed, and sends a signal with the issue (positive of negative)
assessWhenEverybodyVoted :: Assessor ()Source
assess the vote only when every body voted. An error is generated if the assessing function returns Nothing.
noStatusQuo :: [Vote] -> [Vote]Source
players that did not voted are counted as negative.
quorum :: Int -> [Vote] -> BoolSource
a quorum is the neccessary number of voters for the validity of the vote
withQuorum :: CountVotes -> Int -> CountVotesSource
adds a quorum to an assessing function
unanimity :: [Vote] -> Maybe BoolSource
assess the vote results according to a unanimity (everybody votes for)
majority :: [Vote] -> Maybe BoolSource
assess the vote results according to an absolute majority (half voters plus one, no quorum is needed)
majorityWith :: Int -> [Vote] -> Maybe BoolSource
assess the vote results according to a majority of x (in %)
numberPositiveVotes :: Int -> [Vote] -> Maybe BoolSource
assess the vote results according to a necessary number of positive votes
voters :: [(PlayerNumber, Maybe ForAgainst)] -> [(PlayerNumber, ForAgainst)]Source
get only those who voted
getOnlyVoters :: [(PlayerNumber, Maybe ForAgainst)] -> [(PlayerNumber, Maybe ForAgainst)]Source
get only those who voted
activateOrReject :: Rule -> Bool -> Nomex ()Source
activate or reject a rule
forEachPlayer :: (PlayerNumber -> Nomex ()) -> (PlayerNumber -> Nomex ()) -> (PlayerNumber -> Nomex ()) -> Nomex ()Source
perform an action for each current players, new players and leaving players
forEachPlayer_ :: (PlayerNumber -> Nomex ()) -> Nomex ()Source
perform the same action for each players, including new players
createValueForEachPlayer :: Int -> V [(Int, Int)] -> Nomex ()Source
create a value initialized for each players manages players joining and leaving
createValueForEachPlayer_ :: V [(Int, Int)] -> Nomex ()Source
create a value initialized for each players initialized to zero manages players joining and leaving
modifyValueOfPlayer :: PlayerNumber -> V [(Int, Int)] -> (Int -> Int) -> Nomex ()Source
noPlayPlayer :: PlayerNumber -> RuleFuncSource
Player p cannot propose anymore rules
autoDelete :: Nomex ()Source
a rule can autodelete itself (generaly after having performed some actions)
eraseAllRules :: PlayerNumber -> Nomex BoolSource
All rules from player p are erased: