Missing instances for ResourceT in conduit

偶尔善良 提交于 2019-12-24 05:06:05

问题


I'm getting a strange error when trying to use ResourceT from conduit 1.0.9.1. I'm missing instances from the documentation. For example

import Control.Monad
import Control.Monad.Trans
import Control.Monad.IO.Class
import Data.Conduit

test = runResourceT (lift $ print "Hello world")

fails with No instance for (MonadTrans ResourceT) arising from a use of lift, although there are many instances in the docs, including MonadTrans ResourceT. Checking REPL confirms the problem:

Prelude> :m Data.Conduit
Prelude Data.Conduit> :i ResourceT
newtype ResourceT m a
  = Control.Monad.Trans.Resource.Internal.ResourceT ...
-- Defined in `Control.Monad.Trans.Resource.Internal'
instance Monad m => Monad (ResourceT m)
  -- Defined in `Control.Monad.Trans.Resource.Internal'
instance Functor m => Functor (ResourceT m)
  -- Defined in `Control.Monad.Trans.Resource.Internal'
instance MonadThrow m => MonadThrow (ResourceT m)
  -- Defined in `Control.Monad.Trans.Resource.Internal'
instance MonadBaseControl b m => MonadBaseControl b (ResourceT m)
  -- Defined in `Control.Monad.Trans.Resource.Internal'

This seems like some stupid mistake on my side, but I can't figure it out. Where are the missing instances?

来源:https://stackoverflow.com/questions/20121467/missing-instances-for-resourcet-in-conduit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!