Maintainer | Ertugrul Soeylemez <es@ertes.de> |
---|
Events.
- after :: Monad m => Time -> Wire m a (Event a)
- afterEach :: forall a b m. Monad m => [(Time, b)] -> Wire m a (Event b)
- edge :: Monad m => Wire m (Bool, a) (Event a)
- edgeBy :: forall a b m. Monad m => (a -> Bool) -> (a -> b) -> Wire m a (Event b)
- edgeJust :: Monad m => Wire m (Maybe a) (Event a)
- never :: Monad m => Wire m a (Event b)
- now :: Monad m => b -> Wire m a (Event b)
- once :: Monad m => Wire m (Event a) (Event a)
- repeatedly :: forall a m. Monad m => Wire m (Time, a) (Event a)
- repeatedlyList :: forall a m. Monad m => [a] -> Wire m Time (Event a)
- wait :: Monad m => Wire m (Event a) a
- dam :: forall a m. Monad m => Wire m [a] (Event a)
- delayEvents :: forall a m. Monad m => Wire m (Time, Event a) (Event a)
- delayEventsSafe :: forall a m. Monad m => Wire m (Time, Int, Event a) (Event a)
- dropEvents :: forall a m. Monad m => Int -> Wire m (Event a) (Event a)
- dropFor :: forall a m. Monad m => Wire m (Time, Event a) (Event a)
- notYet :: Monad m => Wire m (Event a) (Event a)
- takeEvents :: forall a m. Monad m => Int -> Wire m (Event a) (Event a)
- takeFor :: forall a m. Monad m => Wire m (Time, Event a) (Event a)
- accum :: forall a m. Monad m => a -> Wire m (Event (a -> a)) (Event a)
- hold :: forall a m. Monad m => a -> Wire m (Event a) a
- dHold :: forall a m. Monad m => a -> Wire m (Event a) a
Producing events
after :: Monad m => Time -> Wire m 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 m. Monad m => [(Time, b)] -> Wire m 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,
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) (Event a)Source
Produce a single event carrying the value of the input signal,
whenever the input signal switches to Just
.
now :: Monad m => b -> Wire m a (Event b)Source
Produce an event at the first instant and never again.
once :: Monad m => Wire m (Event a) (Event a)Source
Pass the first event occurence through and suppress all future events.
repeatedly :: forall a m. Monad m => Wire m (Time, a) (Event a)Source
Emit the right signal event each time the left signal interval passes.
repeatedlyList :: forall a m. Monad m => [a] -> Wire m Time (Event a)Source
Each time the signal interval passes emit the next element from the given list.
Wire transformers
Event transformers
Delaying events
dam :: forall a m. Monad m => Wire m [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 :: forall a m. Monad m => Wire m (Time, 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 :: forall a m. Monad m => Wire m (Time, 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 m. Monad m => Int -> Wire m (Event a) (Event a)Source
Drop the given number of events, before passing events through.
dropFor :: forall a m. Monad m => Wire m (Time, 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.
takeEvents :: forall a m. Monad m => Int -> Wire m (Event a) (Event a)Source
Pass only the first given number of events. Then suppress events forever.
takeFor :: forall a m. Monad m => Wire m (Time, 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 m. Monad m => a -> Wire m (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.