pipes-misc-0.5.0.0: Miscellaneous utilities for pipes, required by glazier-tutorial

Safe HaskellNone
LanguageHaskell2010

Pipes.Misc.Time

Description

You can use the Arrow instance to get different types of ticker time. Eg:

diffTimeEvery :: MonadIO io => C.Clock -> Int -> P.Producer' C.TimeSpec io r
diffTimeEvery clock micros = always () P.>-> delay micros P.>-> ticker clock P.>-> diffTime

import Control.Arrow
import qualified Control.Category as Cat
import qualified Pipes.Shaft as PS

diffAndTickEvery :: MonadIO io => C.Clock -> Int -> P.Producer' (C.TimeSpec, C.TimeSpec) io r
diffAndTickEvery clock micros = always () P.>-> delay micros P.>-> ticker clock P.>->
   PS.fromShaft (PS.Shaft diffTime &&& Cat.id)

Synopsis

Documentation

delay :: MonadIO io => Int -> Pipe a a io r Source #

Add a delay after every await

delay' :: MonadIO io => Int -> Pipe a a io r Source #

After the first await, add a delay after every subsequent await.

fps :: Decimal -> Int Source #

obtain the threadDelay given a fps

ticker :: MonadIO io => Clock -> Pipe () TimeSpec io r Source #

Continuously yield the clock time Use with delay to reduce the yield rate. Eg:

tickEvery :: MonadIO io => C.Clock -> Int -> P.Producer' C.TimeSpec io r
tickEvery clock micros = always () P.>-> delay micros P.>-> ticker clock

diffTime :: Monad m => Pipe TimeSpec TimeSpec m r Source #

Converts a stream of times, into a stream of delta time. The first yield is zero.

resetEpoch :: Monad m => Pipe TimeSpec TimeSpec m r Source #

Converts a stream of epoch times into a stream of epoch time, where zero is the first yielded time.