[Haskell-cafe] parallelism or concurrency ? if they are different

Paolino paolo.veronelli at gmail.com
Fri Feb 13 05:09:35 EST 2009

When I came to haskell, I arrived with a small and only evolutionary
background in programming. First monad I met was MonadState StdGen m.
Everything was in someway acceptable, I had no problem in
explicitating the need for the generator.
The lesson was referential transparency. To me referential tranparency
is still obscure as a feature.
Not using the monad , my functions pass around a generator, then they
are repeatable, same generator , same computation.
Years pass by, now evolutionary algorithms need to scale multicores.
But multicore can be used with threads or par, the difference is that
par is pure, because it respects referential transparency. But threads
They are always unrespectful ? Or it's an implementation issue of
preemptive choice?
Can I have a baton to pass around like I had for random generator, so
that the computation ends without IO (unsafe performed) , without
breaking tranparency,
something like (runIOThreads :: ThreadsIO a -> ThreadsBaton -> a) ?
>From Real World Haskell my algorithm have to be parallelized as they
don't do some kind of IO, they don't deal with the world, but where is
it stated that it is possible  to write them with par (I couldn't) ?
More , I'm not caring  that my computation is unrepeatable, for me
it's fine that  the runtime system  gives me the cached results for
same arguments computation. The fact that it doesn't ,and recompute
the function giving out something fuzzily different from before, is
enough to coerce me to spit out IO  values ?
Finally, why and where the optimizer will substitute a value with its
definition, so that it possibly get computed twice ?



More information about the Haskell-Cafe mailing list