hasim-0.1.2: Process-Based Discrete Event Simulation library

Portabilityunportable
Stabilityexperimental
Maintainerjochem@functor.nl

Control.Hasim

Contents

Description

This module imports all relevant functions from Control.Hasim.* hiding implementation details.

Synopsis

Types

type Time = DoubleSource

The type that represents a time.

The type that represents a process identifier.

type Id = IntSource

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.

mkProcessSource

Arguments

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

setActionSource

Arguments

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

data Proc pkt st Source

A Proc st pkt is a process that potentially accepts packets of type pkt while maintaining state st.

Instances

Eq (Proc pkt st) 
Ord (Proc pkt st) 
Show (Proc pkt 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.

data Process Source

Existential type for a Proc. A Process is a Proc pkt for some pkt.

data Action Source

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

Instances

MonadState st (Action pkt st) 
Monad (Action pkt st) 
MonadIO (Action pkt st) 

data AcceptResult pkt st Source

The type of result of the Acceptor

Constructors

Refuse 
Parallel (st -> st) 
Interrupt (Action pkt st ()) 

Actions

SimRun

runSimulation :: Simulation -> IO ()Source

Run the simulation.