rhine-0.5.1.0: Functional Reactive Programming with type-level clocks

Safe HaskellNone
LanguageHaskell2010

FRP.Rhine.Schedule

Contents

Description

Schedules are the compatibility mechanism between two different clocks. A schedule' implements the the universal clocks such that those two given clocks are its subclocks.

This module defines the Schedule type and certain general constructions of schedules, such as lifting along monad morphisms or time domain morphisms. It also supplies (sequential and parallel) compositions of clocks.

Specific implementations of schedules are found in submodules.

Synopsis

The schedule type

data Schedule m cl1 cl2 Source #

A schedule implements a combination of two clocks. It outputs a time stamp and an Either value, which specifies which of the two subclocks has ticked.

Constructors

Time cl1 ~ Time cl2 => Schedule 

Fields

Utilities to create new schedules from existing ones

hoistSchedule :: (Monad m1, Monad m2) => (forall a. m1 a -> m2 a) -> Schedule m1 cl1 cl2 -> Schedule m2 cl1 cl2 Source #

Lift a schedule along a monad morphism.

flipSchedule :: Monad m => Schedule m cl1 cl2 -> Schedule m cl2 cl1 Source #

Swaps the clocks for a given schedule.

rescaledSchedule :: Monad m => Schedule m cl1 cl2 -> Schedule m (RescaledClock cl1 time) (RescaledClock cl2 time) Source #

If a schedule works for two clocks, a rescaling of the clocks also applies to the schedule.

rescaledScheduleS :: Monad m => Schedule m cl1 cl2 -> Schedule m (RescaledClockS m cl1 time tag1) (RescaledClockS m cl2 time tag2) Source #

As rescaledSchedule, with a stateful rescaling

readerSchedule :: (Monad m, Clock (ReaderT r m) cl1, Clock (ReaderT r m) cl2, Time cl1 ~ Time cl2) => Schedule m (HoistClock (ReaderT r m) m cl1) (HoistClock (ReaderT r m) m cl2) -> Schedule (ReaderT r m) cl1 cl2 Source #

Lifts a schedule into the ReaderT transformer, supplying the same environment to its scheduled clocks.

Composite clocks

Sequentially combined clocks

data SequentialClock m cl1 cl2 Source #

Two clocks can be combined with a schedule as a clock for an asynchronous sequential composition of signal networks.

Constructors

Time cl1 ~ Time cl2 => SequentialClock 

Fields

Instances
(Monad m, Clock m cl1, Clock m cl2) => Clock m (SequentialClock m cl1 cl2) Source # 
Instance details

Defined in FRP.Rhine.Schedule

Associated Types

type Time (SequentialClock m cl1 cl2) :: Type Source #

type Tag (SequentialClock m cl1 cl2) :: Type Source #

Methods

initClock :: SequentialClock m cl1 cl2 -> RunningClockInit m (Time (SequentialClock m cl1 cl2)) (Tag (SequentialClock m cl1 cl2)) Source #

type Time (SequentialClock m cl1 cl2) Source # 
Instance details

Defined in FRP.Rhine.Schedule

type Time (SequentialClock m cl1 cl2) = Time cl1
type Tag (SequentialClock m cl1 cl2) Source # 
Instance details

Defined in FRP.Rhine.Schedule

type Tag (SequentialClock m cl1 cl2) = Either (Tag cl1) (Tag cl2)

type SeqClock m cl1 cl2 = SequentialClock m cl1 cl2 Source #

Abbrevation synonym.

schedSeq1 :: (Monad m, Semigroup cl1) => Schedule m cl1 (SequentialClock m cl1 cl2) Source #

cl1 is a subclock of SequentialClock m cl1 cl2, therefore it is always possible to schedule these two clocks deterministically. The left subclock of the combined clock always ticks instantly after cl1.

schedSeq2 :: (Monad m, Semigroup cl2, Time cl1 ~ Time cl2) => Schedule m (SequentialClock m cl1 cl2) cl2 Source #

As schedSeq1, but for the right subclock. The right subclock of the combined clock always ticks instantly before cl2.

Parallelly combined clocks

data ParallelClock m cl1 cl2 Source #

Two clocks can be combined with a schedule as a clock for an asynchronous parallel composition of signal networks.

Constructors

Time cl1 ~ Time cl2 => ParallelClock 

Fields

Instances
(Monad m, Clock m cl1, Clock m cl2) => Clock m (ParallelClock m cl1 cl2) Source # 
Instance details

Defined in FRP.Rhine.Schedule

Associated Types

type Time (ParallelClock m cl1 cl2) :: Type Source #

type Tag (ParallelClock m cl1 cl2) :: Type Source #

Methods

initClock :: ParallelClock m cl1 cl2 -> RunningClockInit m (Time (ParallelClock m cl1 cl2)) (Tag (ParallelClock m cl1 cl2)) Source #

type Time (ParallelClock m cl1 cl2) Source # 
Instance details

Defined in FRP.Rhine.Schedule

type Time (ParallelClock m cl1 cl2) = Time cl1
type Tag (ParallelClock m cl1 cl2) Source # 
Instance details

Defined in FRP.Rhine.Schedule

type Tag (ParallelClock m cl1 cl2) = Either (Tag cl1) (Tag cl2)

type ParClock m cl1 cl2 = ParallelClock m cl1 cl2 Source #

Abbrevation synonym.

schedPar1 :: (Monad m, Semigroup cl1) => Schedule m cl1 (ParallelClock m cl1 cl2) Source #

Like schedSeq1, but for parallel clocks. The left subclock of the combined clock always ticks instantly after cl1.

schedPar1' :: (Monad m, Semigroup cl1) => Schedule m cl1 (ParallelClock m cl1 cl2) Source #

Like schedPar1, but the left subclock of the combined clock always ticks instantly before cl1.

schedPar2 :: (Monad m, Semigroup cl2, Time cl1 ~ Time cl2) => Schedule m (ParallelClock m cl1 cl2) cl2 Source #

Like schedPar1, but for the right subclock. The right subclock of the combined clock always ticks instantly before cl2.

schedPar2' :: (Monad m, Semigroup cl2, Time cl1 ~ Time cl2) => Schedule m (ParallelClock m cl1 cl2) cl2 Source #

Like schedPar1, but the right subclock of the combined clock always ticks instantly after cl2.

Navigating the clock tree

type family In cl where ... Source #

The clock that represents the rate at which data enters the system.

Equations

In (SequentialClock m cl1 cl2) = In cl1 
In (ParallelClock m cl1 cl2) = ParallelClock m (In cl1) (In cl2) 
In cl = cl 

type family Out cl where ... Source #

The clock that represents the rate at which data leaves the system.

Equations

Out (SequentialClock m cl1 cl2) = Out cl2 
Out (ParallelClock m cl1 cl2) = ParallelClock m (Out cl1) (Out cl2) 
Out cl = cl 

data LastTime cl where Source #

A tree representing possible last times to which the constituents of a clock may have ticked.

Constructors

SequentialLastTime :: LastTime cl1 -> LastTime cl2 -> LastTime (SequentialClock m cl1 cl2) 
ParallelLastTime :: LastTime cl1 -> LastTime cl2 -> LastTime (ParallelClock m cl1 cl2) 
LeafLastTime :: Time cl -> LastTime cl 

data ParClockInclusion clS cl where Source #

An inclusion of a clock into a tree of parallel compositions of clocks.

parClockTagInclusion :: ParClockInclusion clS cl -> Tag clS -> Tag cl Source #

Generates a tag for the composite clock from a tag of a leaf clock, given a parallel clock inclusion.