Moe-0.1: A FRP library based on signal functions.

FRP.Moe.Core

Synopsis

Documentation

newtype SF a b Source

SF a b can be seen as a function from [x1, x2, ...] to [y1, y2, ...], in which

x1, x2, ... have the type of a, and y1, y2, ... have the type of b. Notice that

each value is in fact a sample of a continuous temporal function of values in

some certain time. The time stamps are omitted in most of the comments.

Constructors

MkSF 

Fields

runSF :: DTime -> a -> (b, SF a b)
 

Instances

Arrow SF 
ArrowChoice SF 
ArrowLoop SF 
Category SF

second, (&&&) and (***) are not necessary. They exist only for optimization

ArrowDelay SF

right, (|||) and (+++) are not necessary. They exist only for optimization

Functor (SF a) 
Applicative (SF a) 
Monoid b => Monoid (SF a b) 

sfId :: SF a aSource

Input: [x1, x2, ...]

Output: [x1, x2, ...]

sfArr :: (a -> b) -> SF a bSource

Input: [x1, x2, ...]

Output: [f x1, f x2, ...]

sfComp :: SF b c -> SF a b -> SF a cSource

Input of sf1: [y1, y2, ...]

Output of sf1: [z1, z2, ...]

Input of sf2: [x1, x2, ...]

Output of sf2: [y1, y2, ...]

Input: [x1, x2, ...]

Output: [z1, z2, ...]

sfLoop :: SF (a, c) (b, c) -> SF a bSource

Returns a signal function that:

Input: [x1, x2, ...]

Output: [y1, y2, ...]

whenever the following property holds for sf:

Input of sf: [(x1, z1), (x2, z2), ...]

Output of sf: [(y1, z1), (y2, z2), ...]

sfFirst :: SF a b -> SF (a, c) (b, c)Source

Input of sf: [x1, x2, ...]

Output of sf: [y1, y2, ...]

Input: [(x1, z1), (x2, z2), ...]

Output: [(y1, z1), (y2, z2), ...]

sfSecond :: SF a b -> SF (c, a) (c, b)Source

Input of sf: [x1, x2, ...]

Output of sf: [y1, y2, ...]

Input: [(z1, x1), (z2, x2), ...]

Output: [(z1, y1), (z2, y2), ...]

sfLeft :: SF a b -> SF (Either a c) (Either b c)Source

Input of sf: [x1, x2, ...]

Output of sf: [y1, y2, ...]

Input: [Left x1, Right z1, Left x2, ...]

Output: [Left y1, Right z1, Left y2, ...]

sfRight :: SF a b -> SF (Either c a) (Either c b)Source

Input of sf: [x1, x2, ...]

Output of sf: [y1, y2, ...]

Input: [Right x1, Left z1, Right x2, ...]

Output: [Right y1, Left z2, Right y2, ...]

sfDelay :: a -> SF a aSource

Input of sf: [x1, x2, ...]

Output of sf: [x0, x1, x2, ...]

dTime :: SF () DTimeSource

Input of sf: [x1, x2, ...]

Output of sf: [dt1, dt2, ...] (dt_i is the time interval between x_(i-1) and x_i)

class Arrow a => ArrowDelay a whereSource

Methods

delay :: b -> a b bSource

Instances

ArrowDelay SF

right, (|||) and (+++) are not necessary. They exist only for optimization

data Event a Source

Constructors

Event a 
NoEvent 

switch :: SF b (c, Event d) -> (d -> SF b c) -> SF b cSource

Input of sf: [x1, x2, x3, ...]

Output of sf: [(y1, NoEvent), (y2, Event e1), (y3, NoEvent), ...]

Input of (gen e): [x2, x3, ...]

Output of (gen e): [y(e1)1, y(e1)2, ...]

Input: [x1, x2, x3, ...]

Output: [y1, y(e1)1, y(e1)2, ...]

dswitch :: SF b (c, Event d) -> (d -> SF b c) -> SF b cSource

Input of sf: [x1, x2, x3, ...]

Output of sf: [(y1, NoEvent), (y2, Event e1), (y3, NoEvent), ...]

Input of (gen e): [x2, x3, ...]

Output of (gen e): [y(e1)1, y(e1)2, ...]

Input: [x1, x2, x3, ...]

Output: [y1, y2, y(e1)2, ...]

kswitch :: SF a b -> SF (a, b) (Event c) -> (SF a b -> c -> SF a b) -> SF a bSource

Input of sf: [x1, x2, x3, ...]

Output of sf: [y1, y2, y3, ...]

Input of sfe: [(x1, y1), (x2, y2), (x3, y3), ...]

Output of sfe: [NoEvent, Event e1, NoEvent, ...]

Input of (gen sf3 e1): [x2, x3, ...]

Output of (gen sf3 e1): [y(sf3,e1)1, y(sf3,e1)2, ...]

Input: [x1, x2, x3, ...]

Output: [y1, y(sf3,e1)1, y(sf3,e2)2, ...]

where sf1 = [x1, x2, x3, ...] -- ^> [y1, y2, y3, ...]

sf2 = [x2, x3, ...] -- ^> [y2, y3, ...]

sf3 = [x3, ...] -- ^> [y3, ...]

...

dkswitch :: SF a b -> SF (a, b) (Event c) -> (SF a b -> c -> SF a b) -> SF a bSource

Input of sf: [x1, x2, x3, ...]

Output of sf: [y1, y2, y3, ...]

Input of sfe: [(x1, y1), (x2, y2), (x3, y3), ...]

Output of sfe: [NoEvent, Event e1, NoEvent, ...]

Input of (gen sf3 e1): [x2, x3, ...]

Output of (gen sf3 e1): [y(sf3,e1)1, y(sf3,e1)2, ...]

Input: [x1, x2, x3, ...]

Output: [y1, y2, y(sf3,e2)2, ...]

where sf1 = [x1, x2, x3, ...] -- ^> [y1, y2, y3, ...]

sf2 = [x2, x3, ...] -- ^> [y2, y3, ...]

sf3 = [x3, ...] -- ^> [y3, ...]

...

pswitch :: Functor col => (forall sf. a -> col sf -> col (b, sf)) -> col (SF b c) -> SF (a, col c) (Event d) -> (col (SF b c) -> d -> SF a (col c)) -> SF a (col c)Source

dpswitch :: Functor col => (forall sf. a -> col sf -> col (b, sf)) -> col (SF b c) -> SF (a, col c) (Event d) -> (col (SF b c) -> d -> SF a (col c)) -> SF a (col c)Source

nth :: Int -> DTime -> SF () a -> aSource

Get the element (x_n) the output [y1, y2, ...] of sf.

Time interval is fixed to (dt).

gen :: SF a b -> [(DTime, a)] -> [b]Source

Turn sf into a stream function.