netwire-1.0.0: Arrowized FRP implementation

MaintainerErtugrul Soeylemez <es@ertes.de>

FRP.NetWire.Event

Contents

Description

Events.

Synopsis

Producing events

after :: forall a. DTime -> Wire a (Event a)Source

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

afterEach :: forall a b. [(DTime, b)] -> Wire a (Event b)Source

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 :: Wire (Bool, a) (Event a)Source

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

edgeBy :: forall a b. (a -> Bool) -> (a -> b) -> Wire a (Event b)Source

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 :: Wire (Maybe a) (Event a)Source

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

never :: Wire a (Event b)Source

Never produce an event.

now :: b -> Wire a (Event b)Source

Produce an event at the first instant and never again.

once :: Wire (Event a) (Event a)Source

Pass the first event occurence through and suppress all future events.

repeatedly :: forall a. Wire (DTime, a) (Event a)Source

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

repeatedlyList :: forall a. [a] -> Wire DTime (Event a)Source

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

Wire transformers

wait :: Wire (Event a) aSource

Inhibit the signal, unless an event occurs.

Event transformers

Delaying events

dam :: forall a. Wire [a] (Event a)Source

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 :: Wire (DTime, Event a) (Event a)Source

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 :: Wire (DTime, Int, Event a) (Event a)Source

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. Int -> Wire (Event a) (Event a)Source

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

dropFor :: forall a. Wire (DTime, Event a) (Event a)Source

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

notYet :: Wire (Event a) (Event a)Source

Suppress the first event occurence.

takeEvents :: Int -> Wire (Event a) (Event a)Source

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

takeFor :: Wire (DTime, Event a) (Event a)Source

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

Manipulating events

accum :: forall a. a -> Wire (Event (a -> a)) (Event a)Source

This function corresponds to the iterate function for lists. Begins with an initial output value, which is not emitted. Each time an input event is received, its function is applied to the current accumulator and the new value is emitted.

Mapping to continuous signals

hold :: forall a. a -> Wire (Event a) aSource

Turn discrete events into continuous signals. Initially produces the argument value. Each time an event occurs, the produced value is switched to the event's value.

dHold :: forall a. a -> Wire (Event a) aSource

Decoupled variant of hold.