concurrency: Typeclasses, functions, and data types for concurrency and STM.

[ concurrency, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

A typeclass abstraction over much of Control.Concurrent (and some extras!). If you're looking for a general introduction to Haskell concurrency, you should check out the excellent Parallel and Concurrent Programming in Haskell, by Simon Marlow. If you are already familiar with concurrent Haskell, just change all the imports from Control.Concurrent.* to Control.Concurrent.Classy.* and fix the type errors.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0.0, 1.1.0.0, 1.1.1.0, 1.1.2.0, 1.1.2.1, 1.2.0.0, 1.2.1.0, 1.2.1.1, 1.2.1.2, 1.2.2.0, 1.2.3.0, 1.3.0.0, 1.4.0.0, 1.4.0.1, 1.4.0.2, 1.5.0.0, 1.6.0.0, 1.6.1.0, 1.6.2.0, 1.7.0.0, 1.8.0.0, 1.8.1.0, 1.9.0.0, 1.10.0.0, 1.11.0.0, 1.11.0.1, 1.11.0.2, 1.11.0.3
Dependencies array (>=0.5.1 && <0.6), atomic-primops (>=0.8 && <0.9), base (>=4.9 && <5), exceptions (>=0.7 && <0.11), monad-control (>=1.0 && <1.1), mtl (>=2.2 && <2.4), stm (>=2.4 && <2.6), transformers (>=0.5 && <0.7) [details]
License MIT
Copyright (c) 2016--2020 Michael Walker
Author Michael Walker
Maintainer mike@barrucadu.co.uk
Category Concurrency
Home page https://github.com/barrucadu/dejafu
Source repo head: git clone https://github.com/barrucadu/dejafu.git
this: git clone https://github.com/barrucadu/dejafu.git(tag concurrency-1.11.0.3)
Uploaded by barrucadu at 2023-06-17T22:24:12Z
Distributions LTSHaskell:1.11.0.3, NixOS:1.11.0.3, Stackage:1.11.0.3
Reverse Dependencies 14 direct, 38 indirect [details]
Downloads 21099 total (117 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-06-17 [all 1 reports]

Readme for concurrency-1.11.0.3

[back to package description]

concurrency

A typeclass abstraction over much of Control.Concurrent (and some extras!). If you're looking for a general introduction to Haskell concurrency, you should check out the excellent Parallel and Concurrent Programming in Haskell, by Simon Marlow. If you are already familiar with concurrent Haskell, just change all the imports from Control.Concurrent.* to Control.Concurrent.Classy.* and fix the type errors.

A brief list of supported functionality:

  • Threads: both unbound and bound.
  • Getting and setting capablities.
  • Yielding and delaying.
  • Mutable state: STM, MVar, and IORef.
  • Atomic compare-and-swap for IORef.
  • Exceptions.
  • All of the data structures in Control.Concurrent.* and Control.Concurrent.STM.* have typeclass-abstracted equivalents.
  • A reimplementation of the async package, providing a higher-level interface over threads, allowing users to conveniently run MonadConc operations asynchronously and wait for their results.

This is quite a rich set of functionality, although it is not complete. If there is something else you need, file an issue!

This used to be part of dejafu, but with the dejafu-0.4.0.0 release, it was split out into its own package.

Why this and not something else?

  • Why not base: like lifted-base, concurrency uses typeclasses to make function types more generic. This automatically eliminates calls to lift in many cases, resulting in clearer and simpler code.

  • Why not lifted-base: fundamentally, lifted-base is still using actual threads and actual mutable variables. When using a concurrency-specific typeclass, this isn't necessarily the case. The dejafu library provides non-IO-based implementations to allow testing concurrent programs.

  • Why not IOSpec: IOSpec provides many of the operations this library does, however it uses a free monad to do so, which has extra allocation overhead. Furthermore, it does not expose enough of the internals in order to accurately test real-execution semantics, such as relaxed memory.

Contributing

Bug reports, pull requests, and comments are very welcome!

Feel free to contact me on GitHub, through IRC (#haskell on libera.chat), or email (mike@barrucadu.co.uk).