arrows-0.4.4.2: Arrow classes and transformers
Copyright(c) Ross Paterson 2003
LicenseBSD-style (see the LICENSE file in the distribution)
MaintainerR.Paterson@city.ac.uk
Stabilityexperimental
Portabilitynon-portable (multi-parameter type classes)
Safe HaskellSafe-Inferred
LanguageHaskell98

Control.Arrow.Transformer.Stream

Description

Arrow transformer lifting an arrow to streams.

Synopsis

Documentation

newtype StreamArrow a b c Source #

Arrows between streams.

Note: lift is only a functor if *** in the underlying arrow is.

Constructors

StreamArrow (a (Stream b) (Stream c)) 

Instances

Instances details
Arrow a => ArrowTransformer StreamArrow a Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

lift :: a b c -> StreamArrow a b c Source #

ArrowWriter w a => ArrowWriter w (StreamArrow a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

write :: StreamArrow a w () Source #

newWriter :: StreamArrow a e b -> StreamArrow a e (b, w) Source #

ArrowState s a => ArrowState s (StreamArrow a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

fetch :: StreamArrow a e s Source #

store :: StreamArrow a s () Source #

Arrow a => Arrow (StreamArrow a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

arr :: (b -> c) -> StreamArrow a b c #

first :: StreamArrow a b c -> StreamArrow a (b, d) (c, d) #

second :: StreamArrow a b c -> StreamArrow a (d, b) (d, c) #

(***) :: StreamArrow a b c -> StreamArrow a b' c' -> StreamArrow a (b, b') (c, c') #

(&&&) :: StreamArrow a b c -> StreamArrow a b c' -> StreamArrow a b (c, c') #

ArrowZero a => ArrowZero (StreamArrow a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

zeroArrow :: StreamArrow a b c #

ArrowPlus a => ArrowPlus (StreamArrow a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

(<+>) :: StreamArrow a b c -> StreamArrow a b c -> StreamArrow a b c #

Arrow a => ArrowChoice (StreamArrow a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

left :: StreamArrow a b c -> StreamArrow a (Either b d) (Either c d) #

right :: StreamArrow a b c -> StreamArrow a (Either d b) (Either d c) #

(+++) :: StreamArrow a b c -> StreamArrow a b' c' -> StreamArrow a (Either b b') (Either c c') #

(|||) :: StreamArrow a b d -> StreamArrow a c d -> StreamArrow a (Either b c) d #

ArrowLoop a => ArrowLoop (StreamArrow a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

loop :: StreamArrow a (b, d) (c, d) -> StreamArrow a b c #

ArrowLoop a => ArrowCircuit (StreamArrow a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

delay :: b -> StreamArrow a b b Source #

ArrowLoop a => ArrowAddStream (StreamArrow a) a Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

liftStream :: a e b -> StreamArrow a e b Source #

elimStream :: StreamArrow a (e, b) c -> a (e, Stream b) (Stream c) Source #

Category a => Category (StreamArrow a :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

id :: forall (a0 :: k). StreamArrow a a0 a0 #

(.) :: forall (b :: k) (c :: k) (a0 :: k). StreamArrow a b c -> StreamArrow a a0 b -> StreamArrow a a0 c #

Arrow a => Functor (StreamArrow a b) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

fmap :: (a0 -> b0) -> StreamArrow a b a0 -> StreamArrow a b b0 #

(<$) :: a0 -> StreamArrow a b b0 -> StreamArrow a b a0 #

Arrow a => Applicative (StreamArrow a b) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

pure :: a0 -> StreamArrow a b a0 #

(<*>) :: StreamArrow a b (a0 -> b0) -> StreamArrow a b a0 -> StreamArrow a b b0 #

liftA2 :: (a0 -> b0 -> c) -> StreamArrow a b a0 -> StreamArrow a b b0 -> StreamArrow a b c #

(*>) :: StreamArrow a b a0 -> StreamArrow a b b0 -> StreamArrow a b b0 #

(<*) :: StreamArrow a b a0 -> StreamArrow a b b0 -> StreamArrow a b a0 #

ArrowPlus a => Alternative (StreamArrow a b) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

empty :: StreamArrow a b a0 #

(<|>) :: StreamArrow a b a0 -> StreamArrow a b a0 -> StreamArrow a b a0 #

some :: StreamArrow a b a0 -> StreamArrow a b [a0] #

many :: StreamArrow a b a0 -> StreamArrow a b [a0] #

ArrowPlus a => Semigroup (StreamArrow a b c) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

(<>) :: StreamArrow a b c -> StreamArrow a b c -> StreamArrow a b c #

sconcat :: NonEmpty (StreamArrow a b c) -> StreamArrow a b c #

stimes :: Integral b0 => b0 -> StreamArrow a b c -> StreamArrow a b c #

ArrowPlus a => Monoid (StreamArrow a b c) Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

mempty :: StreamArrow a b c #

mappend :: StreamArrow a b c -> StreamArrow a b c -> StreamArrow a b c #

mconcat :: [StreamArrow a b c] -> 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 Kleisli (ST s): 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, lift does not preserve composition, because this monad isn't commutative. In particular, a composition of lifts 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 c Source #

Encapsulate a local state.

class (ArrowCircuit a, Arrow a') => ArrowAddStream a a' | a -> a' where Source #

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')

Methods

liftStream :: a' e b -> a e b Source #

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.

Instances

Instances details
(ArrowLoop a, ArrowApply a) => ArrowAddStream (Automaton a) a Source # 
Instance details

Defined in Control.Arrow.Transformer.Automaton

Methods

liftStream :: a e b -> Automaton a e b Source #

elimStream :: Automaton a (e, b) c -> a (e, Stream b) (Stream c) Source #

ArrowLoop a => ArrowAddStream (StreamArrow a) a Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

liftStream :: a e b -> StreamArrow a e b Source #

elimStream :: StreamArrow a (e, b) c -> a (e, Stream b) (Stream c) Source #

(ArrowAddStream a a', Applicative f) => ArrowAddStream (StaticArrow f a) (StaticArrow f a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Static

Methods

liftStream :: StaticArrow f a' e b -> StaticArrow f a e b Source #

elimStream :: StaticArrow f a (e, b) c -> StaticArrow f a' (e, Stream b) (Stream c) Source #