fixed-timestep: Pure Haskell library to repeat an action at a specific frequency.

[ library, mit, time ] [ Propose Tags ]

Repeat IO actions at a specific frequency, using flicks (1/705600000 of a second) for timekeeping. Also contains a simple implementation of flicks.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.0.1
Change log CHANGELOG.md
Dependencies async (>=2.0.1.0 && <2.3), base (>=4.10 && <4.13), clock (>=0.7 && <0.8), time (>=1.6 && <1.10) [details]
License MIT
Copyright 2019 Nicolas Stamm (Solonarv)
Author Solonarv
Maintainer Nicolas Stamm <nstamm@gmx.de>
Category Time
Home page https://github.com/Solonarv/fixed-timestep#README
Bug tracker https://github.com/Solonarv/fixed-timestep/issues
Source repo head: git clone git://github.com/Solonarv/fixed-timestep.git
Uploaded by Solonarv at 2019-03-25T22:29:11Z
Distributions
Downloads 1226 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-03-25 [all 1 reports]

Readme for fixed-timestep-0.2.0.1

[back to package description]

fixed-timestep

Pure Haskell library to run an action repeatedly, a specific amount of times per second.

Internal timekeeping is done in flicks, a unit of time equal to precisely 1/705600000 of a second.

Basic usage:

λ> import Data.Time.Clock
λ> import Time.Repeatedly
λ> repeatedly 1 (print =<< getCurrentTime)
2019-03-13 21:14:36.826248 UTC
2019-03-13 21:14:37.8282926 UTC
2019-03-13 21:14:38.8327692 UTC
2019-03-13 21:14:39.8359494 UTC
2019-03-13 21:14:40.8374415 UTC
^CInterrupted.

Using async, you can repeat multiple actions independently, and also cancel them:

λ> import Data.Time.Clock
λ> import Control.Concurrent.Asyncx
λ> import Time.Repeatedly
λ> printer <- asyncRepeatedly 1 (print =<< getCurrentTime)
2019-03-13 21:21:27.5228834 UTC
2019-03-13 21:21:28.523892 UTC
2019-03-13 21:21:29.5283634 UTC
2019-03-13 21:21:30.5313565 UTC
2019-03-13 21:21:31.535904 UTC
2019-03-13 21:21:32.5373828 UTC
2019-03-13 21:21:33.5393834 UTC
2019-03-13 21:21:34.5408811 UTC
cancel printer