I'm confused about the notion of "spark"
Is it a thread in Haskell? Or is the action of spawning a new thread ?
Thanks everybody:
So to summarize, sparks are not thread but more of unit of computation (tasks to put it in C#/Java terms). So it's the Haskell way of implementing the task parallelism.
Sparks are not threads. forkIO
introduces Haskell threads (which map down onto fewer real OS threads). Sparks create entries in the work queues for each thread, from which they'll take tasks to execute if the thread becomes idle.
As a result sparks are very cheap (you might have billions of them in a program, while you probably won't have more than a million Haskell threads, and less than a dozen OS threads on half a dozen cores).
Think of it like this: