3 ms·
Sounds like you've basically explained several of the common concurrency features of Haskell. Haskell has the advantage that any pure data structure (ie, not us
by axman6 13y ago
Sounds like you've basically explained several of the common concurrency features of Haskell. Haskell has the advantage that any pure data structure (ie, not using mutable references, which is almost all data structures we use) can be used concurrently and atomically using IORefs and atomicModifyIORef. If you need transactional guarantees, then software transactional memory (STM) is just as easy to use. For both these situations, it's laziness and purity that gives us these things essentially for free.
Of course you could create more advanced concurrent mutable structures as other languages have, but IORefs and STM get you a very long way when coupled with GHC's extremely light weight threading and high performance IO (which is getting even better in GHC 7.8, to be released soon).
To learn more, Simon Marlow's excellent book is available for free online [1] and in dead tree and eBook forms from O'Reilly. It's very clear, with a great balance of how to use things practically, how they work, and how to make them work their best.
[1] http://chimera.labs.oreilly.com/books/1230000000929/index.html http://chimera.labs.oreilly.com/books/1230000000929/index.ht...
- tel 13y agoThere are also things like acid-state [0] if you want transactional, in-memory, and persisted data stores. [0] http://hackage.haskell.org/package/acid-state http://hackage.haskell.org/package/acid-state