以下功能没有进行类型检查:
import qualified Control.Exception as E
import Data.Conduit (ResourceT)
import Network.HTTP.Types (Method, Status(..))
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy.Char8 as LBS
doHttps :: Method -> String
-> Maybe (RequestBody (ResourceT IO))
-> IO (Either E.SomeException (Response LBS.ByteString))
doHttps reqMethod url body = undefined
它会产生以下错误:
RequestBody is applied to too many type arguments
In the type signature for `doHttps':
doHttps :: Method
-> String
-> Maybe (RequestBody (ResourceT IO))
-> IO (Either E.SomeException (Response LBS.ByteString))
Failed, modules loaded: none.
doHttps
函数是this function的简化版本。但显然模块中的原始功能是typechecks,但上面的代码片段不起作用。为什么会这样?
答案 0 :(得分:4)
不同版本的http-conduit库。在版本1. *中,RequestBody采用了类型参数:
http://hackage.haskell.org/package/http-conduit-1.9.6/docs/Network-HTTP-Conduit.html#t:RequestBody
但是,在版本2. *中,它不带类型参数:
http://hackage.haskell.org/package/http-conduit-2.0.0/docs/Network-HTTP-Conduit.html#t:RequestBody