Hacker News new | ask | show | jobs
by chriswarbo 2961 days ago
I get what you're saying, but I don't like to think of these as orthogonal: locking is a way to force actions to occur in a particular order, so is monadic IO (the 'world-state' is a dummy data dependency, preventing later actions from getting called before earlier ones; it doesn't "really" contain the whole state of the world ;) )
1 comments

I get what you're saying too. :) I think one reasonable semantics for monadic I/O is that it sequences effects in a single thread; and effects from other threads are part of the world-state, not part of the monadic context. Another reasonable semantics is what I think you're describing: monadic I/O in a multithreaded program should sequence effects across all the threads (e.g., mutexes on shared resources). It would be nice to have both options available -- maybe similar to how you can plug a strategy into Haskell's Control.Parallel.Strategies monad.

https://hackage.haskell.org/package/parallel-3.2.1.1/docs/Co...