[Haskell-cafe] derivation of mapP, a parallel, lazy map

Dan Weston westondan at imageworks.com
Mon Feb 25 17:46:38 EST 2008

According to Lennart Augustsson 
(http://haskell.org/pipermail/haskell-cafe/2007-July/029603.html) you 
can have uninterruptible threads in ghc. If a thread never allocates it 
will never be preempted.

So I wonder if what you are proposing really is unsafe because by the 
time (take 1) is even invoked you might not regain control of the CPU 
being held hostage by parBuffer trying to evaluate undefined. After all, 
undefined can encompass non-halting calculations as well as abortive ones.

In other words, undefined is not an exception (despite the error 
message). Converting it to a catchable exception is tantamount to 
pretending that the threading model is fully preemptive.


Roberto Zunino wrote:
> Felipe Lessa wrote:
>> Have you seen parBuffer? I'd also recommend looking at its source.
> I wonder if it would be possible to make a variant of parBuffer so that 
> the following evaluates to 1:
>  > take 1 $ parBuffer 10 r0 (1:2:3:undefined)
> *** Exception: Prelude.undefined
> Maybe we should use a more complex intermediate structure as
>    data ExcList a = Nil | Cons a (ExcList a) | Deferred Exception
> and catch the exception through some unsafe stuff? Would that be a good 
> idea?
> Zun.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list