有功能
httpLBS :: MonadIO m => Request -> m (Response ByteString)
在 Network.HTTP.Simple 模块(doc)中,我想与我的 Ctx 一起传递(以便稍后在集成测试中进行模拟) >数据对象
data Ctx =
Ctx {
token :: String,
httpLBSFunc :: MonadIO m => Request -> m (Response ByteString)
} deriving (Show)
但我遇到此错误:
Prelude> :l Context.hs
[1 of 1] Compiling Context ( Context.hs, interpreted )
Context.hs:19:32: error: Not in scope: type variable ‘m’
|
19 | httpLBSFunc :: MonadIO m => Request -> m (Response B.ByteString)
| ^
Context.hs:19:48: error: Not in scope: type variable ‘m’
|
19 | httpLBSFunc :: MonadIO m => Request -> m (Response B.ByteString)
| ^
Failed, no modules loaded.
如何在我的 Ctx 数据类型中正确定义此方法?
答案 0 :(得分:0)
我没有用实际的Monad IO 代替约束 MonadIO 的缺点,但是对我来说,使其运行就足够了:
data Ctx =
Ctx {
token :: String,
httpLBSFunc :: Request -> IO (Response ByteString)
} deriving (Show)
我什至没有得到它们之间的确切差异