I have the following code with a pipe which is ok without the second pipe (>-> P.mapM ( fillMD5)
). fillMD5
is an operation a -> IO a
.
runSafeT $ runEffect $
every (senseRecursive5 startfpo)
>-> P.mapM ( fillMD5)
>-> P.map fp2rdf
>-> toNTriple houtfile
The error is :
Couldn't match type `IO' with `Pipes.Safe.SafeT IO'
Expected type: Pipes.Safe.SafeT IO ()
Actual type: IO ()
In the second argument of `($)', namely
`runEffect
I understand that the type of mapM
is
mapM :: Monad m => (a -> m b) -> Pipe a b m r
but I do not see how to lift this into Safe.SafeT
?
SafeT
is a monad transformer, and soSafeT IO
is a composite monad withIO
wrapped inSafeT
. To usefillMD5
, you need to lift the computation it produces to the composite monad usinglift
(from theMonadTrans
class):As
fillMD5
produces anIO
action, you can also useliftIO
, which comes from theMonadIO
instance ofSafeT
: