Copyright | Copyright (c) 2009-2017 David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- newtype Net a b = Net {}
- iterateNet :: Net a a -> a -> Process ()
- iterateNetMaybe :: Net a (Maybe a) -> a -> Process ()
- iterateNetEither :: Net a (Either b a) -> a -> Process b
- emptyNet :: Net a b
- arrNet :: (a -> Process b) -> Net a b
- accumNet :: (acc -> a -> Process (acc, b)) -> acc -> Net a b
- withinNet :: Process () -> Net a a
- netUsingId :: ProcessId -> Net a b -> Net a b
- arrivalNet :: Net a (Arrival a)
- delayNet :: a -> Net a a
- netProcessor :: Net a b -> Processor a b
- processorNet :: Processor a b -> Net a b
- traceNet :: Maybe String -> Maybe String -> Net a b -> Net a b
Net Arrow
Represents the net as an automaton working within the Process
computation.
iterateNet :: Net a a -> a -> Process () Source #
Iterate infinitely using the specified initial value.
Net Primitives
arrNet :: (a -> Process b) -> Net 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 :: (acc -> a -> Process (acc, b)) -> acc -> Net a b Source #
Accumulator that outputs a value determined by the supplied function.
withinNet :: Process () -> Net a a Source #
Involve the computation with side effect when processing the input.
Specifying Identifier
netUsingId :: ProcessId -> Net a b -> Net 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 :: Net a (Arrival a) Source #
A net that adds the information about the time points at which the values were received.
Delaying Net
Interchanging Nets with Processors
netProcessor :: Net a b -> Processor a b Source #
Transform the net to an equivalent processor (a rather cheap transformation).
processorNet :: Processor a b -> Net a b Source #
Transform the processor to a similar net (a more costly transformation).