|
|
|
|
|
by shipp02
1771 days ago
|
|
While there is no exact match between them, the ``Send`` trait which can be thought of as preventing you from sharing an object between two threads actually has two monadic implementation in haskell. The ``IORef`` and ``STRef`` monads serve exactly the same purpose. This utilizes the Rank2Types extenstion. I invite you to read the Lazy Functional State Threads paper[1] by Simon Peyton Jones published in 1994. The purpose of the ST Monad is to prevent you form sharing the object inside it wrapped by an STRef with another thread of execution. IORef utilizes the uniqueness of the ``IO`` monad and its properties guaranteed by the haskell runtime i.e. only one thread can use it at any given time to prevent more than one thread from having a reference to the object inside the IORef from multiple. [1]:https://www.microsoft.com/en-us/research/wp-content/uploads/... |
|