Maintainer | Ertugrul Soeylemez <es@ertes.de> |
---|

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.

- switch :: Monad m => Wire m a (b, Maybe c) -> (c -> Wire m a b) -> Wire m a b
- dSwitch :: Monad m => Wire m a (b, Maybe c) -> (c -> Wire m a b) -> Wire m a b
- rSwitch :: Monad m => Wire m a b -> Wire m (a, Maybe (Wire m a b)) b
- drSwitch :: Monad m => Wire m a b -> Wire m (a, Maybe (Wire m a b)) b
- parB :: (Applicative m, Monad m, Traversable f) => f (Wire m a b) -> Wire m a (f b)
- 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)
- 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)
- 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)
- 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)
- 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)

# 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

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