Portability | non-portable (multi-parameter type classes) |
---|---|
Stability | experimental |
Maintainer | ross@soi.city.ac.uk |
Safe Haskell | None |
Arrow transformer lifting an arrow to streams.
- newtype StreamArrow a b c = StreamArrow (a (Stream b) (Stream c))
- runStream :: ArrowLoop a => StreamArrow a (e, b) c -> a (e, Stream b) (Stream c)
- type StreamMap = StreamArrow (->)
- type StreamMapST s = StreamArrow (Kleisli (ST s))
- runStreamST :: (forall s. StreamMapST s e c) -> StreamMap e c
- class (ArrowCircuit a, Arrow a') => ArrowAddStream a a' | a -> a' where
- liftStream :: a' e b -> a e b
- elimStream :: a (e, b) c -> a' (e, Stream b) (Stream c)
Documentation
newtype StreamArrow a b c Source
StreamArrow (a (Stream b) (Stream c)) |
(Arrow (StreamArrow a), Arrow a) => ArrowTransformer StreamArrow a | |
(Monoid w, Arrow (StreamArrow a), ArrowWriter w a) => ArrowWriter w (StreamArrow a) | |
(Arrow (StreamArrow a), ArrowState s a) => ArrowState s (StreamArrow a) | |
(Category (StreamArrow a), Arrow a) => Arrow (StreamArrow a) | |
(Arrow (StreamArrow a), ArrowZero a) => ArrowZero (StreamArrow a) | |
(ArrowZero (StreamArrow a), ArrowPlus a) => ArrowPlus (StreamArrow a) | |
(Arrow (StreamArrow a), Arrow a) => ArrowChoice (StreamArrow a) | |
(Arrow (StreamArrow a), ArrowLoop a) => ArrowLoop (StreamArrow a) | |
Category a => Category (StreamArrow a) | |
(ArrowLoop (StreamArrow a), ArrowLoop a) => ArrowCircuit (StreamArrow a) | |
(ArrowCircuit (StreamArrow a), Arrow a, ArrowLoop a) => ArrowAddStream (StreamArrow a) a | |
Arrow a => Functor (StreamArrow a b) | |
(Functor (StreamArrow a b), Arrow a) => Applicative (StreamArrow a b) | |
(Applicative (StreamArrow a b), ArrowPlus a) => Alternative (StreamArrow a b) | |
ArrowPlus a => Monoid (StreamArrow a b c) |
runStream :: ArrowLoop a => StreamArrow a (e, b) c -> a (e, Stream b) (Stream c)Source
Run a stream processor on a stream of inputs, obtaining a stream of outputs.
Typical usage in arrow notation:
proc p -> do ... ys <- (|runStream (\x -> ...)|) xs
Here xs
refers to the input stream and x
to individual
elements of that stream. ys
is bound to the output stream.
type StreamMap = StreamArrow (->)Source
Mappings of streams
type StreamMapST s = StreamArrow (Kleisli (ST s))Source
In-place state updates.
Note: this is an arrow type, and lift
can be used to promote arrows
from
: the resulting arrow updates the state for
each stream element in turn, and as long as the final state in not
required all is well. However, Kleisli
(ST
s)lift
does not preserve composition,
because this monad isn't commutative. In particular, a composition
of lift
s of state transformers will not work, as the second will
require the final state of the first.
runStreamST :: (forall s. StreamMapST s e c) -> StreamMap e cSource
Encapsulate a local state.
class (ArrowCircuit a, Arrow a') => ArrowAddStream a a' | a -> a' whereSource
Adding a StreamArrow
to an
arrow type, but not necessarily as the outer arrow transformer.
Typically a composite arrow type is built by applying a series
of arrow transformer to a base arrow (usually either a function
arrow or a Kleisli
arrow. One can add a transformer to the
top of this stack using the lift
method of the ArrowTransformer
class,
or remove a state transformer from the top of the stack using the
runStream
encapsulation operator.
The methods of this class add and remove state transformers anywhere
in the stack. In the instance
instance Arrow a => ArrowAddStream (ArrowStream a) a
they are equivalent to lift
and
runStream
respectively.
Instances are lifted through other transformers with
instance ArrowAddStream a a' => ArrowAddStream (FooArrow a) (FooArrow a')
liftStream :: a' e b -> a e bSource
Lift a computation from an arrow to a stream processing one.
Typical usage in arrow notation:
proc p -> ... (|liftStream cmd|)
elimStream :: a (e, b) c -> a' (e, Stream b) (Stream c)Source
Run a stream processor on a stream of inputs, obtaining a stream of outputs.
Typical usage in arrow notation:
proc p -> do ... ys <- (|elimStream (\x -> ...)|) xs
Here xs
refers to the input stream and x
to individual
elements of that stream. ys
is bound to the output stream.
(ArrowCircuit (Automaton a), Arrow a, ArrowLoop a, ArrowApply a) => ArrowAddStream (Automaton a) a | |
(ArrowCircuit (StreamArrow a), Arrow a, ArrowLoop a) => ArrowAddStream (StreamArrow a) a | |
(ArrowCircuit (StaticArrow f a), Arrow (StaticArrow f a'), ArrowAddStream a a', Applicative f) => ArrowAddStream (StaticArrow f a) (StaticArrow f a') |