ticker: A concurrent utility inspired by Ticker in golang

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:

A concurrent utility inspired by Ticker in golang


[Skip to Readme]

Properties

Versions 1.0.0, 1.0.0
Change log CHANGELOG.md
Dependencies async (>=2.0 && <3), base (>=4.7 && <5), safe-exceptions (>=0.1) [details]
License BSD-3-Clause
Copyright 2017 OSANAI Kazuyoshi
Author OSANAI Kazuyoshi
Maintainer osmium.k@gmail.com
Category Concurrency
Home page https://github.com/kazeula/ticker-hs
Source repo head: git clone https://github.com/kazeula/ticker-hs
Uploaded by syocy at 2017-08-21T16:15:44Z

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for ticker-1.0.0

[back to package description]

ticker

A utility of concurrent programming in Haskell, inspired by Ticker in Go.

import Control.Concurrent.Ticker (newTicker)
import Control.Concurrent.Chan (getChanContents)
import Control.Concurrent.Async (async, cancel)
import Control.Monad (forM_)

main :: IO ()
main = do
  (chan, cancelTicker) <- newTicker (10^3 * 100) -- tick rate: 100ms
  chanStream <- getChanContents chan
  thread <- async $ forM_ chanStream $ \_ -> do
    putStr "Tick!"
  threadDelay (10^3 * 350) -- wait 3 ticks
  putStrLn ""
  cancel thread
  cancelTicker
  
-- Tick!Tick!Tick!

More functions are defined in src/Control/Concurrent/Ticker.hs.