machinecell-1.3.1: Arrow based stream transducers

Safe HaskellNone
LanguageHaskell2010

Control.Arrow.Machine.Utils

Contents

Synopsis

AFRP-like utilities

hold :: ArrowApply a => b -> ProcessA a (Event b) b Source

accum :: ArrowApply a => b -> ProcessA a (Event (b -> b)) b Source

edge :: (ArrowApply a, Eq b) => ProcessA a b (Event b) Source

passRecent :: (ArrowApply a, Occasional o) => ProcessA a (AS e) (Event b) -> ProcessA a (e, AS b) o -> ProcessA a (AS e) o infixr 9 Source

Deprecated: Use hold instead

withRecent :: (ArrowApply a, Occasional o) => ProcessA a (e, AS b) o -> ProcessA a (e, AS (Event b)) o Source

Deprecated: Use hold instead

feedback1 :: (ArrowApply a, Occasional d) => ProcessA a (e, AS d) (c, d) -> ProcessA a (AS e) c Source

Deprecated: Use Pump instead

Event version of loop (member of ArrowLoop). Yielding an event to feedback output always creates a new process cycle. So be careful to make an infinite loop.

feedback :: (ArrowApply a, Occasional d) => ProcessA a (e, AS d) b -> ProcessA a (e, AS b) (c, d) -> ProcessA a (AS e) c infixr 9 Source

Deprecated: Use Pump instead

Artificially split into two arrow to use binary operator notation rather than banana brackets.

Switches

Switches inspired by Yampa library. Signature is almost same, but collection requirement is not only Functor, but Traversable. This is because of side effects.

switch :: ArrowApply a => ProcessA a b (c, Event t) -> (t -> ProcessA a b c) -> ProcessA a b c Source

dSwitch :: ArrowApply a => ProcessA a b (c, Event t) -> (t -> ProcessA a b c) -> ProcessA a b c Source

rSwitch :: ArrowApply a => ProcessA a b c -> ProcessA a (b, Event (ProcessA a b c)) c Source

drSwitch :: ArrowApply a => ProcessA a b c -> ProcessA a (b, Event (ProcessA a b c)) c Source

kSwitch :: ArrowApply a => ProcessA a b c -> ProcessA a (b, c) (Event t) -> (ProcessA a b c -> t -> ProcessA a b c) -> ProcessA a b c Source

dkSwitch :: ArrowApply a => ProcessA a b c -> ProcessA a (b, c) (Event t) -> (ProcessA a b c -> t -> ProcessA a b c) -> ProcessA a b c Source

pSwitch :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a (b, col c) (Event mng) -> (col (ProcessA a ext c) -> mng -> ProcessA a b (col c)) -> ProcessA a b (col c) Source

pSwitchB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a (b, col c) (Event mng) -> (col (ProcessA a b c) -> mng -> ProcessA a b (col c)) -> ProcessA a b (col c) Source

rpSwitch :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a (b, Event (col (ProcessA a ext c) -> col (ProcessA a ext c))) (col c) Source

rpSwitchB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a (b, Event (col (ProcessA a b c) -> col (ProcessA a b c))) (col c) Source

State arrow

encloseState :: (ArrowApply a, ArrowAddState s a a') => ProcessA a b c -> s -> ProcessA a' b c Source

Other utility arrows

tee :: ArrowApply a => ProcessA a (Event b1, Event b2) (Event (Either b1 b2)) Source

Make two event streams into one. Actually gather is more general and convenient; ... <- tee -< (e1, e2) is equivalent to ... gather -< [Left <$ e1, Right $ e2]

gather :: (ArrowApply a, Foldable f) => ProcessA a (f (Event b)) (Event b) Source

Make multiple event channels into one. If simultaneous events are given, lefter one is emitted earlier.

sample :: ArrowApply a => ProcessA a (Event b1, Event b2) [b1] Source

source :: (ArrowApply a, Foldable f) => f c -> ProcessA a (Event b) (Event c) Source

Provides a source event stream. A dummy input event stream is needed. run af [...] is equivalent to run (source [...] >>> af) (repeat ())

fork :: (ArrowApply a, Foldable f) => ProcessA a (Event (f b)) (Event b) Source

Given an array-valued event and emit it's values as inidvidual events.

filter :: ArrowApply a => a o Bool -> ProcessA a (Event o) (Event o) Source

anytime :: ArrowApply a => a b c -> ProcessA a (Event b) (Event c) Source

Executes an action once per an input event is provided.

par :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a b (col c) Source

parB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a b (col c) Source

cycleDelay :: ArrowApply a => ProcessA a b b Source

Observe a previous value of a signal. Tipically used with rec statement.