
Haskell High Performance Programming
By :

Yampa is an FRP framework that supports both continuous and discrete time. In Yampa, the most important concept is the signal function (SF). Signal functions are first-class transformations on signals, that is, time-dependent values:
data SF a b -- think: Signal a → Signal b -- instance Arrow, ArrowLoop, Category
Signal functions can be created and manipulated via the Arrow interface. For instance, a pure transformation (a → b
) is turned into a signal function simply with arr
from the Arrow
class. Here's a signal function which squares values passed through it:
square :: SF Double Double square = arr (^2)
The embed
utility function can be used to test signal functions:
embed square (1, [(0, Just 2), (1, Just 3)]) [1.0,4.0,9.0]
The type signature of embed looks like this:
embed :: SF a b -> (a, [(DTime, Maybe a)]) -> [b]
The first argument is the signal function to sample from. The second is a tuple that consists of the initial input...