[Haskell-cafe] Simplest way to move a ... `using` ... line into the IO monad?

Tom Ellis tom-lists-haskell-cafe-2023 at jaguarpaw.co.uk
Fri Oct 27 18:43:07 UTC 2023


On Fri, Oct 27, 2023 at 11:36:53AM -0700, David Banas wrote:
> What is the simplest way to translate a non-monadic line of Haskell code, such as:
> 
> res = map foo xs `using` parList rseq
> 
> For use in the IO monad?
> 
> This doesn’t work:
> 
> res <- mapM fooM xs `using` parTraversable rseq

The docs for Control.Parallel.Strategies say "The parallel tasks
evaluated by a Strategy may have no side effects. For
non-deterministic parallel programming, see Control.Concurrent."[1].
So I guess you should look into Control.Concurrent[2].

Tom

[1] https://www.stackage.org/haddock/lts-21.17/parallel-3.2.2.0/Control-Parallel-Strategies.html#v:using

[2] https://www.stackage.org/haddock/lts-21.17/base-4.17.2.0/Control-Concurrent.html


More information about the Haskell-Cafe mailing list