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

Safe HaskellNone
LanguageHaskell2010

FRP.Rhine.Clock

Contents

Synopsis

The Clock type class

class TimeDomain (TimeDomainOf cl) => Clock m cl where Source #

A clock creates a stream of time stamps, possibly together with side effects in a monad m that cause the environment to wait until the specified time is reached.

Since we want to leverage Haskell's type system to annotate signal functions by their clocks, each clock must be an own type, cl. Different values of the same clock type should tick at the same speed, and only differ in implementation details. Often, clocks are singletons.

Minimal complete definition

startClock

Associated Types

type TimeDomainOf cl Source #

The time domain, i.e. type of the time stamps the clock creates.

type Tag cl Source #

Additional information that the clock may output at each tick, e.g. if a realtime promise was met, if an event occurred, if one of its subclocks (if any) ticked.

Methods

startClock Source #

Arguments

:: cl

The clock value, containing e.g. settings or device parameters

-> m (MSF m () (TimeDomainOf cl, Tag cl), TimeDomainOf cl)

The stream of time stamps, and the initial time

The method that produces to a clock value a running clock, i.e. an effectful stream of tagged time stamps together with an initialisation time.

Instances
Clock IO Busy Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Busy

Associated Types

type TimeDomainOf Busy :: * Source #

type Tag Busy :: * Source #

MonadIO m => Clock m StdinClock Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Stdin

Associated Types

type TimeDomainOf StdinClock :: * Source #

type Tag StdinClock :: * Source #

Monad m => Clock m FixedRate Source # 
Instance details

Defined in FRP.Rhine.Clock.FixedRate

Associated Types

type TimeDomainOf FixedRate :: * Source #

type Tag FixedRate :: * Source #

Monad m => Clock m Count Source # 
Instance details

Defined in FRP.Rhine.Clock.Count

Associated Types

type TimeDomainOf Count :: * Source #

type Tag Count :: * Source #

Monad m => Clock m (Step n) Source # 
Instance details

Defined in FRP.Rhine.Clock.Step

Associated Types

type TimeDomainOf (Step n) :: * Source #

type Tag (Step n) :: * Source #

Methods

startClock :: Step n -> m (MSF m () (TimeDomainOf (Step n), Tag (Step n)), TimeDomainOf (Step n)) Source #

(Monad m, PureAudioClockRate rate) => Clock m (PureAudioClock rate) Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Audio

Associated Types

type TimeDomainOf (PureAudioClock rate) :: * Source #

type Tag (PureAudioClock rate) :: * Source #

(Monad m, TimeDomain td, Clock m cl) => Clock m (RescaledClock cl td) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type TimeDomainOf (RescaledClock cl td) :: * Source #

type Tag (RescaledClock cl td) :: * Source #

Methods

startClock :: RescaledClock cl td -> m (MSF m () (TimeDomainOf (RescaledClock cl td), Tag (RescaledClock cl td)), TimeDomainOf (RescaledClock cl td)) Source #

(Monad m, Clock m cl) => Clock m (SelectClock cl a) Source # 
Instance details

Defined in FRP.Rhine.Clock.Select

Associated Types

type TimeDomainOf (SelectClock cl a) :: * Source #

type Tag (SelectClock cl a) :: * Source #

Methods

startClock :: SelectClock cl a -> m (MSF m () (TimeDomainOf (SelectClock cl a), Tag (SelectClock cl a)), TimeDomainOf (SelectClock cl a)) Source #

(MonadIO m, KnownNat bufferSize, AudioClockRate rate) => Clock m (AudioClock rate bufferSize) Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Audio

Associated Types

type TimeDomainOf (AudioClock rate bufferSize) :: * Source #

type Tag (AudioClock rate bufferSize) :: * Source #

Methods

startClock :: AudioClock rate bufferSize -> m (MSF m () (TimeDomainOf (AudioClock rate bufferSize), Tag (AudioClock rate bufferSize)), TimeDomainOf (AudioClock rate bufferSize)) Source #

(Monad m1, Monad m2, Clock m1 cl) => Clock m2 (HoistClock m1 m2 cl) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type TimeDomainOf (HoistClock m1 m2 cl) :: * Source #

type Tag (HoistClock m1 m2 cl) :: * Source #

Methods

startClock :: HoistClock m1 m2 cl -> m2 (MSF m2 () (TimeDomainOf (HoistClock m1 m2 cl), Tag (HoistClock m1 m2 cl)), TimeDomainOf (HoistClock m1 m2 cl)) Source #

