Safe Haskell | None |
---|---|
Language | Haskell2010 |
FRP.Rhine.Clock
Contents
Synopsis
- 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.
Minimal complete definition
Associated Types
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.
Methods
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
Auxiliary definitions and utilities
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 # | |
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 # | |
Defined in FRP.Rhine.Clock | |
type Tag (RescaledClock cl td) Source # | |
Defined in FRP.Rhine.Clock |
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 # | |
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 # | |
Defined in FRP.Rhine.Clock | |
type Tag (RescaledClockS m cl td tag) Source # | |
Defined in FRP.Rhine.Clock |
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 # | |
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 # | |
Defined in FRP.Rhine.Clock | |
type Tag (HoistClock m1 m2 cl) Source # | |
Defined in FRP.Rhine.Clock |
type LiftClock m t cl = HoistClock m (t m) cl Source #