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

Safe HaskellNone



Basic rules examples.



autoActivate :: RuleFuncSource

This rule will activate automatically any new rule.

legal :: RuleFuncSource

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

illegal :: RuleFuncSource

A rule will be always illegal

maybeMetaRule :: Rule -> Nomex (Maybe (Rule -> Nomex BoolResp))Source

active metarules are automatically used to evaluate a given rule checkWithMetarules :: Rule -> Nomex (Event (Message ForAgainst) checkWithMetarules rule = do rs <- getActiveRules (metas :: [Rule -> Nomex BoolResp]) <- mapMaybeM maybeMetaRule rs let (evals :: [Nomex BoolResp]) = map (meta -> meta rule) metas foldr (&&*) true evals

onRuleProposed :: (Rule -> Nomex (Msg [ForAgainst])) -> RuleFuncSource

any new rule will be activate if the rule in parameter returns True

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

modifyAllValues :: 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: