1
1
# io-sim
2
2
3
+
3
4
` IOSim ` is an simulator monad which supports:
4
5
5
6
* asynchronous exceptions
9
10
* concurrency: both low level ` forkIO ` as well as ` async ` style
10
11
* strict STM
11
12
* access to lazy ST
12
- * schedule discovery (see [ IOSimPOR] ( ./how-to-use-IOSimPOR.md ) )
13
+ * schedule discovery (see [ IOSimPOR] [ io-sim-por-how-to ] )
13
14
* eventlog
14
15
* dynamic tracing
15
- * tracing committed changes to ` TVar ` , ` TMVar ` s, .. .
16
- * labeling of threads, ` TVar ` 's, .. .
16
+ * tracing committed changes to ` TVar ` , ` TMVar ` s, etc .
17
+ * labelling of threads, ` TVar ` 's, etc .
17
18
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 ` .
19
+ ` io-classes ` provides an interface, which allows to write code which can be run
20
+ in both real ` IO ` and ` IOSim ` . It is a drop-in replacement for ` IO ` , and
21
+ supports interfaces commonly known from ` base ` , ` exceptions ` , ` stm ` , ` async ` or
22
+ ` time ` packages.
20
23
21
24
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.
25
+ thus most of the ` IO ` instances are directly referring to ` base ` or ` async ` api.
23
26
However we made some differences, which are reported below.
24
27
25
28
` io-classes ` supports a novel hierarchy for error handling monads as well more
26
29
familiar ` exception ` style. The new hierarchy provides ` bracket ` and
27
30
` finally ` functions in the ` MonadThrow ` class, while ` catch ` style operators
28
31
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,
32
+ the most common functions used to write code with robust exception handling,
30
33
exposing them through the more basic ` MonadThrow ` class informs the reader
31
34
/ reviewer that no tricky error handling is done in that section of the code
32
35
base.
33
36
34
37
` IOSim ` exposes a detailed trace, which can be enhanced by labelling threads,
35
38
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
+ trace) or simple ` String ` based tracing. Although its agnostic with respect to
40
+ the logging framework, it worked of us particularly well using
41
+ [ contra-tracer] [ contra-tracer ] . It has been used to develop, test and debug
42
+ a complex, highly-concurrent, distributed system
43
+ ([ ouroboros-network] [ ouroboros-network ] ), in particular
39
44
40
45
* write network simulations, to verify a complex networking stack;
41
- * write disk IO simulations, to verify database solution.
46
+ * write disk IO simulations, to verify a database implementation.
47
+
42
48
43
49
## Packages
44
50
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
51
+ * ` io-sim ` : provides two simulator interpreters: ` IOSim ` and ` IOSimPOR ` - an
52
+ enhanced ` IOSim ` version with schedule discovery capabilities.
53
+ * ` io-classes ` : class bases interface, which allows to to abstract over the
54
+ monad
48
55
* ` strict-stm ` : strict STM operations
49
56
50
- [ ouroboros-network ] : https://github.com/input-output-hk/ouroboros-network
51
-
52
57
53
58
## Differences from ` base ` , ` async ` or ` exceptions ` packages
54
59
60
+ ### Major differences
61
+
55
62
* ` threadDelay ` is using ` DiffTime ` (which is measured in _ seconds_ rather than _ microseconds_ ).
56
63
* ` regiterDelay ` is using ` DiffTime `
57
64
* ` timeout ` is using ` DiffTime `
58
65
* ` getMonotonicTime ` returns ` Time ` (a newtype wrapper around ` DiffTime ` )
59
66
67
+
60
68
### Minor differences
61
69
62
- Some of the types have more general type signatures, e.g.
70
+ Some of the types have more general kind signatures, e.g.
63
71
64
72
```
65
73
type Async :: (Type -> Type) -> Type -> Type
66
74
```
67
75
68
- The first type of kind ` Type -> Type ` describe the monad which could be
76
+ The first type of kind ` Type -> Type ` describes the monad which could be
69
77
instantiated to ` IO ` , ` IOSim ` or some other monad stack build with monad
70
78
transformers. The same applies to many other types, e.g. ` TVar ` , ` TMVar ` .
71
79
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:
80
+ The following types although similar to the originals are not the same as the
81
+ ones that come from ` base ` , ` async ` , or ` excpetions ` packages:
75
82
76
83
* ` Handler ` (origin: ` base ` )
77
84
* ` MaskingState ` (origin: ` base ` )
@@ -82,12 +89,15 @@ are not the same as the ones that come from `base`, `async`, or
82
89
83
90
### Issues
84
91
85
- Although new issues should be reported in this repository, we still have a list
92
+ New issues should be reported in this repository, we still have a list
86
93
of issues opened in the ` ouroboros-network ` repository:
87
94
88
95
* [ io-sim issues] [ io-sim-issues ]
89
96
* [ io-classes issues] [ io-sim-issues ]
90
97
98
+ [ io-sim-por-how-to ] : ./io-sim/how-to-use-IOSimPOR.md
91
99
[ ouroboros-network ] : https://github.com/input-output-hk/ouroboros-network
92
100
[ io-sim-issues ] : https://github.com/input-output-hk/ouroboros-network/issues?q=is%3Aopen+is%3Aissue+label%3Aio-sim
93
101
[ io-classes-issues ] : https://github.com/input-output-hk/ouroboros-network/issues?q=is%3Aopen+is%3Aissue+label%3Aio-classes
102
+ [ contra-tracer ] : https://hackage.haskell.org/package/contra-tracer
103
+ [ io-sim-por ] : https://github.com/input-output-hk/io-sim/blob/main/io-sim/how-to-use-IOSimPOR.md
0 commit comments