(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 TimeDomainOf (ParallelClock m cl1 cl2) :: * Source #

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

Methods

startClock :: ParallelClock m cl1 cl2 -> m (MSF m () (TimeDomainOf (ParallelClock m cl1 cl2), Tag (ParallelClock m cl1 cl2)), TimeDomainOf (ParallelClock m cl1 cl2)) Source #

(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 TimeDomainOf (SequentialClock m cl1 cl2) :: * Source #

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

Methods

startClock :: SequentialClock m cl1 cl2 -> m (MSF m () (TimeDomainOf (SequentialClock m cl1 cl2), Tag (SequentialClock m cl1 cl2)), TimeDomainOf (SequentialClock m cl1 cl2)) Source #

(Monad m, TimeDomain td, Clock m cl) => Clock m (RescaledClockS m cl td tag) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type TimeDomainOf (RescaledClockS m cl td tag) :: * Source #

type Tag (RescaledClockS m cl td tag) :: * Source #

Methods

startClock :: RescaledClockS m cl td tag -> m (MSF m () (TimeDomainOf (RescaledClockS m cl td tag), Tag (RescaledClockS m cl td tag)), TimeDomainOf (RescaledClockS m cl td tag)) Source #

Auxiliary definitions and utilities

data TimeInfo cl Source #

An annotated, rich time stamp.

Constructors

TimeInfo 

Fields

retag :: TimeDomainOf cl1 ~ TimeDomainOf cl2 => (Tag cl1 -> Tag cl2) -> TimeInfo cl1 -> TimeInfo cl2 Source #

A utility that changes the tag of a TimeInfo.

genTimeInfo :: (Monad m, Clock m cl) => cl -> TimeDomainOf cl -> MSF m (TimeDomainOf cl, Tag cl) (TimeInfo cl) Source #

Given a clock value and an initial time, generate a stream of time stamps.

Certain universal building blocks to produce new clocks from given ones

data RescaledClock cl td Source #

Applying a morphism of time domains yields a new clock.

Constructors

RescaledClock 

Fields

Instances
(Monad m, TimeDomain td, Clock m cl) => Clock m (RescaledClock cl td) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type TimeDomainOf (RescaledClock cl td) :: * Source #

type Tag (RescaledClock cl td) :: * Source #

Methods

startClock :: RescaledClock cl td -> m (MSF m () (TimeDomainOf (RescaledClock cl td), Tag (RescaledClock cl td)), TimeDomainOf (RescaledClock cl td)) Source #

type TimeDomainOf (RescaledClock cl td) Source # 
Instance details

Defined in FRP.Rhine.Clock

type TimeDomainOf (RescaledClock cl td) = td
type Tag (RescaledClock cl td) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Tag (RescaledClock cl td) = Tag cl

data RescaledClockS m cl td tag Source #

Instead of a mere function as morphism of time domains, we can transform one time domain into the other with a monadic stream function.

Constructors

RescaledClockS 

Fields

Instances
(Monad m, TimeDomain td, Clock m cl) => Clock m (RescaledClockS m cl td tag) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type TimeDomainOf (RescaledClockS m cl td tag) :: * Source #

type Tag (RescaledClockS m cl td tag) :: * Source #

Methods

startClock :: RescaledClockS m cl td tag -> m (MSF m () (TimeDomainOf (RescaledClockS m cl td tag), Tag (RescaledClockS m cl td tag)), TimeDomainOf (RescaledClockS m cl td tag)) Source #

type TimeDomainOf (RescaledClockS m cl td tag) Source # 
Instance details

Defined in FRP.Rhine.Clock

type TimeDomainOf (RescaledClockS m cl td tag) = td
type Tag (RescaledClockS m cl td tag) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Tag (RescaledClockS m cl td tag) = tag

data HoistClock m1 m2 cl Source #

Applying a monad morphism yields a new clock.

Constructors

HoistClock 

Fields

Instances
(Monad m1, Monad m2, Clock m1 cl) => Clock m2 (HoistClock m1 m2 cl) Source # 
Instance details

Defined in FRP.Rhine.Clock

Associated Types

type TimeDomainOf (HoistClock m1 m2 cl) :: * Source #

type Tag (HoistClock m1 m2 cl) :: * Source #

Methods

startClock :: HoistClock m1 m2 cl -> m2 (MSF m2 () (TimeDomainOf (HoistClock m1 m2 cl), Tag (HoistClock m1 m2 cl)), TimeDomainOf (HoistClock m1 m2 cl)) Source #

type TimeDomainOf (HoistClock m1 m2 cl) Source # 
Instance details

Defined in FRP.Rhine.Clock

type TimeDomainOf (HoistClock m1 m2 cl) = TimeDomainOf cl
type Tag (HoistClock m1 m2 cl) Source # 
Instance details

Defined in FRP.Rhine.Clock

type Tag (HoistClock m1 m2 cl) = Tag cl

type LiftClock m t cl = HoistClock m (t m) cl Source #

liftClock :: (Monad m, MonadTrans t) => cl -> LiftClock m t cl Source #