reactive-banana- Library for functional reactive programming (FRP).

Safe HaskellSafe





Model implementation for learning and testing.


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 \_ -> _|_).


Data types

type Time = Int Source

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.

data Event a Source


Show a => Show (Event a) Source 

data Behavior a Source


type Moment a = Time -> a Source


unionWith :: (a -> a -> a) -> Event a -> Event a -> Event a Source

mapE :: (a -> b) -> Event a -> Event b Source

accumE :: a -> Event (a -> a) -> Moment (Event a) Source

applyE :: Behavior (a -> b) -> Event a -> Event b Source

applyB :: Behavior (a -> b) -> Behavior a -> Behavior b Source

mapB :: (a -> b) -> Behavior a -> Behavior b Source

Dynamic event switching


interpret :: (Event a -> Moment (Event b)) -> [Maybe a] -> [Maybe b] Source