netwire-5.0.3: Functional reactive programming library

Copyright | (c) 2013 Ertugrul Soeylemez
License | BSD3
Maintainer | Ertugrul Soeylemez <es@ertes.de>
Safe Haskell | None
Language | Haskell2010

Control.Wire.Event

Contents

- Events
- Time-based
- Signal analysis
- Modifiers
- Scans
  - Special scans

Description

Synopsis

- data Event a
- at :: forall t s e (m :: Type -> Type) a. HasTime t s => t -> Wire s e m a (Event a)
- never :: forall s e (m :: Type -> Type) a b. Wire s e m a (Event b)
- now :: forall s e (m :: Type -> Type) a. Wire s e m a (Event a)
- periodic :: forall t s e (m :: Type -> Type) a. HasTime t s => t -> Wire s e m a (Event a)
- periodicList :: forall t s b e (m :: Type -> Type) a. HasTime t s => t -> [b] -> Wire s e m a (Event b)
- became :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m a (Event a)
- noLonger :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m a (Event a)
- edge :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m a (Event a)
- (<&) :: forall (m :: Type -> Type) s e a b. Monad m => Wire s e m a (Event b) -> Wire s e m a (Event b) -> Wire s e m a (Event b)
- (&>) :: forall (m :: Type -> Type) s e a b. Monad m => Wire s e m a (Event b) -> Wire s e m a (Event b) -> Wire s e m a (Event b)
- dropE :: forall s e (m :: Type -> Type) a. Int -> Wire s e m (Event a) (Event a)
- dropWhileE :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m (Event a) (Event a)
- filterE :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m (Event a) (Event a)
- merge :: (a -> a -> a) -> Event a -> Event a -> Event a
- mergeL :: Event a -> Event a -> Event a
- mergeR :: Event a -> Event a -> Event a
- notYet :: forall s e (m :: Type -> Type) a. Wire s e m (Event a) (Event a)
- once :: forall s e (m :: Type -> Type) a. Wire s e m (Event a) (Event a)
- takeE :: forall s e (m :: Type -> Type) a. Int -> Wire s e m (Event a) (Event a)
- takeWhileE :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m (Event a) (Event a)
- accumE :: forall b a s e (m :: Type -> Type). (b -> a -> b) -> b -> Wire s e m (Event a) (Event b)
- accum1E :: forall a s e (m :: Type -> Type). (a -> a -> a) -> Wire s e m (Event a) (Event a)
- iterateE :: forall a s e (m :: Type -> Type). a -> Wire s e m (Event (a -> a)) (Event a)
- maximumE :: forall a s e (m :: Type -> Type). Ord a => Wire s e m (Event a) (Event a)
- minimumE :: forall a s e (m :: Type -> Type). Ord a => Wire s e m (Event a) (Event a)
- productE :: forall a s e (m :: Type -> Type). Num a => Wire s e m (Event a) (Event a)
- sumE :: forall a s e (m :: Type -> Type). Num a => Wire s e m (Event a) (Event a)

# Events

data Event a Source #

Denotes a stream of values, each together with time of occurrence. Since `Event` is commonly used for functional reactive programming it does not define most of the usual instances to protect continuous time and discrete event occurrence semantics.

#### Instances

Instances details

Functor Event Source # |
Instance details Defined in Control.Wire.Unsafe.Event Methods fmap :: (a -> b) -> Event a -> Event b Source # (<$) :: a -> Event b -> Event a Source #
NFData a => NFData (Event a) Source # |
Instance details Defined in Control.Wire.Unsafe.Event Methods rnf :: Event a -> () Source #
Semigroup a => Monoid (Event a) Source # |
Instance details Defined in Control.Wire.Unsafe.Event Methods mempty :: Event a Source # mappend :: Event a -> Event a -> Event a Source # mconcat :: [Event a] -> Event a Source #
Semigroup a => Semigroup (Event a) Source # |
Instance details Defined in Control.Wire.Unsafe.Event Methods (<>) :: Event a -> Event a -> Event a Source # sconcat :: NonEmpty (Event a) -> Event a Source # stimes :: Integral b => b -> Event a -> Event a Source #

# Time-based

at Source #

Arguments

:: forall t s e (m :: Type -> Type) a. HasTime t s |
=> t | Time of occurrence.
-> Wire s e m a (Event a) |

At the given point in time.

- Depends: now when occurring.

never :: forall s e (m :: Type -> Type) a b. Wire s e m a (Event b) Source #

Never occurs.

now :: forall s e (m :: Type -> Type) a. Wire s e m a (Event a) Source #

Occurs once immediately.

