1
1
# IO Monad Class Hierarchy
2
2
3
- This package provides a monad class hierarchy which is an interface for both the
4
- [ ` io-sim ` ] and [ ` IO ` ] monads. It was developed with the following constraints
5
- in mind:
3
+ This package provides a monad class hierarchy which is an interface for both
4
+ the [ ` io-sim ` ] and [ ` IO ` ] monads. It was developed with the following
5
+ constraints in mind:
6
6
7
- * be a drop in replacement for ` IO ` monad;
7
+ * be a drop- in replacement for ` IO ` monad;
8
8
* ` IO ` instances do not alter its original semantics, providing a shallow
9
- bindings to [ ` async ` ] , [ ` base ` ] , [ ` stm ` ] and [ ` exceptions ` ] packages as well
10
- as timer api ;
11
- * provide zero cost abstractions.
9
+ bindings to [ ` async ` ] , [ ` base ` ] , [ ` stm ` ] , and [ ` exceptions ` ] packages as well
10
+ as timer API ;
11
+ * provide zero- cost abstractions.
12
12
13
- We provde also non standard extensions of this api :
13
+ We provide also non- standard extensions of this API :
14
14
15
15
* [ ` strict-stm ` ] : strict ` TVar ` 's, and other mutable ` STM ` variables, with
16
- suport of the [ ` nothunks ` ] library;
16
+ support of the [ ` nothunks ` ] library;
17
17
* [ ` si-timers ` ] : timers api:
18
18
- 32-bit safe API using ` DiffTime ` measured in seconds (rather than time in
19
19
microseconds represented as ` Int ` as in ` base ` )
20
- - cancellble timeouts.
20
+ - cancellable timeouts.
21
21
22
- [ ` strict-stm ` ] and [ ` nothunks ` ] were successfuly used in large code base to
22
+ [ ` strict-stm ` ] and [ ` nothunks ` ] were successfully used in a large code base to
23
23
eliminate space leaks and keep that property over long development cycles.
24
24
25
25
## Exception Class Hierarchy
26
26
27
27
This package provides an alternative class hierarchy giving access to
28
- exceptions api . The [ ` exception ` ] package class hierarchy is also supported by
28
+ exceptions API . The [ ` exception ` ] package class hierarchy is also supported by
29
29
[ ` io-sim ` ] , so you can also use either one.
30
30
31
- The ` MonadThrow ` defined in this package allows to work with exceptions without
31
+ The ` MonadThrow ` defined in this package allows working with exceptions without
32
32
having explicit access to ` catch ` or ` mask ` . It only provides access to
33
- ` throwIO ` , ` bracket ` , ` bracket_ ` and ` finally ` . ` MonadCatch ` class provides
34
- api which allows to work with exceptions, e.g. ` catch ` or ` bracketOnError ` , and
35
- ` MonadMask ` gives access to low level ` mask ` and friends. This division makes
33
+ ` throwIO ` , ` bracket ` , ` bracket_ ` , and ` finally ` . ` MonadCatch ` class provides
34
+ API which allows working with exceptions, e.g. ` catch ` or ` bracketOnError ` , and
35
+ ` MonadMask ` gives access to low- level ` mask ` and friends. This division makes
36
36
code review process somewhat easier. Using only ` MonadThrow ` constraint, the
37
- reviewer can be sure that no low level exception api is used, which usually
38
- requires more care. Still ` MonadThrow ` is general enough to to do resource
37
+ reviewer can be sure that no low- level exception API is used, which usually
38
+ requires more care. Still ` MonadThrow ` is general enough to do resource
39
39
handling right.
40
40
41
41
## Time and Timer APIs
42
42
43
43
The time and timer APIs of this package follows closely the API exposed by
44
- [ ` base ` ] and [ ` time ` ] packages. We separately packaged a more conveneint API
45
- in [ ` si-timers ` ] (ref [ SI] ), which provides monoidal action of ` DiffTime ` on
44
+ [ ` base ` ] and [ ` time ` ] packages. We separately packaged a more convenient API
45
+ in [ ` si-timers ` ] (ref [ SI] ), which provides a monoidal action of ` DiffTime ` on
46
46
monotonic time as well as exposes 32-bit safe timer API (on 32-bit systems time
47
- in microseconds represented as an ` Int ` can only holds timeouts of ~ 35
48
- minutes).
47
+ in microseconds represented as an ` Int ` can only hold timeouts of ~ 35 minutes).
49
48
50
- ` Control.Monad.Class.MonadTimer.NonStandard.MonadTimeout ` provides a low level
51
- timeout abstraction. On systems which support native timer manager it's used
52
- to implement its API, which is very efficient even for low latency timeouts.
49
+ ` Control.Monad.Class.MonadTimer.NonStandard.MonadTimeout ` provides a low- level
50
+ timeout abstraction. On systems that support a native timer manager, it's used
51
+ to implement its API, which is very efficient even for low- latency timeouts.
53
52
On other platforms (e.g. ` Windows ` ), it's good enough for subsecond timeouts
54
- but it's not good enough for fine grained timeouts (e.g. sub milliseconds) as
55
- it relays on GHC thread scheduler. We support ` MonadTimeout ` on ` Linux ` ,
56
- ` MacOS ` , ` Windows ` and ` IOSim ` (and unofficially on ` GHCJS ` ).
53
+ but it's not good enough for fine- grained timeouts (e.g. sub milliseconds) as
54
+ it relays on the GHC thread scheduler. We support ` MonadTimeout ` on ` Linux ` ,
55
+ ` MacOS ` , ` Windows ` , and ` IOSim ` (and unofficially on ` GHCJS ` ).
57
56
58
- ` MonadDelay ` and ` MonadTimer ` classes provide the well established interface to
57
+ ` MonadDelay ` and ` MonadTimer ` classes provide a well- established interface to
59
58
delays & timers.
60
59
61
60
62
61
## Software Transactional Memory API
63
62
64
- We provide two interfaces to ` stm ` api : lazy, included in ` io-classes ` ; and
63
+ We provide two interfaces to ` stm ` API : lazy, included in ` io-classes ` ; and
65
64
strict one provided by [ ` strict-stm ` ] .
66
65
67
66
68
67
## Threads API
69
68
70
- We draw a line between ` base ` api and ` async ` api. The former one is provided
71
- by
69
+ We draw a line between ` base ` API and ` async ` API. The former is provided by
72
70
[ MonadFork] ( https://hackage.haskell.org/package/io-classes/docs/Control-Monad-Class-MonadFork.html#t:MonadFork )
73
71
the latter by
74
72
[ MonadAsync] ( https://hackage.haskell.org/package/io-classes/docs/Control-Monad-Class-MonadFork.html#t:MonadAsync ) .
@@ -78,33 +76,30 @@ packages.
78
76
79
77
## Some other APIs
80
78
81
- * [ MonadEventlog] ( https://hackage.haskell.org/package/io-sim-classes/docs/Control-Monad-Class-MonadEventlog.html#t:MonadEventlog ) :
82
- provides an API to the
83
- [ Debug.Trace] ( https://hackage.haskell.org/package/base/docs/Debug-Trace.html )
84
- eventlog interface.
85
- * [ MonadST] ( https://hackage.haskell.org/package/io-classes/docs/Control-Monad-Class-MonadST.html#t:MonadST ) : provides a way to lift ` ST ` -computations.
86
- * [ MonadSay] ( https://hackage.haskell.org/package/io-classes/docs/Control-Monad-Class-MonadSay.html#t:MonadSay ) : dummy debugging interface
79
+ * [ MonadEventlog] : provides an API to the [ Debug.Trace] event log interface.
80
+ * [ MonadST] : provides a way to lift ` ST ` -computations.
81
+ * [ MonadSay] : dummy debugging interface
87
82
88
83
89
84
## Debuging & Insepction
90
85
91
- We provide quite extended debuging & insepction api . This proved to be
86
+ We provide quite extended debugging & inspection API . This proved to be
92
87
extremely helpful when analysing complex deadlocks or livelocks or writing
93
88
complex quickcheck properties of a highly concurrent system. Some of this is
94
- only possible because we can control execution environment of [ ` io-sim ` ] .
89
+ only possible because we can control the execution environment of [ ` io-sim ` ] .
95
90
96
91
* ` labelThread ` as part of ` MonadThread ` ([ ` IO ` ] , [ ` io-sim ` ] , which is also
97
92
part of ` GHC ` API, ref [ ` labelThread ` ] [ labelThread-base ] );
98
- * ` MonadLabelledSTM ` which allows to label various ` STM ` mutable variables,
93
+ * ` MonadLabelledSTM ` which allows to label of various ` STM ` mutable variables,
99
94
e.g. ` TVar ` , ` MVar ` , etc. ([ ` io-sim ` ] , not provided by ` GHC ` );
100
- * ` MonadInspectSTM ` which allows to inspect values of ` STM ` mutable variables
101
- when they are commited . ([ ` io-sim ` ] , not provided by ` GHC ` ).
95
+ * ` MonadInspectSTM ` which allows inspecting values of ` STM ` mutable variables
96
+ when they are committed . ([ ` io-sim ` ] , not provided by ` GHC ` ).
102
97
103
98
104
- ## Monad transformers
99
+ ## Monad Transformers
105
100
106
101
We provide support for monad transformers (although at this stage it might have
107
- its limitations and so there might be some rought edges. PRs are welcomed,
102
+ its limitations and so there might be some rough edges. PRs are welcomed,
108
103
[ contributing] ).
109
104
110
105
[ SI] : https://www.wikiwand.com/en/International_System_of_Units
@@ -122,3 +117,8 @@ its limitations and so there might be some rought edges. PRs are welcomed,
122
117
[ contributing ] : https://www.github.com/input-output-hk/io-sim/tree/master/CONTRIBUTING.md
123
118
[ `nothunks` ] : https://hackage.haskell.org/package/nothunks
124
119
[ labelThread-base ] : https://hackage.haskell.org/package/base-4.17.0.0/docs/GHC-Conc-Sync.html#v:labelThread
120
+
121
+ [ MonadEventlog ] : https://hackage.haskell.org/package/io-sim-classes/docs/Control-Monad-Class-MonadEventlog.html#t:MonadEventlog
122
+ [ Debug.Trace ] : https://hackage.haskell.org/package/base/docs/Debug-Trace.html
123
+ [ MonadST ] : https://hackage.haskell.org/package/io-classes/docs/Control-Monad-Class-MonadST.html#t:MonadST
124
+ [ MonadSay ] : https://hackage.haskell.org/package/io-classes/docs/Control-Monad-Class-MonadSay.html#t:MonadSay
0 commit comments