Missing instances for ResourceT in conduit

2019-07-24 02:49发布

问题:

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?