io-classes: Type classes for concurrency with STM, ST and timing

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]

IO Monad class hierarchy compatible with io-sim, base, async, stm, exceptions & time packages.


[Skip to Readme]

Properties

Versions 1.0.0.0, 1.0.0.1, 1.0.0.1, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.3.1.0, 1.4.0.0, 1.4.1.0
Change log CHANGELOG.md
Dependencies array, async (>=2.1), base (>=4.9 && <4.19), bytestring, mtl (>=2.2 && <2.4), stm (>=2.5 && <2.6), time (>=1.9.1 && <1.13) [details]
License Apache-2.0[multiple license files]
Copyright 2019-2023 Input Output Global Inc (IOG)
Author Alexander Vieth, Duncan Coutts, Marcin Szamotulski, Thomas Winant
Maintainer Duncan Coutts duncan@well-typed.com, Marcin Szamotulski coot@coot.me
Category Control
Source repo head: git clone https://github.com/input-output-hk/io-sim(io-classes)
Uploaded by coot at 2023-04-20T19:05:39Z

Modules

[Index] [Quick Jump]

Flags

Automatic Flags
NameDescriptionDefault
asserts

Enable assertions

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for io-classes-1.0.0.1

[back to package description]

IO Monad Class Hierarchy

This package provides a monad class hierarchy which is an interface for both the io-sim and IO monads. It was developed with the following constraints in mind:

We provide also non-standard extensions of this API:

strict-stm and nothunks were successfully used in a large code base to eliminate space leaks and keep that property over long development cycles.

Exception Class Hierarchy

This package provides an alternative class hierarchy giving access to exceptions API. The [exception] package class hierarchy is also supported by io-sim, so you can also use either one.

The MonadThrow defined in this package allows working with exceptions without having explicit access to catch or mask. It only provides access to throwIO, bracket, bracket_, and finally. MonadCatch class provides API which allows working with exceptions, e.g. catch or bracketOnError, and MonadMask gives access to low-level mask and friends. This division makes code review process somewhat easier. Using only MonadThrow constraint, the reviewer can be sure that no low-level exception API is used, which usually requires more care. Still MonadThrow is general enough to do resource handling right.

Time and Timer APIs

The time and timer APIs of this package follows closely the API exposed by base and time packages. We separately packaged a more convenient API in si-timers (ref SI), which provides a monoidal action of DiffTime on monotonic time as well as exposes 32-bit safe timer API (on 32-bit systems time in microseconds represented as an Int can only hold timeouts of ~35 minutes).

Control.Monad.Class.MonadTimer.NonStandard.MonadTimeout provides a low-level timeout abstraction. On systems that support a native timer manager, it's used to implement its API, which is very efficient even for low-latency timeouts. On other platforms (e.g. Windows), it's good enough for subsecond timeouts but it's not good enough for fine-grained timeouts (e.g. sub milliseconds) as it relays on the GHC thread scheduler. We support MonadTimeout on Linux, MacOS, Windows, and IOSim (and unofficially on GHCJS).

MonadDelay and MonadTimer classes provide a well-established interface to delays & timers.

Software Transactional Memory API

We provide two interfaces to stm API: lazy, included in io-classes; and strict one provided by strict-stm.

Threads API

We draw a line between base API and async API. The former is provided by MonadFork the latter by MonadAsync. Both are shallow abstractions around APIs exposed by the base and async packages.

Some other APIs

Debuging & Insepction

We provide quite extended debugging & inspection API. This proved to be extremely helpful when analysing complex deadlocks or livelocks or writing complex quickcheck properties of a highly concurrent system. Some of this is only possible because we can control the execution environment of io-sim.

Monad Transformers

We provide support for monad transformers (although at this stage it might have its limitations and so there might be some rough edges. PRs are welcomed, contributing).