我有一些pipes-concurrency
看起来像这样的代码:
-- this won't compile but will give you the gist of what's happening
pipeline :: MonadIO m => Consumer a m ()
main = do
(output, input) <- spawn Unbounded
async $ do runEffect $ fromInput input >-> pipeline
performGC
-- skipped the `output` pipeline code.
问题 1:这显然不会编译,因为runEffect
will returnMonadIO m => m ()
和async
requires IO a
。有没有办法做到这一点?还是我被困在强迫我的管道包含 IO monad 中的效果?
问题 2:在实现 MonadIO 的 Monad 中嵌入异步是否有意义?不确定我是否在这里很好地表达了自己。
谢谢!