Safe Haskell | Safe |
---|---|

Language | Haskell98 |

- type Time = Int
- data Event a
- data Behavior a
- type Moment a = Time -> a
- never :: Event a
- filterJust :: Event (Maybe a) -> Event a
- unionWith :: (a -> a -> a) -> Event a -> Event a -> Event a
- mapE :: (a -> b) -> Event a -> Event b
- accumE :: a -> Event (a -> a) -> Moment (Event a)
- applyE :: Behavior (a -> b) -> Event a -> Event b
- stepperB :: a -> Event a -> Moment (Behavior a)
- pureB :: a -> Behavior a
- applyB :: Behavior (a -> b) -> Behavior a -> Behavior b
- mapB :: (a -> b) -> Behavior a -> Behavior b
- valueB :: Behavior a -> Moment a
- observeE :: Event (Moment a) -> Event a
- switchE :: Event (Event a) -> Event a
- switchB :: Behavior a -> Event (Behavior a) -> Behavior a
- interpret :: (Event a -> Moment (Event b)) -> [Maybe a] -> [Maybe b]

# Synopsis

Model implementation for learning and testing.

# Overview

This module reimplements the key FRP types and functions from the module Reactive.Banana.Combinators in a way that is hopefully easier to understand. Thereby, this model also specifies the semantics of the library. Of course, the real implementation is much more efficient than this model here.

To understand the model in detail, look at the source code! (If there is no link to the source code at every type signature, then you have to run cabal with --hyperlink-source flag.)

This model is *authoritative*: when observed with the `interpretModel`

function,
both the actual implementation and its model *must* agree on the result.
Note that this must also hold for recursive and partial definitions
(at least in spirit, I'm not going to split hairs over `_|_`

vs `\_ -> _|_`

).

# Combinators

## Data types

The FRP model used in this library is actually a model with continuous time.

However, it can be shown that this model is observationally equivalent to a particular model with (seemingly) discrete time steps, which is implemented here. Details will be explained elsewhere.

## Basic

filterJust :: Event (Maybe a) -> Event a Source