Animas-0.2: Updated version of Yampa: a library for programming hybrid systems.

Portabilityportable
Stabilityprovisional
Maintainernilsson@cs.yale.edu

FRP.Animas.Event

Description

Definition of Animas Event type and functions on that type.

Synopsis

Documentation

data Event a Source

Event type

Constructors

NoEvent 
Event a 

Instances

Functor Event 
Eq a => Eq (Event a) 
Ord a => Ord (Event a) 
Show a => Show (Event a) 
Forceable a => Forceable (Event a) 

noEvent :: Event aSource

Not an event

noEventFstSource

Arguments

:: (Event a, b)

Input pair

-> (Event c, b)

No event pair

Force the first item of a pair to not be an event

noEventSndSource

Arguments

:: (a, Event b)

Input pair

-> (a, Event c)

No event pair

Force the second item of a pair to not be an event

maybeToEvent :: Maybe a -> Event aSource

Internal: Convert a Maybe value to an event

eventSource

Arguments

:: a

Default value

-> (b -> a)

Function from event value

-> Event b

Event

-> a

Return value

Apply a function to an event, or return a default value

fromEvent :: Event a -> aSource

Extract a value from an event. This function will produce an error if applied to a NoEvent function

isEvent :: Event a -> BoolSource

Predicate: is a value an event occurence

isNoEvent :: Event a -> BoolSource

Predicate: is a value not an event occurence

tagSource

Arguments

:: Event a

Possible event occurence

-> b

Replacement value

-> Event b 

Replace a possible event occurence with a new occurence carrying a replacement value

tagWith :: b -> Event a -> Event bSource

See above

attach :: Event a -> b -> Event (a, b)Source

Pair a value with an event occurrence's value, creating a new event occurrence

lMerge :: Event a -> Event a -> Event aSource

If both inputs are event occurrences, produce the left event.

rMerge :: Event a -> Event a -> Event aSource

If both inputs are event occurences, produce the right event.

merge :: Event a -> Event a -> Event aSource

If both inputs are event occurences, produce an error.

mergeBy :: (a -> a -> a) -> Event a -> Event a -> Event aSource

If both inputs are event occurences, merge them with the supplied function

mapMergeSource

Arguments

:: (a -> c)

Function for occurences in first source

-> (b -> c)

Function for occurences in second source

-> (a -> b -> c)

Function for occurences in both sources

-> Event a

First source

-> Event b

Second source

-> Event c

Merged/mapped events

Apply functions to an event occurences from two sources

mergeEvents :: [Event a] -> Event aSource

Produce the event occurence closest to the head of the list, if one exists.

catEvents :: [Event a] -> Event [a]Source

From a list of event sources produce an event occurence with a list of values of occurrences

joinE :: Event a -> Event b -> Event (a, b)Source

If there is an occurence from both sources, produce an occurence with both values.

splitE :: Event (a, b) -> (Event a, Event b)Source

Create a pair of event occurences from a single event occurence with a pair of values

filterE :: (a -> Bool) -> Event a -> Event aSource

Apply a predicate to event occurences and forward them only if it matches

mapFilterE :: (a -> Maybe b) -> Event a -> Event bSource

Apply a Maybe function to event occurences, producing events only for Just values.

gate :: Event a -> Bool -> Event aSource

Only pass through events if some external condition is true.