我正在尝试使用stm-conduit中的MergeSources函数,该函数具有以下签名:
mergeSources :: (MonadResource mi, MonadIO mo, MonadUnliftIO mi)
=> [ConduitT () a mi ()] -- ^ The sources to merge.
-> Int -- ^ The bound of the intermediate channel.
-> mo (ConduitT () a mi ())
我有直接基于IO的资源,而且我不知道该如何继续前进,我认为ResourceT是候选对象:
所以我有以下签名的来源:
ConduitT () (Connection,WorkspaceId) IO ()
,我想要这个签名:
ConduitT () (Connection,WorkspaceId) (ResourceT IO) ()
尽管我没有足够的资源来处理这些操作(我有一个连接,但它是全局的,这是他们的建议...),但我还是举一个我想使用的功能的示例
streamAllWorkspaceAlreadyCreated :: Connection -> ConduitT () (Connection,WorkspaceId) IO ()
streamAllWorkspaceAlreadyCreated eventStoreConnection = do
yield eventStoreConnection
.| WorkspaceStream.streamAll
.| WorkspaceStream.discardCorruptedStreams
.| mapC (\workSpaceId -> (eventStoreConnection,workSpaceId))
答案 0 :(得分:0)
transPipe
:https://hackage.haskell.org/package/conduit-1.3.1/docs/Data-Conduit.html#v:transPipe
transPipe :: Monad m => (forall a. m a -> n a) -> ConduitT i o m r -> ConduitT i o n r
transPipe liftIO :: ConduitT i o IO r -> ConduitT i o (ResourceT IO) r