netwire-1.1.0: Arrowized FRP implementation

MaintainerErtugrul Soeylemez <es@ertes.de>

FRP.NetWire.Tools

Contents

Description

The usual FRP tools you'll want to work with.

Synopsis

Basic utilities

constant :: b -> Wire m a bSource

The constant wire. Please use this function instead of arr (const c).

identity :: Monad m => Wire m a aSource

Identity signal transformer. Outputs its input.

Time

time :: Monad m => Wire m a TimeSource

Get the local time.

timeFrom :: Monad m => Time -> Wire m a TimeSource

Get the local time, assuming it starts from the given value.

Signal transformers

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

Turn a continuous signal into a discrete one. This transformer picks values from the right signal at intervals of the left signal.

The interval length is followed in real time. If it's zero, then this wire acts like second id.

keep :: Monad m => Wire m a aSource

Keep the value in the first instant forever.

Inhibitors

inhibit :: (Exception e, Monad m) => Wire m e bSource

Unconditional inhibition with the given inhibition exception.

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

Inhibit right signal, when the left signal is false.

Wire transformers

exhibit :: Monad m => Wire m a b -> Wire m a (Output b)Source

This function corresponds to try for exceptions, allowing you to observe inhibited signals.

freeze :: Monad m => Wire m a b -> Wire m a bSource

Effectively prevent a wire from rewiring itself. This function will turn any stateful wire into a stateless wire, rendering most wires useless.

Note: This function should not be used normally. Use it only, if you know exactly what you're doing.

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

Sample the given wire at specific intervals. Use this instead of discrete, if you want to prevent the signal from passing through the wire all the time.

The left signal interval is allowed to become zero, at which point the signal is passed through the wire at every instant.

swallow :: Monad m => Wire m a b -> Wire m a bSource

Wait for the first signal from the given wire and keep it forever.

(-->) :: Monad m => b -> Wire m a b -> Wire m a bSource

Override the output value at the first non-inhibited instant.

(>--) :: Monad m => a -> Wire m a b -> Wire m a bSource

Override the input value, until the wire starts producing.

(-=>) :: Monad m => (b -> b) -> Wire m a b -> Wire m a bSource

Apply a function to the wire's output at the first non-inhibited instant.

(>=-) :: Monad m => (a -> a) -> Wire m a b -> Wire m a bSource

Apply a function to the wire's input, until the wire starts producing.

Switches

Unconditional switches

constantAfter :: Monad m => b -> b -> Wire m a bSource

Produce the value of the second argument at the first instant. Then produce the second value forever.

initially :: Monad m => a -> Wire m a aSource

Produce the argument value at the first instant. Then act as the identity signal transformer forever.

Arrow tools

mapA :: ArrowChoice a => a b c -> a [b] [c]Source

Apply an arrow to a list of inputs.

Convenience functions

dup :: a -> (a, a)Source

Duplicate a value to a tuple.

fmod :: Double -> Double -> DoubleSource

Floating point modulo operation. Note that fmod n 0 = 0.

swap :: (a, b) -> (b, a)Source

Swap the values in a tuple.