4 ms·
FYI, sparks are different from threads. Haskell has "forkIO" threads which are comparable to Erlang processes/go-routines (actually, they're cheaper than both s
by merijnv 11y ago
FYI, sparks are different from threads. Haskell has "forkIO" threads which are comparable to Erlang processes/go-routines (actually, they're cheaper than both since haskell allocates less stack for threads). Threads are what you want for concurrent programming (i.e., non-deterministic interleaving of behaviour, which with GHC can be run in either single-threaded or multi-threaded mode).
Sparks are for deterministic parallelism, the idea behind sparks is that you create a pool of sparks, each of which represent a small, finite bit of work that can be done in parallel.
In general sparks will represent a finite, deterministic amount of work, whereas threads represent a (potentially) infinite amount of non-deterministic work.
- flippant 11y agoFor anyone looking for an example, I suggest Chapter 24 of Real World Haskell [1]. The parallel stuff is about halfway down. [1] http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html http://book.realworldhaskell.org/read/concurrent-and-multico...
- doublec 11y agoAlso worth looking at "Parallel and Concurrent Programming in Haskell" http://chimera.labs.oreilly.com/books/1230000000929 http://chimera.labs.oreilly.com/books/1230000000929
- michaelochurch 11y agoProbably one of the best books on the topics (parallelism, concurrency, distributed programming) overall in addition to being a great Haskell resource.