rhine-1.1: Functional Reactive Programming with type-level clocks
Safe HaskellSafe-Inferred
LanguageHaskell2010

FRP.Rhine.Clock.Realtime.Millisecond

Description

Provides a clock that ticks at every multiple of a fixed number of milliseconds.

Synopsis

Documentation

newtype Millisecond (n :: Nat) Source #

A clock ticking every n milliseconds, in real time. Since n is in the type signature, it is ensured that when composing two signals on a Millisecond clock, they will be driven at the same rate.

The tag of this clock is Bool, where True represents successful realtime, and False a lag.

Instances

Instances details
Clock IO (Millisecond n) Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Millisecond

Associated Types

type Time (Millisecond n) Source #

type Tag (Millisecond n) Source #

GetClockProxy (Millisecond n) Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Millisecond

type Tag (Millisecond n) Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Millisecond

type Tag (Millisecond n) = Bool
type Time (Millisecond n) Source # 
Instance details

Defined in FRP.Rhine.Clock.Realtime.Millisecond

waitClock :: KnownNat n => Millisecond n Source #

This implementation measures the time after each tick, and waits for the remaining time until the next tick. If the next tick should already have occurred, the tag is set to False, representing a failed real time attempt.

Note that this clock internally uses threadDelay which can block for quite a lot longer than the requested time, which can cause the clock to miss one or more ticks when using low values of n. When using threadDelay, the difference between the real wait time and the requested wait time will be larger when using the '-threaded' ghc option (around 800 microseconds) than when not using this option (around 100 microseconds). For low values of n it is recommended that '-threaded' not be used in order to miss less ticks. The clock will adjust the wait time, up to no wait time at all, to catch up when a tick is missed.