composewell / streamly

High performance, concurrent functional programming abstractions
https://streamly.composewell.com
Other
864 stars 66 forks source link

Concurrent monad transformers #247

Open harendra-kumar opened 5 years ago

harendra-kumar commented 5 years ago

To support concurrent modification of shared state we need a concurrent StateT. A concurrent StateT would fork the shared state to multiple concurrent threads and then join the modified state back to create a common modified shared state. We can have fork and join typeclasses to facilitate the forking an combining of state.

In addition to StateT, ExceptT is another candidate for fork and join of state.

harendra-kumar commented 4 years ago

Instead of using fork/join typeclasses we can have a Monoid instance on the state of the monad and combine the states of the concurrent actions on completion.

Currently the MonadState instance for concurrent streams is broken. We should either fix this issue or remove that instance. Marking this issue as a bug because of that.

harendra-kumar commented 2 years ago

MonadState is broken for concurrent streams in Streamly.Prelude but we are deprecating that module in 0.9.0 and now we have explicit concurrency via Data.Stream.Concurrent, so we are leaving MonadState for old streams as is.