netwire-1.2.4: Arrowized FRP implementation

MaintainerErtugrul Soeylemez <es@ertes.de>

FRP.NetWire.Event

Contents

Description

Event system. None of these wires except event supports feedback, because they all can inhibit.

Synopsis

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, a), (2, b), (3, c)] produces the event a after one second, b after three seconds and c after six seconds.

edge :: Monad m => Wire m (Bool, a) aSource

Produce a single event with the right signal whenever the left signal switches from False to True.

edgeBy :: forall a b m. Monad m => (a -> Bool) -> (a -> b) -> Wire m a bSource

Whenever the predicate in the first argument switches from False to True for the input signal, produce an event carrying the value given by applying the second argument function to the input signal.

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.

once :: Monad m => Wire m a aSource

Produce an event at the first instant and never again.

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.

notYet :: Monad m => Wire m a aSource

Suppress the first event occurence.

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.

Tools

event :: Monad m => Wire m a b -> Wire m a (Maybe b)Source

Variant of exhibit, which produces a Maybe instead of an Either.

Never inhibits. Same feedback properties as argument wire.