Haskell 发出HTTP请求时出现类型不匹配错误

Haskell 发出HTTP请求时出现类型不匹配错误,haskell,http-conduit,Haskell,Http Conduit,尝试发出HTTP请求时,出现错误: {-# LANGUAGE OverloadedStrings #-} import Network.HTTP.Conduit -- the main module -- The streaming interface uses conduits import Data.Conduit import Data.Conduit.Binary (sinkFile) import qualified Data.ByteString.Lazy as L import

尝试发出HTTP请求时,出现错误:

{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Conduit -- the main module

-- The streaming interface uses conduits
import Data.Conduit
import Data.Conduit.Binary (sinkFile)

import qualified Data.ByteString.Lazy as L
import Control.Monad.IO.Class (liftIO)

main :: IO ()
main = do
    simpleHttp "http://www.example.com/foo.txt" >>= L.writeFile "foo.txt"
错误是:

Couldn't match type `L.ByteString'
                  with `bytestring-0.10.0.2:Data.ByteString.Lazy.Internal.ByteString'
    Expected type: bytestring-0.10.0.2:Data.ByteString.Lazy.Internal.ByteString
                   -> IO ()
      Actual type: L.ByteString -> IO ()
    In the return type of a call of `L.writeFile'
    In the second argument of `(>>=)', namely `L.writeFile "foo.txt"'
    In a stmt of a 'do' block:
      simpleHttp "http://www.example.com/foo.txt"
      >>= L.writeFile "foo.txt"

我不知道如何解决它,因为错误的文本没有真正意义。

您在
bytestring
软件包上有两个冲突的版本。通过testring尝试
ghc pkg列表
。我建议您将代码加密并使用cabal沙箱

另见


顺便说一句,ghc-7.8中的错误信息应该更好,请参见阴谋集团沙箱的

+1。使用项目目录中的
cabal sandbox init
,通过testring/usr/local/ceral/ghc/7.6.3\u 2/lib/ghc-7.6.3/package.conf.d bytestring-0.10.0.2/Users/alex/.ghc/x86\u 64-darwin-7.6.3/package.conf.d bytestring-0.10.4.0--下一步是什么?@alexanderssupertramp查看我链接的另一个答案。它包含两个解决该问题的选项。但是现在,阴谋集团是首选的方式,我把它修好了。但是你是如何意识到你有两个相互冲突的版本…,错误消息并没有暗示这一点,是吗?@AlexanderSupertramp确实如此。请注意,预期的类型是完全限定的,包括包版本
ghc
在错误消息中省略包名,除非它不明确。