3 ms·
Scala uses the Future monad pretty widely to model concurrency. Does Haskell not use the Future monad? What does it use instead?
by pkinsky 13y ago
Scala uses the Future monad pretty widely to model concurrency. Does Haskell not use the Future monad? What does it use instead?
- jmillikin 13y agoIn Haskell it'd be more typical to use blocking operations for RPCs and spawn a thread for each sequence. For example, the article has a sequence of operations that should be run in order; that would be a single thread, with each operation blocking until it's ready. If some operations need to be async, then spawn another thread for just that operation. This model is possible because the Haskell runtime decouples threads from the OS's process-with-shared-address-space abstraction, so running a few million threads is a reasonable design choice. Users of Erlang will find the Haskell threading model very familiar, with the exception that Haskell also provides ways to pass around mutable state (e.g. you could pass a pointer through a channel). It is possible to implement something like a Future monad if you really want to, based on MVar, but cheap threads make it unnecessary.