Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class TimeDomain (TimeDomainOf cl) => Clock m cl where
- type TimeDomainOf cl
- type Tag cl
- data TimeInfo cl = TimeInfo {
- sinceTick :: Diff (TimeDomainOf cl)
- sinceStart :: Diff (TimeDomainOf cl)
- absolute :: TimeDomainOf cl
- tag :: Tag cl
- retag :: TimeDomainOf cl1 ~ TimeDomainOf cl2 => (Tag cl1 -> Tag cl2) -> TimeInfo cl1 -> TimeInfo cl2
- genTimeInfo :: (Monad m, Clock m cl) => cl -> TimeDomainOf cl -> MSF m (TimeDomainOf cl, Tag cl) (TimeInfo cl)
- data RescaledClock cl td = RescaledClock {
- unscaledClock :: cl
- rescale :: TimeDomainOf cl -> td
- data RescaledClockS m cl td tag = RescaledClockS {
- unscaledClockS :: cl
- rescaleS :: TimeDomainOf cl -> m (MSF m (TimeDomainOf cl, Tag cl) (td, tag), td)
- data HoistClock m1 m2 cl = HoistClock {
- hoistedClock :: cl
- monadMorphism :: forall a. m1 a -> m2 a
- type LiftClock m t cl = HoistClock m (t m) cl
- liftClock :: (Monad m, MonadTrans t) => cl -> LiftClock m t cl
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.
type TimeDomainOf cl Source #
The time domain, i.e. type of the time stamps the clock creates.
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.
startClock :: cl -> m (MSF m () (TimeDomainOf cl, Tag cl), TimeDomainOf cl) Source #
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.
Clock IO Busy Source # | |
Monad m => Clock m Count Source # | |
Monad m => Clock m FixedRate Source # | |
MonadIO m => Clock m StdinClock Source # | |
(Monad m, PureAudioClockRate rate) => Clock m (PureAudioClock rate) Source # | |
Monad m => Clock m (Step n) Source # | |
(Monad m, TimeDomain td, Clock m cl) => Clock m (RescaledClock cl td) Source # | |
(MonadIO m, KnownNat bufferSize, AudioClockRate rate) => Clock m (AudioClock rate bufferSize) Source # | |
(Monad m, Clock m cl) => Clock m (SelectClock cl a) Source # | |
(Monad m1, Monad m2, Clock m1 a) => Clock m2 (HoistClock m1 m2 a) Source # | |
(Monad m, Clock m cl1, Clock m cl2) => Clock m (ParallelClock m cl1 cl2) Source # | |
(Monad m, Clock m cl1, Clock m cl2) => Clock m (SequentialClock m cl1 cl2) Source # | |
(Monad m, TimeDomain td, Clock m cl) => Clock m (RescaledClockS m cl td tag) Source # | |
Auxiliary definitions and utilities
An annotated, rich time stamp.
TimeInfo | |
|
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.
RescaledClock | |
|
(Monad m, TimeDomain td, Clock m cl) => Clock m (RescaledClock cl td) Source # | |
type TimeDomainOf (RescaledClock cl td) Source # | |
type Tag (RescaledClock cl td) Source # | |
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.
RescaledClockS | |
|
(Monad m, TimeDomain td, Clock m cl) => Clock m (RescaledClockS m cl td tag) Source # | |
type TimeDomainOf (RescaledClockS m cl td tag) Source # | |
type Tag (RescaledClockS m cl td tag) Source # | |
data HoistClock m1 m2 cl Source #
Applying a monad morphism yields a new clock.
HoistClock | |
|
(Monad m1, Monad m2, Clock m1 a) => Clock m2 (HoistClock m1 m2 a) Source # | |
type TimeDomainOf (HoistClock m1 m2 cl) Source # | |
type Tag (HoistClock m1 m2 cl) Source # | |
type LiftClock m t cl = HoistClock m (t m) cl Source #