MyNixOS website logo
Description

Pure Haskell library to repeat an action at a specific frequency.

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

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
Metadata

Version

0.2.0.1

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows