gore-and-ash-1.1.0.1: Core of FRP game engine called Gore&Ash

Copyright(c) 2013 Ertugrul Soeylemez
LicenseBSD3
MaintainerErtugrul Soeylemez <es@ertes.de>
Safe HaskellNone
LanguageHaskell2010

Control.Wire.Event

Contents

Description

 

Synopsis

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.

Time-based

at Source

Arguments

:: 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 :: Wire s e m a (Event b) Source

Never occurs.

now :: Wire s e m a (Event a) Source

Occurs once immediately.

  • Depends: now when occurring.

periodic :: 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 :: 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 :: (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 :: (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 :: (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

(<&) :: 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.

(&>) :: 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 :: Int -> Wire s e m (Event a) (Event a) Source

Forget the first given number of occurrences.

  • Depends: now.

dropWhileE :: (a -> Bool) -> Wire s e m (Event a) (Event a) Source

Forget all initial occurrences until the given predicate becomes false.

  • Depends: now.

filterE :: (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 :: Wire s e m (Event a) (Event a) Source

Forget the first occurrence.

  • Depends: now.

once :: Wire s e m (Event a) (Event a) Source

Forget all occurrences except the first.

  • Depends: now when occurring.

takeE :: Int -> Wire s e m (Event a) (Event a) Source

Forget all but the first given number of occurrences.

  • Depends: now.

takeWhileE :: (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

:: (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

:: (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 :: 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 :: Ord a => Wire s e m (Event a) (Event a) Source

Maximum of all events.

  • Depends: now.

minimumE :: Ord a => Wire s e m (Event a) (Event a) Source

Minimum of all events.

  • Depends: now.

productE :: Num a => Wire s e m (Event a) (Event a) Source

Product of all events.

  • Depends: now.

sumE :: Num a => Wire s e m (Event a) (Event a) Source

Sum of all events.

  • Depends: now.