aivika-transformers-5.4: Transformers for the Aivika simulation library

CopyrightCopyright (c) 2009-2017 David Sorokin <david.sorokin@gmail.com>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Simulation.Aivika.Trans.Net

Contents

Description

Tested with: GHC 8.0.1

The module defines a Net arrow that can be applied to modeling the queue networks like the Processor arrow from another module. Only the former has a more efficient implementation of the Arrow interface than the latter, although at the cost of some decreasing in generality.

While the Processor type is just a function that transforms the input Stream into another, the Net type is actually an automaton that has an implementation very similar to that one which the Circuit type has, only the computations occur in the Process monad. But unlike the Circuit type, the Net type doesn't allow declaring recursive definitions, being based on continuations.

In a nutshell, the Net type is an interchangeable alternative to the Processor type with its weaknesses and strengths. The Net arrow is useful for constructing computations with help of the proc-notation to be transformed then to the Processor computations that are more general in nature and more easy-to-use but which computations created with help of the proc-notation are not so efficient.

Synopsis

Net Arrow

newtype Net m a b Source #

Represents the net as an automaton working within the Process computation.

Constructors

Net 

Fields

Instances

MonadDES m => Arrow (Net m) Source # 

Methods

arr :: (b -> c) -> Net m b c #

first :: Net m b c -> Net m (b, d) (c, d) #

second :: Net m b c -> Net m (d, b) (d, c) #

(***) :: Net m b c -> Net m b' c' -> Net m (b, b') (c, c') #

(&&&) :: Net m b c -> Net m b c' -> Net m b (c, c') #

MonadDES m => ArrowChoice (Net m) Source # 

Methods

left :: Net m b c -> Net m (Either b d) (Either c d) #

right :: Net m b c -> Net m (Either d b) (Either d c) #

(+++) :: Net m b c -> Net m b' c' -> Net m (Either b b') (Either c c') #

(|||) :: Net m b d -> Net m c d -> Net m (Either b c) d #

MonadDES m => Category * (Net m) Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

iterateNet :: MonadDES m => Net m a a -> a -> Process m () Source #

Iterate infinitely using the specified initial value.

iterateNetMaybe :: MonadDES m => Net m a (Maybe a) -> a -> Process m () Source #

Iterate the net using the specified initial value until Nothing is returned within the Net computation.

iterateNetEither :: MonadDES m => Net m a (Either b a) -> a -> Process m b Source #

Iterate the net using the specified initial value until the Left result is returned within the Net computation.

Net Primitives

emptyNet :: MonadDES m => Net m a b Source #

A net that never finishes its work.

arrNet :: MonadDES m => (a -> Process m b) -> Net m a b Source #

Create a simple net by the specified handling function that runs the discontinuous process for each input value to get an output.

accumNet :: MonadDES m => (acc -> a -> Process m (acc, b)) -> acc -> Net m a b Source #

Accumulator that outputs a value determined by the supplied function.

withinNet :: MonadDES m => Process m () -> Net m a a Source #

Involve the computation with side effect when processing the input.

Specifying Identifier

netUsingId :: MonadDES m => ProcessId m -> Net m a b -> Net m a b Source #

Create a net that will use the specified process identifier. It can be useful to refer to the underlying Process computation which can be passivated, interrupted, canceled and so on. See also the processUsingId function for more details.

Arrival Net

arrivalNet :: MonadDES m => Net m a (Arrival a) Source #

A net that adds the information about the time points at which the values were received.

Delaying Net

delayNet :: MonadDES m => a -> Net m a a Source #

Delay the input by one step using the specified initial value.

Interchanging Nets with Processors

netProcessor :: MonadDES m => Net m a b -> Processor m a b Source #

Transform the net to an equivalent processor (a rather cheap transformation).

processorNet :: MonadDES m => Processor m a b -> Net m a b Source #

Transform the processor to a similar net (a more costly transformation).

Debugging

traceNet Source #

Arguments

:: MonadDES m 
=> Maybe String

the request message

-> Maybe String

the response message

-> Net m a b

a net

-> Net m a b 

Show the debug messages with the current simulation time.