1## Using Monad Transformers
3Common monad transformers can be used with streamly serial streams, without any
4issues. `ReaderT` can be used with concurrent streams as well without any
7The semantics of monads other than `ReaderT` with concurrent streams are
8not yet finalized and will change in future, therefore as of now they are not
9recommended to be used with concurrent streams.
11## Ordering of Monad Transformers
13In most cases it is a good idea to keep streamly as the top level monad.
16### Serial Applications
18Read only global state can always be shared using the `Reader` monad.
19Read-write global state can be shared either using an `IORef` in the `Reader`
20monad or using the `State` monad.
22See `AcidRain.hs` example for a usage of `StateT` in the serially executing
23portion of the program.
25### Concurrent Applications
27The current recommended method for sharing modifiable global state across
28concurrent tasks is to put the shared state inside an `IORef` in a `Reader`
29monad or just share the `IORef` by passing it to the required functions. The
30`IORef` can be updated atomically using `atomicModifyIORef`.
32The `CirclingSquare.hs` example shares an `IORef` across parallel tasks.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list