Safe Haskell | None |
---|
All the building blocks to build rules.
- newVar :: (Typeable a, Show a, Eq a) => VarName -> a -> Nomex (Maybe (V a))
- newVar_ :: (Typeable a, Show a, Eq a) => VarName -> a -> Nomex (V a)
- readVar :: (Typeable a, Show a, Eq a) => V a -> Nomex (Maybe a)
- readVar_ :: forall a. (Typeable a, Show a, Eq a) => V a -> Nomex a
- writeVar :: (Typeable a, Show a, Eq a) => V a -> a -> Nomex Bool
- writeVar_ :: (Typeable a, Show a, Eq a) => V a -> a -> Nomex ()
- modifyVar :: (Typeable a, Show a, Eq a) => V a -> (a -> a) -> Nomex ()
- delVar :: V a -> Nomex Bool
- delVar_ :: V a -> Nomex ()
- data ArrayVar i a = ArrayVar (Msg [(i, Maybe a)]) (V (Map i (Maybe a)))
- newArrayVar :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => VarName -> [i] -> Nomex (ArrayVar i a)
- newArrayVar' :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => VarName -> [i] -> ([(i, Maybe a)] -> Nomex ()) -> Nomex (ArrayVar i a)
- newArrayVarOnce :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => VarName -> [i] -> ([(i, Maybe a)] -> Nomex ()) -> Nomex (ArrayVar i a)
- isFullArrayVar :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> Nomex Bool
- putArrayVar :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> i -> a -> Nomex ()
- getArrayVarMessage :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> Nomex (Msg [(i, Maybe a)])
- getArrayVarData :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> Nomex [(i, Maybe a)]
- getArrayVarData' :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> Nomex [(i, a)]
- delArrayVar :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> Nomex ()
- onEvent :: (Typeable e, Show e, Eq e) => Event e -> ((EventNumber, EventData e) -> Nomex ()) -> Nomex EventNumber
- onEvent_ :: forall e. (Typeable e, Show e, Eq e) => Event e -> (EventData e -> Nomex ()) -> Nomex ()
- onEventOnce :: (Typeable e, Show e, Eq e) => Event e -> (EventData e -> Nomex ()) -> Nomex EventNumber
- onEventOnce_ :: (Typeable e, Show e, Eq e) => Event e -> (EventData e -> Nomex ()) -> Nomex ()
- delEvent :: EventNumber -> Nomex Bool
- delEvent_ :: EventNumber -> Nomex ()
- delAllEvents :: (Typeable e, Show e, Eq e) => Event e -> Nomex ()
- sendMessage :: (Typeable a, Show a, Eq a) => Msg a -> a -> Nomex ()
- sendMessage_ :: Msg () -> Nomex ()
- onMessage :: (Typeable m, Show m) => Msg m -> (MsgData m -> Nomex ()) -> Nomex ()
- onMessageOnce :: (Typeable m, Show m) => Msg m -> (MsgData m -> Nomex ()) -> Nomex ()
- schedule :: Schedule Freq -> (UTCTime -> Nomex ()) -> Nomex ()
- executeAndScheduleNext :: (EventData Time -> Nomex ()) -> Schedule Freq -> EventData Time -> Nomex ()
- schedule_ :: Schedule Freq -> Nomex () -> Nomex ()
- schedule' :: [UTCTime] -> (UTCTime -> Nomex ()) -> Nomex ()
- executeAndScheduleNext' :: (EventData Time -> Nomex ()) -> [UTCTime] -> EventData Time -> Nomex ()
- schedule'_ :: [UTCTime] -> Nomex () -> Nomex ()
- activateRule :: RuleNumber -> Nomex Bool
- activateRule_ :: RuleNumber -> Nomex ()
- rejectRule :: RuleNumber -> Nomex Bool
- rejectRule_ :: RuleNumber -> Nomex ()
- getRules :: Nomex [Rule]
- getActiveRules :: Nomex [Rule]
- getRule :: RuleNumber -> Nomex (Maybe Rule)
- getRulesByNumbers :: [RuleNumber] -> Nomex [Rule]
- getRuleFuncs :: Nomex [RuleFunc]
- addRule :: Rule -> Nomex Bool
- addRule_ :: Rule -> Nomex ()
- addRuleParams_ :: RuleName -> RuleFunc -> RuleCode -> RuleNumber -> String -> Nomex ()
- suppressRule :: RuleNumber -> Nomex Bool
- suppressRule_ :: RuleNumber -> Nomex ()
- suppressAllRules :: Nomex Bool
- modifyRule :: RuleNumber -> Rule -> Nomex Bool
- inputChoice :: (Eq c, Show c) => PlayerNumber -> String -> [c] -> c -> Event (InputChoice c)
- inputChoiceHead :: (Eq c, Show c) => PlayerNumber -> String -> [c] -> Event (InputChoice c)
- inputChoiceEnum :: forall c. (Enum c, Bounded c, Typeable c, Eq c, Show c) => PlayerNumber -> String -> c -> Event (InputChoice c)
- inputString :: PlayerNumber -> String -> Event InputString
- onInputChoice :: (Typeable a, Eq a, Show a) => String -> [a] -> (EventNumber -> a -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
- onInputChoice_ :: (Typeable a, Eq a, Show a) => String -> [a] -> (a -> Nomex ()) -> PlayerNumber -> Nomex ()
- onInputChoiceOnce :: (Typeable a, Eq a, Show a) => String -> [a] -> (a -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
- onInputChoiceOnce_ :: (Typeable a, Eq a, Show a) => String -> [a] -> (a -> Nomex ()) -> PlayerNumber -> Nomex ()
- onInputChoiceEnum :: forall a. (Enum a, Bounded a, Typeable a, Eq a, Show a) => String -> a -> (EventNumber -> a -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
- onInputChoiceEnum_ :: forall a. (Enum a, Bounded a, Typeable a, Eq a, Show a) => String -> a -> (a -> Nomex ()) -> PlayerNumber -> Nomex ()
- onInputChoiceEnumOnce_ :: forall a. (Enum a, Bounded a, Typeable a, Eq a, Show a) => String -> a -> (a -> Nomex ()) -> PlayerNumber -> Nomex ()
- onInputString :: String -> (EventNumber -> String -> Nomex ()) -> PlayerNumber -> Nomex EventNumber
- onInputString_ :: String -> (String -> Nomex ()) -> PlayerNumber -> Nomex ()
- onInputStringOnce_ :: String -> (String -> Nomex ()) -> PlayerNumber -> Nomex ()
- getPlayers :: Nomex [PlayerInfo]
- getPlayer :: PlayerNumber -> Nomex (Maybe PlayerInfo)
- getPlayerName :: PlayerNumber -> Nomex (Maybe PlayerName)
- setPlayerName :: PlayerNumber -> PlayerName -> Nomex Bool
- modifyPlayerName :: PlayerNumber -> (PlayerName -> PlayerName) -> Nomex Bool
- getPlayersNumber :: Nomex Int
- getAllPlayerNumbers :: Nomex [PlayerNumber]
- delPlayer :: PlayerNumber -> Nomex Bool
- setVictory :: [PlayerNumber] -> Nomex ()
- giveVictory :: PlayerNumber -> Nomex ()
- output :: String -> PlayerNumber -> Nomex ()
- outputAll :: String -> Nomex ()
- getCurrentTime :: Nomex UTCTime
- getSelfRuleNumber :: Nomex RuleNumber
- getSelfRule :: Nomex Rule
- getSelfProposedByPlayer :: Nomex PlayerNumber
- voidRule :: Nomex a -> Nomex RuleResp
- andMsgBool :: Bool -> Msg Bool -> Nomex (Msg Bool)
- andMsgMsg :: Msg Bool -> Msg Bool -> Nomex (Msg Bool)
- defaultRule :: Rule
Variables
modifyVar :: (Typeable a, Show a, Eq a) => V a -> (a -> a) -> Nomex ()Source
modify a variable using the provided function
Variable arrays
ArrayVar is an indexed array with a signal attached to warn when the array is filled. | each indexed elements starts empty (value=Nothing), and when the array is full, the signal is triggered. | This is useful to wait for a serie of events to happen, and trigger a computation on the collected results.
newArrayVar :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => VarName -> [i] -> Nomex (ArrayVar i a)Source
initialize an empty ArrayVar
newArrayVar' :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => VarName -> [i] -> ([(i, Maybe a)] -> Nomex ()) -> Nomex (ArrayVar i a)Source
initialize an empty ArrayVar, registering a callback that will be triggered when the array is filled
newArrayVarOnce :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => VarName -> [i] -> ([(i, Maybe a)] -> Nomex ()) -> Nomex (ArrayVar i a)Source
initialize an empty ArrayVar, registering a callback. the callback will be triggered when the array is filled, and then the ArrayVar will be deleted
isFullArrayVar :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> Nomex BoolSource
putArrayVar :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> i -> a -> Nomex ()Source
store one value and the given index. If this is the last filled element, the registered callbacks are triggered.
getArrayVarMessage :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> Nomex (Msg [(i, Maybe a)])Source
get the messsage triggered when the array is filled
getArrayVarData :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> Nomex [(i, Maybe a)]Source
get the association array
getArrayVarData' :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> Nomex [(i, a)]Source
get the association array with only the filled values
delArrayVar :: (Ord i, Typeable a, Show a, Eq a, Typeable i, Show i) => ArrayVar i a -> Nomex ()Source
Events
onEvent :: (Typeable e, Show e, Eq e) => Event e -> ((EventNumber, EventData e) -> Nomex ()) -> Nomex EventNumberSource
register a callback on an event
onEvent_ :: forall e. (Typeable e, Show e, Eq e) => Event e -> (EventData e -> Nomex ()) -> Nomex ()Source
register a callback on an event, disregard the event number
onEventOnce :: (Typeable e, Show e, Eq e) => Event e -> (EventData e -> Nomex ()) -> Nomex EventNumberSource
set an handler for an event that will be triggered only once
onEventOnce_ :: (Typeable e, Show e, Eq e) => Event e -> (EventData e -> Nomex ()) -> Nomex ()Source
set an handler for an event that will be triggered only once
delEvent :: EventNumber -> Nomex BoolSource
delEvent_ :: EventNumber -> Nomex ()Source
sendMessage :: (Typeable a, Show a, Eq a) => Msg a -> a -> Nomex ()Source
broadcast a message that can be catched by another rule
sendMessage_ :: Msg () -> Nomex ()Source
onMessage :: (Typeable m, Show m) => Msg m -> (MsgData m -> Nomex ()) -> Nomex ()Source
subscribe on a message
schedule :: Schedule Freq -> (UTCTime -> Nomex ()) -> Nomex ()Source
on the provided schedule, the supplied function will be called
executeAndScheduleNext :: (EventData Time -> Nomex ()) -> Schedule Freq -> EventData Time -> Nomex ()Source
executeAndScheduleNext' :: (EventData Time -> Nomex ()) -> [UTCTime] -> EventData Time -> Nomex ()Source
schedule'_ :: [UTCTime] -> Nomex () -> Nomex ()Source
Rule management
activateRule :: RuleNumber -> Nomex BoolSource
activate a rule: change its state to Active and execute it
activateRule_ :: RuleNumber -> Nomex ()Source
rejectRule :: RuleNumber -> Nomex BoolSource
reject a rule: change its state to Suppressed and suppresses all its environment (events, variables, inputs) the rule can be activated again later
rejectRule_ :: RuleNumber -> Nomex ()Source
getRulesByNumbers :: [RuleNumber] -> Nomex [Rule]Source
addRuleParams_ :: RuleName -> RuleFunc -> RuleCode -> RuleNumber -> String -> Nomex ()Source
suppressRule_ :: RuleNumber -> Nomex ()Source
modifyRule :: RuleNumber -> Rule -> Nomex BoolSource
Inputs
inputChoice :: (Eq c, Show c) => PlayerNumber -> String -> [c] -> c -> Event (InputChoice c)Source
inputChoiceHead :: (Eq c, Show c) => PlayerNumber -> String -> [c] -> Event (InputChoice c)Source
inputChoiceEnum :: forall c. (Enum c, Bounded c, Typeable c, Eq c, Show c) => PlayerNumber -> String -> c -> Event (InputChoice c)Source
inputString :: PlayerNumber -> String -> Event InputStringSource
onInputChoice :: (Typeable a, Eq a, Show a) => String -> [a] -> (EventNumber -> a -> Nomex ()) -> PlayerNumber -> Nomex EventNumberSource
triggers a choice input to the user. The result will be sent to the callback
onInputChoice_ :: (Typeable a, Eq a, Show a) => String -> [a] -> (a -> Nomex ()) -> PlayerNumber -> Nomex ()Source
the same, disregard the event number
onInputChoiceOnce :: (Typeable a, Eq a, Show a) => String -> [a] -> (a -> Nomex ()) -> PlayerNumber -> Nomex EventNumberSource
the same, suppress the event after first trigger
onInputChoiceOnce_ :: (Typeable a, Eq a, Show a) => String -> [a] -> (a -> Nomex ()) -> PlayerNumber -> Nomex ()Source
the same, disregard the event number
onInputChoiceEnum :: forall a. (Enum a, Bounded a, Typeable a, Eq a, Show a) => String -> a -> (EventNumber -> a -> Nomex ()) -> PlayerNumber -> Nomex EventNumberSource
triggers a choice input to the user, using an enumerate as input
onInputChoiceEnum_ :: forall a. (Enum a, Bounded a, Typeable a, Eq a, Show a) => String -> a -> (a -> Nomex ()) -> PlayerNumber -> Nomex ()Source
the same, disregard the event number
onInputChoiceEnumOnce_ :: forall a. (Enum a, Bounded a, Typeable a, Eq a, Show a) => String -> a -> (a -> Nomex ()) -> PlayerNumber -> Nomex ()Source
the same, suppress the event after first trigger
onInputString :: String -> (EventNumber -> String -> Nomex ()) -> PlayerNumber -> Nomex EventNumberSource
triggers a string input to the user. The result will be sent to the callback
onInputString_ :: String -> (String -> Nomex ()) -> PlayerNumber -> Nomex ()Source
asks the player pn to answer a question, and feed the callback with this data.
onInputStringOnce_ :: String -> (String -> Nomex ()) -> PlayerNumber -> Nomex ()Source
asks the player pn to answer a question, and feed the callback with this data.
Victory, players
getPlayers :: Nomex [PlayerInfo]Source
get all the players
getPlayer :: PlayerNumber -> Nomex (Maybe PlayerInfo)Source
Get a specific player
getPlayerName :: PlayerNumber -> Nomex (Maybe PlayerName)Source
Set the name of a player
setPlayerName :: PlayerNumber -> PlayerName -> Nomex BoolSource
Set the name of a player
modifyPlayerName :: PlayerNumber -> (PlayerName -> PlayerName) -> Nomex BoolSource
getPlayersNumber :: Nomex IntSource
Get the total number of playersgetPlayersNumber :: Nomex Int
getAllPlayerNumbers :: Nomex [PlayerNumber]Source
Get all the players number
delPlayer :: PlayerNumber -> Nomex BoolSource
Remove the player from the game (kick)
Victory, output, time and self-number
setVictory :: [PlayerNumber] -> Nomex ()Source
set victory to a list of players
giveVictory :: PlayerNumber -> Nomex ()Source
give victory to one player
output :: String -> PlayerNumber -> Nomex ()Source
outputs a message to one player
getSelfRuleNumber :: Nomex RuleNumberSource
allows a rule to retrieve its self number (for auto-deleting for example)
Miscellaneous
a default rule