Safe Haskell | None |
---|
This module containt the type definitions necessary to build a Nomic rule.
- type PlayerNumber = Int
- type PlayerName = String
- type RuleNumber = Int
- type RuleName = String
- type RuleText = String
- type RuleCode = String
- type EventNumber = Int
- type EventName = String
- type VarName = String
- type GameName = String
- type Code = String
- data Exp a where
- NewVar :: (Typeable a, Show a, Eq a) => VarName -> a -> Exp (Maybe (V a))
- DelVar :: V a -> Exp Bool
- ReadVar :: (Typeable a, Show a, Eq a) => V a -> Exp (Maybe a)
- WriteVar :: (Typeable a, Show a, Eq a) => V a -> a -> Exp Bool
- OnEvent :: (Typeable e, Show e, Eq e) => Event e -> ((EventNumber, EventData e) -> Exp ()) -> Exp EventNumber
- DelEvent :: EventNumber -> Exp Bool
- DelAllEvents :: (Typeable e, Show e, Eq e) => Event e -> Exp ()
- SendMessage :: (Typeable a, Show a, Eq a) => Event (Message a) -> a -> Exp ()
- Output :: PlayerNumber -> String -> Exp ()
- ProposeRule :: Rule -> Exp Bool
- ActivateRule :: RuleNumber -> Exp Bool
- RejectRule :: RuleNumber -> Exp Bool
- AddRule :: Rule -> Exp Bool
- DelRule :: RuleNumber -> Exp Bool
- ModifyRule :: RuleNumber -> Rule -> Exp Bool
- GetRules :: Exp [Rule]
- SetVictory :: [PlayerNumber] -> Exp ()
- GetPlayers :: Exp [PlayerInfo]
- Const :: a -> Exp a
- Bind :: Exp a -> (a -> Exp b) -> Exp b
- CurrentTime :: Exp UTCTime
- SelfRuleNumber :: Exp RuleNumber
- data V a = V {}
- data Var = forall a . (Typeable a, Show a, Eq a) => Var {
- vRuleNumber :: Int
- vName :: String
- vData :: a
- type Output = (PlayerNumber, String)
- data Player
- data RuleEvent
- data Time
- data EvRule
- data Message m
- data InputChoice c
- data InputString
- data Victory
- data Event a where
- Player :: Player -> Event Player
- RuleEv :: RuleEvent -> Event RuleEvent
- Time :: UTCTime -> Event Time
- Message :: String -> Event (Message m)
- InputChoice :: (Eq c, Show c) => PlayerNumber -> String -> [c] -> c -> Event (InputChoice c)
- InputString :: PlayerNumber -> String -> Event InputString
- Victory :: Event Victory
- data EventData a where
- PlayerData :: { } -> EventData Player
- RuleData :: { } -> EventData RuleEvent
- TimeData :: { } -> EventData Time
- MessageData :: Show m => {
- messageData :: m
- InputChoiceData :: Show c => {
- inputChoiceData :: c
- InputStringData :: { } -> EventData InputString
- VictoryData :: {
- victoryData :: [PlayerInfo]
- data EventHandler where
- EH :: (Typeable e, Show e, Eq e) => {
- eventNumber :: EventNumber
- ruleNumber :: RuleNumber
- event :: Event e
- handler :: (EventNumber, EventData e) -> Exp ()
- EH :: (Typeable e, Show e, Eq e) => {
- type OneParamRule a = a -> Exp RuleResponse
- type NoParamRule = Exp ()
- data RuleResponse
- data RuleFunc
- = RuleRule { }
- | PlayerRule { }
- | VoidRule { }
- data Rule = Rule {}
- data RuleStatus
- data PlayerInfo = PlayerInfo {}
- data Game = Game {
- gameName :: GameName
- gameDesc :: String
- rules :: [Rule]
- players :: [PlayerInfo]
- variables :: [Var]
- events :: [EventHandler]
- outputs :: [Output]
- victory :: [PlayerNumber]
- currentTime :: UTCTime
- (===) :: (Typeable a, Typeable b, Eq b) => a -> b -> Bool
- replaceWith :: (a -> Bool) -> a -> [a] -> [a]
Documentation
type PlayerNumber = IntSource
type PlayerName = StringSource
type RuleNumber = IntSource
type EventNumber = IntSource
Expression
an Exp allows the player's rule to have access to the state of the game. | it is a compositional algebra defined with a GADT.
NewVar :: (Typeable a, Show a, Eq a) => VarName -> a -> Exp (Maybe (V a)) | |
DelVar :: V a -> Exp Bool | |
ReadVar :: (Typeable a, Show a, Eq a) => V a -> Exp (Maybe a) | |
WriteVar :: (Typeable a, Show a, Eq a) => V a -> a -> Exp Bool | |
OnEvent :: (Typeable e, Show e, Eq e) => Event e -> ((EventNumber, EventData e) -> Exp ()) -> Exp EventNumber | |
DelEvent :: EventNumber -> Exp Bool | |
DelAllEvents :: (Typeable e, Show e, Eq e) => Event e -> Exp () | |
SendMessage :: (Typeable a, Show a, Eq a) => Event (Message a) -> a -> Exp () | |
Output :: PlayerNumber -> String -> Exp () | |
ProposeRule :: Rule -> Exp Bool | |
ActivateRule :: RuleNumber -> Exp Bool | |
RejectRule :: RuleNumber -> Exp Bool | |
AddRule :: Rule -> Exp Bool | |
DelRule :: RuleNumber -> Exp Bool | |
ModifyRule :: RuleNumber -> Rule -> Exp Bool | |
GetRules :: Exp [Rule] | |
SetVictory :: [PlayerNumber] -> Exp () | |
GetPlayers :: Exp [PlayerInfo] | |
Const :: a -> Exp a | |
Bind :: Exp a -> (a -> Exp b) -> Exp b | |
CurrentTime :: Exp UTCTime | |
SelfRuleNumber :: Exp RuleNumber |
Variables
stores the variable's data
type Output = (PlayerNumber, String)Source
Events
data InputChoice c Source
Typeable1 InputChoice | |
Eq (InputChoice a) | |
Show a => Show (InputChoice a) |
events names
Player :: Player -> Event Player | |
RuleEv :: RuleEvent -> Event RuleEvent | |
Time :: UTCTime -> Event Time | |
Message :: String -> Event (Message m) | |
InputChoice :: (Eq c, Show c) => PlayerNumber -> String -> [c] -> c -> Event (InputChoice c) | |
InputString :: PlayerNumber -> String -> Event InputString | |
Victory :: Event Victory |
data associated with each events
PlayerData :: PlayerInfo -> EventData Player | |
RuleData :: Rule -> EventData RuleEvent | |
TimeData :: UTCTime -> EventData Time | |
MessageData :: Show m => m -> EventData (Message m) | |
| |
InputChoiceData :: Show c => c -> EventData (InputChoice c) | |
| |
InputStringData :: String -> EventData InputString | |
VictoryData :: [PlayerInfo] -> EventData Victory | |
|
data EventHandler whereSource
EH :: (Typeable e, Show e, Eq e) => EventNumber -> RuleNumber -> Event e -> ((EventNumber, EventData e) -> Exp ()) -> EventHandler | |
|
Rule
type OneParamRule a = a -> Exp RuleResponseSource
type of rule to assess the legality of a given parameter
type NoParamRule = Exp ()Source
type of rule that just mofify the game state
data RuleResponse Source
a rule can assess the legality either immediatly of later through a messsage
the different types of rules
An informationnal structure about a rule:
Rule | |
|
data RuleStatus Source
the status of a rule.
Player
data PlayerInfo Source
informations on players
Game
The state of the game:
Game | |
|
(===) :: (Typeable a, Typeable b, Eq b) => a -> b -> BoolSource
an equality that tests also the types.
:: (a -> Bool) | Value to search |
-> a | Value to replace it with |
-> [a] | Input list |
-> [a] | Output list |
Replaces all instances of a value in a list by another value.