gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 12:55:41 29 4
gpt4 key购买 nike

尝试发出 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 包上有两个相互冲突的版本。尝试ghc-pkg list bytestring。我建议您对代码进行 cabalize 并使用 cabal 沙箱。

另请参阅"Couldn't match expected type with actual type" error when using Codec.BMP

顺便说一句,ghc-7.8 中的错误消息应该更好,请参阅 https://ghc.haskell.org/trac/ghc/ticket/8278

关于haskell - 发出 HTTP 请求时出现类型不匹配错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24248861/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com