Note that there are some explanatory texts on larger screens.

plurals
  1. POShared variable in Haskell parMap
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COI highly doubt that using a mutable variable to contain the boolean value is going to make it any faster. Have you run a profiler on your code to see where the slowdowns occur? You may be too focused on optimizing something simple when your efficiency problem lies elsewhere. Are you sure that `g` is getting evaluated in parallel, or is it creating thunks in parallel and letting the single-core `foldr` do the evaluation?
      singulars
    2. COHi thanks for the comment. Actually, I want to know more if this is possible. I have been playing with profiling, and what not. Certainly the majority of time is spent in the map. I know this, and it is stated in the question. But I have seen this pattern come up in more than one place in my code, where I do something in parallel, and then something else in sequence -- and the sequential part is something tacked on to the end of a computation and could be done with a shared variable in the parallel part. So I'm asking how to do this in Haskell.
      singulars
    3. COIt's certainly possible to use `MVar`s to do this, but I think you might find that the overhead of using a mutable variable would, in most cases, vastly outweigh doing a quick second loop. It would depend on your specific problem, though. I can definitely imagine where there could be cases that you would want to do something like that.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload