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

Event system. None of these wires except `event`

supports feedback,
because they all can inhibit.

- after :: Monad m => Time -> Wire m a a
- afterEach :: forall a b m. Monad m => [(Time, b)] -> Wire m a b
- edge :: Monad m => Wire m (Bool, a) a
- edgeBy :: forall a b m. Monad m => (a -> Bool) -> (a -> b) -> Wire m a b
- edgeJust :: Monad m => Wire m (Maybe a) a
- never :: Monad m => Wire m a b
- once :: Monad m => Wire m a a
- periodically :: forall m. Monad m => Wire m Time ()
- repeatedly :: forall a m. Monad m => Wire m (Time, a) a
- repeatedlyList :: forall a m. Monad m => [a] -> Wire m Time a
- dam :: forall a m. Monad m => Wire m [a] a
- delayEvents :: forall a m. Monad m => Wire m (Time, Maybe a) a
- delayEventsSafe :: forall a m. Monad m => Wire m (Time, Int, Maybe a) a
- dropEvents :: forall a m. Monad m => Int -> Wire m a a
- dropFor :: forall a m. Monad m => Wire m (Time, a) a
- notYet :: Monad m => Wire m a a
- takeEvents :: forall a m. Monad m => Int -> Wire m a a
- takeFor :: forall a m. Monad m => Wire m (Time, a) a
- event :: Monad m => Wire m a b -> Wire m a (Maybe b)

# Producing events

after :: Monad m => Time -> Wire m a aSource

Produce a signal once after the specified delay and never again. The event's value will be the input signal at that point.

afterEach :: forall a b m. Monad m => [(Time, b)] -> Wire m a bSource

Produce an event according to the given list of time deltas and
event values. The time deltas are relative to each other, hence from
the perspective of switching in `[(1, `

produces the event `a`

), (2, `b`

), (3, `c`

)]

after one second, `a`

after three seconds
and `b`

after six seconds.
`c`

edgeJust :: Monad m => Wire m (Maybe a) aSource

Produce a single event carrying the value of the input signal,
whenever the input signal switches to `Just`

.

never :: Monad m => Wire m a bSource

Never produce an event. This is equivalent to `inhibit`

, but with
a contextually more appropriate exception message.

periodically :: forall m. Monad m => Wire m Time ()Source

Emits a '()' signal each time the signal interval passes. This is
a simpler variant of `repeatedly`

.

repeatedly :: forall a m. Monad m => Wire m (Time, a) aSource

Emit the right signal event each time the left signal interval passes.

repeatedlyList :: forall a m. Monad m => [a] -> Wire m Time aSource

Each time the signal interval passes emit the next element from the given list.

# Event transformers

## Delaying events

dam :: forall a m. Monad m => Wire m [a] aSource

Event dam. Collects all values from the input list and emits one value at each instant.

Note that this combinator can cause event congestion. If you feed values faster than it can produce, it will leak memory.

delayEvents :: forall a m. Monad m => Wire m (Time, Maybe a) aSource

Delay events by the time interval in the left signal.

Note that this event transformer has to keep all delayed events in
memory, which can cause event congestion. If events are fed in
faster than they can be produced (for example when the framerate
starts to drop), it will leak memory. Use `delayEventSafe`

to
prevent this.

delayEventsSafe :: forall a m. Monad m => Wire m (Time, Int, Maybe a) aSource

Delay events by the time interval in the left signal. The event queue is limited to the maximum number of events given by middle signal. If the current queue grows to this size, then temporarily no further events are queued.

As suggested by the type, this maximum can change over time. However, if it's decreased below the number of currently queued events, the events are not deleted.

## Selecting events

dropEvents :: forall a m. Monad m => Int -> Wire m a aSource

Drop the given number of events, before passing events through.

dropFor :: forall a m. Monad m => Wire m (Time, a) aSource

Timed event gate for the right signal, which begins closed and opens after the time interval in the left signal has passed.

takeEvents :: forall a m. Monad m => Int -> Wire m a aSource

Pass only the first given number of events. Then suppress events forever.

takeFor :: forall a m. Monad m => Wire m (Time, a) aSource

Timed event gate for the right signal, which starts open and slams shut after the left signal time interval passed.