Portability | portable |
---|---|

Stability | provisional |

Maintainer | nilsson@cs.yale.edu |

Definition of Animas Event type and functions on that type.

- data Event a
- noEvent :: Event a
- noEventFst :: (Event a, b) -> (Event c, b)
- noEventSnd :: (a, Event b) -> (a, Event c)
- maybeToEvent :: Maybe a -> Event a
- event :: a -> (b -> a) -> Event b -> a
- fromEvent :: Event a -> a
- isEvent :: Event a -> Bool
- isNoEvent :: Event a -> Bool
- tag :: Event a -> b -> Event b
- tagWith :: b -> Event a -> Event b
- attach :: Event a -> b -> Event (a, b)
- lMerge :: Event a -> Event a -> Event a
- rMerge :: Event a -> Event a -> Event a
- merge :: Event a -> Event a -> Event a
- mergeBy :: (a -> a -> a) -> Event a -> Event a -> Event a
- mapMerge :: (a -> c) -> (b -> c) -> (a -> b -> c) -> Event a -> Event b -> Event c
- mergeEvents :: [Event a] -> Event a
- catEvents :: [Event a] -> Event [a]
- joinE :: Event a -> Event b -> Event (a, b)
- splitE :: Event (a, b) -> (Event a, Event b)
- filterE :: (a -> Bool) -> Event a -> Event a
- mapFilterE :: (a -> Maybe b) -> Event a -> Event b
- gate :: Event a -> Bool -> Event a

# Documentation

Event type

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

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

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

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

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.

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

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

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