Hi,
I wrote a little routine to run a bunch of computations in parallel using
pipes like this
type Generator a b m = (Monad m) => a -> Producer b m ()
type Worker b c m = (Monad m) => Pipe b c m ()
type Sync c m = (Monad m) => Consumer c m ()
runWorkers n a g w s = do
(output, input) <- liftIO $ spawn Unbounded
(output', input') <- liftIO $ spawn Unbounded
inp <- async $ do
runEffect $ (g a) >-> toOutput output
liftIO performGC
out <- async $ do
runEffect $ fromInput input' >-> s
liftIO performGC
workers <- forM [1..n] $ \_ ->
async $ do
runEffect $ fromInput input >-> w >-> toOutput output'
liftIO performGC
mapM_ wait (inp:out:workers)
and now I want to use Pipes.Safe.Prelude's withFile in one of my generators.
But when I tried to do
PSP.runSafeT $ runWorkers
I get the error
No instance for (MonadBaseControl IO (PS.SafeT IO))
arising from a use of `runWorkers'
Possible fix:
add an instance declaration for (MonadBaseControl IO (PS.SafeT IO))
and trying to fix this led me into a whole bunch of other problems.
What is the preferred way to do this kind of thing?
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].