- Depends: now when occurring.

periodic :: forall t s e (m :: Type -> Type) a. HasTime t s => t -> Wire s e m a (Event a) Source #

Periodic occurrence with the given time period. First occurrence is now.

- Depends: now when occurring.

periodicList :: forall t s b e (m :: Type -> Type) a. HasTime t s => t -> [b] -> Wire s e m a (Event b) Source #

Periodic occurrence with the given time period. First occurrence is now. The event values are picked one by one from the given list. When the list is exhausted, the event does not occur again.

# Signal analysis

became :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m a (Event a) Source #

Occurs each time the predicate becomes true for the input signal, for example each time a given threshold is reached.

- Depends: now.

noLonger :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m a (Event a) Source #

Occurs each time the predicate becomes false for the input signal, for example each time a given threshold is no longer exceeded.

- Depends: now.

edge :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m a (Event a) Source #

Events occur first when the predicate is false then when it is true, and then this pattern repeats.

- Depends: now.

# Modifiers

(<&) :: forall (m :: Type -> Type) s e a b. Monad m => Wire s e m a (Event b) -> Wire s e m a (Event b) -> Wire s e m a (Event b) infixl 5 Source #

Merge events with the leftmost event taking precedence. Equivalent to using the monoid interface with `First`. Infixl 5.

- Depends: now on both.
- Inhibits: when any of the two wires inhibit.

(&>) :: forall (m :: Type -> Type) s e a b. Monad m => Wire s e m a (Event b) -> Wire s e m a (Event b) -> Wire s e m a (Event b) infixl 5 Source #

Merge events with the rightmost event taking precedence. Equivalent to using the monoid interface with `Last`. Infixl 5.

- Depends: now on both.
- Inhibits: when any of the two wires inhibit.

dropE :: forall s e (m :: Type -> Type) a. Int -> Wire s e m (Event a) (Event a) Source #

Forget the first given number of occurrences.

- Depends: now.

dropWhileE :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m (Event a) (Event a) Source #

Forget all initial occurrences until the given predicate becomes false.

- Depends: now.

filterE :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m (Event a) (Event a) Source #

Forget all occurrences for which the given predicate is false.

- Depends: now.

merge :: (a -> a -> a) -> Event a -> Event a -> Event a Source #

Merge two events using the given function when both occur at the same time.

mergeL :: Event a -> Event a -> Event a Source #

Left-biased event merge.

mergeR :: Event a -> Event a -> Event a Source #

Right-biased event merge.

notYet :: forall s e (m :: Type -> Type) a. Wire s e m (Event a) (Event a) Source #

Forget the first occurrence.

- Depends: now.

once :: forall s e (m :: Type -> Type) a. Wire s e m (Event a) (Event a) Source #

Forget all occurrences except the first.

- Depends: now when occurring.

takeE :: forall s e (m :: Type -> Type) a. Int -> Wire s e m (Event a) (Event a) Source #

Forget all but the first given number of occurrences.

- Depends: now.

takeWhileE :: forall a s e (m :: Type -> Type). (a -> Bool) -> Wire s e m (Event a) (Event a) Source #

Forget all but the initial occurrences for which the given predicate is true.

- Depends: now.

# Scans

accumE Source #

Arguments

:: forall b a s e (m :: Type -> Type). (b -> a -> b) | Fold function
-> b | Initial value.
-> Wire s e m (Event a) (Event b) |

Left scan for events. Each time an event occurs, apply the given function.

- Depends: now.

accum1E Source #

Arguments

:: forall a s e (m :: Type -> Type). (a -> a -> a) | Fold function
-> Wire s e m (Event a) (Event a) |

Left scan for events with no initial value. Each time an event occurs, apply the given function. The first event is produced unchanged.

- Depends: now.

iterateE :: forall a s e (m :: Type -> Type). a -> Wire s e m (Event (a -> a)) (Event a) Source #

On each occurrence, apply the function the event carries.

- Depends: now.

## Special scans

maximumE :: forall a s e (m :: Type -> Type). Ord a => Wire s e m (Event a) (Event a) Source #

Maximum of all events.

- Depends: now.

minimumE :: forall a s e (m :: Type -> Type). Ord a => Wire s e m (Event a) (Event a) Source #

Minimum of all events.

- Depends: now.

productE :: forall a s e (m :: Type -> Type). Num a => Wire s e m (Event a) (Event a) Source #

Product of all events.

- Depends: now.

sumE :: forall a s e (m :: Type -> Type). Num a => Wire s e m (Event a) (Event a) Source #

Sum of all events.

- Depends: now.