Restore rparWith r0 documented behaviour#34
Conversation
It does not pass with the current implementation of `rparWith`.
I know the implementation of rparWith looks ugly, but the lazy 'Lift' box is necessary, to make sure rparWith has no built-in rseq.
treeowl
left a comment
There was a problem hiding this comment.
This is exactly the same without optimization, but broken with optimization.
|
No it's not the order of the output of the test program changes, depending on the implementation of |
|
The documentation for |
|
@Borgvall thanks for spotting the problem and for the test case! Yes we also need to fix the documentation. Personally I'd also like to have a better understanding of where the original implementation went wrong - @treeowl is there a succinct way to describe the problem that we could put in a comment? It would be nice if |
|
If we adopt my proposed |
|
I tried to reproduce the issue #17 with this branch, using the example code of the report, where I replaced module Main where
import Control.Parallel.Strategies
main :: IO ()
main = do let xs = take 1000 $ product . take 1000 . repeat <$> [1..]
x = product (xs `using` parTraversable rseq)
putStrLn (show x) |
|
#17 was fixed by using |
|
I think this PR can be closed. It's subsumed by #36. |
| LazyBox printWhenEvaluated <- evaluate $ runEval $ do | ||
| let printWhenEvaluated = unsafePerformIO $ putStrLn "Must be printed at the end." | ||
| sparkedResult <- rparWith r0 printWhenEvaluated | ||
| return $ LazyBox sparkedResult |
There was a problem hiding this comment.
Since #3 has been accepted, one can simplify this mess after merge to master:
printWhenEvaluated <- unsafePerformIO (putStrnLn "Must be printed at the end.") `usingIO` rparWith r0
In addition I have added a test case, to prevent this regression in the future.