netwire-1.2.6: Arrowized FRP implementation

MaintainerErtugrul Soeylemez <es@ertes.de>

FRP.NetWire.Switch

Contents

Description

Switching combinators. Note that Wire also provides a state-preserving Control.Arrow.ArrowApply instance, which may be more convenient than these combinators in many cases.

Synopsis

Basic switches

switch :: Monad m => Wire m a (b, Maybe c) -> (c -> Wire m a b) -> Wire m a bSource

This is the most basic switching combinator. It is an event-based one-time switch.

The first argument is the initial wire, which may produce a switching event at some point. When this event is produced, then the signal path switches to the wire produced by the second argument function.

dSwitch :: Monad m => Wire m a (b, Maybe c) -> (c -> Wire m a b) -> Wire m a bSource

Decoupled variant of switch.

rSwitch :: Monad m => Wire m a b -> Wire m (a, Maybe (Wire m a b)) bSource

Combinator for recurrent switches. The wire produced by this switch takes switching events and switches to the wires contained in the events. The first argument is the initial wire.

drSwitch :: Monad m => Wire m a b -> Wire m (a, Maybe (Wire m a b)) bSource

Decoupled variant of rSwitch.

Broadcasters

parB :: (Applicative m, Monad m, Traversable f) => f (Wire m a b) -> Wire m a (f b)Source

Broadcast signal to a collection of signal functions. If any of the wires inhibits, then the whole parallel network inhibits.

rpSwitchB :: (Applicative m, Monad m, Traversable f) => f (Wire m a b) -> Wire m (a, Maybe (f (Wire m a b) -> f (Wire m a b))) (f b)Source

Recurrent parallel broadcast switch. This combinator acts like parB, but takes an additional event signal, which can transform the set of wires.

Just like parB if any of the wires inhibits, the whole network inhibits.

drpSwitchB :: (Applicative m, Monad m, Traversable f) => f (Wire m a b) -> Wire m (a, Maybe (f (Wire m a b) -> f (Wire m a b))) (f b)Source

Decoupled variant of rpSwitchB.

Routers

par :: (Applicative m, Monad m, Traversable f) => (forall w. a -> f w -> f (b, w)) -> f (Wire m b c) -> Wire m a (f c)Source

Route signal to a collection of signal functions using the supplied routing function. If any of the wires inhibits, the whole network inhibits.

rpSwitch :: (Applicative m, Monad m, Traversable f) => (forall w. a -> f w -> f (b, w)) -> f (Wire m b c) -> Wire m (a, Maybe (f (Wire m b c) -> f (Wire m b c))) (f c)Source

Recurrent parallel routing switch. This combinator acts like par, but takes an additional event signal, which can transform the set of wires. This is the most powerful switch.

Just like par if any of the wires inhibits, the whole network inhibits.

drpSwitch :: (Applicative m, Monad m, Traversable f) => (forall w. a -> f w -> f (b, w)) -> f (Wire m b c) -> Wire m (a, Maybe (f (Wire m b c) -> f (Wire m b c))) (f c)Source

Decoupled variant of rpSwitch.