Portability | unportable |
---|---|
Stability | experimental |
Maintainer | jochem@functor.nl |
This module imports all relevant functions from Control.Hasim.* hiding implementation details.
- type Time = Double
- type Id = Int
- data Simulation
- type SimMonad a = StateT SimState IO a
- mkAnonProcess :: SimMonad (Proc pkt ())
- mkProcess :: String -> st -> SimMonad (Proc pkt st)
- setAction :: Proc pkt st -> Action pkt st () -> SimMonad ()
- createSimulation :: SimMonad () -> IO Simulation
- data Proc pkt st
- type Acceptor pkt st = pkt -> AcceptResult pkt st
- data Process
- data Action
- data AcceptResult pkt st
- module Control.Hasim.Action
- runSimulation :: Simulation -> IO ()
Types
The type that represents a time.
The type that represents a process identifier.
Simulation
data Simulation Source
Data type representing a simulation.
type SimMonad a = StateT SimState IO aSource
The simulation monad called SimMonad
. In this
monad you can define a simulation to be run.
mkAnonProcess :: SimMonad (Proc pkt ())Source
Make an anonymous process.
:: String | The name of the new process. |
-> st | The initial state of the process. |
-> SimMonad (Proc pkt st) |
Make a process with a name. This name will be used in logging and error messages
:: Proc pkt st | The process of which the action should be set |
-> Action pkt st () | The action to be set |
-> SimMonad () |
Set the action of the process.
createSimulation :: SimMonad () -> IO SimulationSource
Create a simulation from a SimMonad (a simulation definition).
If the simulation is invalid, error
will be called.
Process
A Proc st pkt
is a process that potentially accepts packets of type
pkt
while maintaining state st
.
type Acceptor pkt st = pkt -> AcceptResult pkt stSource
An acceptor of a pkt
is an AcceptResult
, which is either
* Refuse
if the packet is to be delivered at a later time, or
never, of course
* Parallel act
if a current computation should not be suspended,
but the state should be changed.
* Interrupt act
if the current computation should be suspended.
The Action
GADT. This is a GADT with three
parameters; an Action pkt st a
is a action where
* pkt denotes the packet type of incoming packets
* st denotes the state that can be modified
and inspected
* a denotes the result value of the Action
data AcceptResult pkt st Source
The type of result of the Acceptor
Actions
module Control.Hasim.Action
SimRun
runSimulation :: Simulation -> IO ()Source
Run the simulation.