Copyright | Copyright (c) 2009-2017 David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Tested with: GHC 8.0.1
This is an internal implementation module that should never be used directly.
The module defines the Simulation
monad that represents a computation within
the simulation run.
Synopsis
- newtype Simulation a = Simulation (Run -> IO a)
- class SimulationLift m where
- liftSimulation :: Simulation a -> m a
- invokeSimulation :: Run -> Simulation a -> IO a
- runSimulation :: Simulation a -> Specs -> IO a
- runSimulations :: Simulation a -> Specs -> Int -> [IO a]
- runSimulationByIndex :: Simulation a -> Specs -> Int -> Int -> IO a
- catchSimulation :: Exception e => Simulation a -> (e -> Simulation a) -> Simulation a
- finallySimulation :: Simulation a -> Simulation b -> Simulation a
- throwSimulation :: Exception e => e -> Simulation a
- simulationEventQueue :: Simulation EventQueue
- memoSimulation :: Simulation a -> Simulation (Simulation a)
- data SimulationException = Exception e => SimulationException e
- data SimulationAbort = SimulationAbort String
- data SimulationRetry = SimulationRetry String
Simulation
newtype Simulation a Source #
A value in the Simulation
monad represents a computation
within the simulation run.
Simulation (Run -> IO a) |
Instances
class SimulationLift m where Source #
A type class to lift the simulation computations to other computations.
liftSimulation :: Simulation a -> m a Source #
Lift the specified Simulation
computation to another computation.
Instances
SimulationLift Simulation Source # | |
Defined in Simulation.Aivika.Internal.Simulation liftSimulation :: Simulation a -> Simulation a Source # | |
SimulationLift Dynamics Source # | |
Defined in Simulation.Aivika.Internal.Dynamics liftSimulation :: Simulation a -> Dynamics a Source # | |
SimulationLift Event Source # | |
Defined in Simulation.Aivika.Internal.Event liftSimulation :: Simulation a -> Event a Source # | |
SimulationLift Composite Source # | |
Defined in Simulation.Aivika.Composite liftSimulation :: Simulation a -> Composite a Source # | |
SimulationLift Cont Source # | |
Defined in Simulation.Aivika.Internal.Cont liftSimulation :: Simulation a -> Cont a Source # | |
SimulationLift Process Source # | |
Defined in Simulation.Aivika.Internal.Process liftSimulation :: Simulation a -> Process a Source # |
invokeSimulation :: Run -> Simulation a -> IO a Source #
Invoke the Simulation
computation.
runSimulation :: Simulation a -> Specs -> IO a Source #
Run the simulation using the specified specs.
runSimulations :: Simulation a -> Specs -> Int -> [IO a] Source #
Run the given number of simulations using the specified specs,
where each simulation is distinguished by its index simulationIndex
.
:: Simulation a | the simulation model |
-> Specs | the simulation specs |
-> Int | the number of runs in series |
-> Int | the index of the current run (started from 1) |
-> IO a |
Run the simulation by the specified specs and run index in series.
Error Handling
catchSimulation :: Exception e => Simulation a -> (e -> Simulation a) -> Simulation a Source #
Exception handling within Simulation
computations.
finallySimulation :: Simulation a -> Simulation b -> Simulation a Source #
A computation with finalization part like the finally
function.
throwSimulation :: Exception e => e -> Simulation a Source #
Like the standard throw
function.
Utilities
simulationEventQueue :: Simulation EventQueue Source #
Return the event queue.
Memoization
memoSimulation :: Simulation a -> Simulation (Simulation a) Source #
Memoize the Simulation
computation, always returning the same value
within a simulation run.
Exceptions
data SimulationException Source #
The root of simulation exceptions.
Exception e => SimulationException e | A particular simulation exception. |
Instances
Show SimulationException Source # | |
Defined in Simulation.Aivika.Internal.Simulation showsPrec :: Int -> SimulationException -> ShowS # show :: SimulationException -> String # showList :: [SimulationException] -> ShowS # | |
Exception SimulationException Source # | |
data SimulationAbort Source #
An exception that signals of aborting the simulation.
SimulationAbort String | The exception to abort the simulation. |
Instances
Show SimulationAbort Source # | |
Defined in Simulation.Aivika.Internal.Simulation showsPrec :: Int -> SimulationAbort -> ShowS # show :: SimulationAbort -> String # showList :: [SimulationAbort] -> ShowS # | |
Exception SimulationAbort Source # | |
data SimulationRetry Source #
An exception that signals that the current computation should be retried as possible, which feature may be supported by the simulation engine or not.
SimulationRetry String | The exception to retry the computation. |
Instances
Show SimulationRetry Source # | |
Defined in Simulation.Aivika.Internal.Simulation showsPrec :: Int -> SimulationRetry -> ShowS # show :: SimulationRetry -> String # showList :: [SimulationRetry] -> ShowS # | |
Exception SimulationRetry Source # | |