Skip to content

Commit 15a4635

Browse files
committed
Added a README.md file
1 parent 1c81f9e commit 15a4635

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# io-sim
2+
3+
`IOSim` is an simulator monad which supports:
4+
5+
* asynchronous exceptions
6+
* simulated time
7+
* timeout API
8+
* software transaction memory (STM)
9+
* concurrency: both low level `forkIO` as well as `async` style
10+
* strict STM
11+
* access to lazy ST
12+
* schedule discovery (see [IOSimPOR](./how-to-use-IOSimPOR.md)
13+
* eventlog
14+
* dynamic tracing
15+
* tracing committed changes to `TVar`, `TMVar`s, ...
16+
* labeling of threads, `TVar`'s, ...
17+
18+
`io-classes` provide a common interface, which allow to write code which can be
19+
run in both real `IO` and `IOSim`. It is a drop-in replacement for `IO`.
20+
21+
One of the principles of `io-classes` was to stay as close to `IO` as possible,
22+
thus most of the `IO` instances are directly referring to `base`, `async` api.
23+
However we made some differences, which are reported below.
24+
25+
`io-classes` supports a novel hierarchy for error handling monads as well more
26+
familiar `exception` style. The new hierarchy provides `bracket` and
27+
`finally` functions in the `MonadThrow` class, while `catch` style operators
28+
are provided by a super-class `MonadCatch`. Both `bracket` and `finally` are
29+
the most common interface used to write code with robust exception handling,
30+
exposing them through the more basic `MonadThrow` class informs the reader
31+
/ reviewer than no tricky error handling is done in that section of the code
32+
base.
33+
34+
`IOSim` exposes a detailed trace, which can be enhanced by labelling threads,
35+
or mutable variables, tracing `Dynamic` values (which can be recovered from the
36+
trace) or simple `String` based tracing. It has been used to develop & test
37+
a complex concurrent system ([ouroboros-network][ouroboros-network]), in
38+
particular
39+
40+
* write network simulations, to verify a complex networking stack;
41+
* write disk IO simulations, to verify database solution.
42+
43+
## Packages
44+
45+
* `io-sim`: provides two simulator monads: `IOSim` and `IOSimPOR` - an enhanced
46+
`IOSim` version with schedule discovery capabilities.
47+
* `io-classes`: class bases interface
48+
* `strict-stm`: strict STM operations
49+
50+
[ouroboros-network]: https://github.com/input-output-hk/ouroboros-network
51+
52+
53+
## Differences from `base`, `async` or `exceptions` packages
54+
55+
* `threadDelay` is using `DiffTime` (which is measured in _seconds_ rather than _microseconds_).
56+
* `regiterDelay` is using `DiffTime`
57+
* `timeout` is using `DiffTime`
58+
* `getMonotonicTime` returns `Time` (a newtype wrapper around `DiffTime`)
59+
60+
### Minor differences
61+
62+
Some of the types have more general type signatures, e.g.
63+
64+
```
65+
type Async :: (Type -> Type) -> Type -> Type
66+
```
67+
68+
The first type of kind `Type -> Type` describe the monad which could be
69+
instantiated to `IO`, `IOSim` or some other monad stack build with monad
70+
transformers. The same applies to many other types, e.g. `TVar`, `TMVar`.
71+
72+
The types although similar to the original
73+
are not the same as the ones that come from `base`, `async`, or
74+
`excpetions` packages:
75+
76+
* `Handler` (origin: `base`)
77+
* `MaskingState` (origin: `base`)
78+
* `Concurrently` (origin: `async`)
79+
* `ExceptionInLinkedThread` (origin: `async`)
80+
* `ExitCase` (origin: `exceptions`)
81+
82+
83+
### Issues
84+
85+
Although new issues should be reported in this repository, we still have a list
86+
of issues opened in the `ouroboros-network` repository:
87+
88+
* [io-sim issues][io-sim-issues]
89+
* [io-classes issues][io-sim-issues]
90+
91+
[ouroboros-network]: https://github.com/input-output-hk/ouroboros-network
92+
[io-sim-issues]: https://github.com/input-output-hk/ouroboros-network/issues?q=is%3Aopen+is%3Aissue+label%3Aio-sim
93+
[io-classes-issues]: https://github.com/input-output-hk/ouroboros-network/issues?q=is%3Aopen+is%3Aissue+label%3Aio-classes

0 commit comments

Comments
 (0)