3

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"

エラーのテキストが意味をなさないため、解決方法がわかりません。

4

1 に答える 1

4

bytestringパッケージに競合する 2 つのバージョンがあります。試してみてくださいghc-pkg list bytestring。コードをキャバリゼーションして、カバル サンドボックスを使用することをお勧めします。

Codec.BMP を使用する場合の「予想される型と実際の型を一致させることができませんでした」エラーも参照してください。

ところで、エラー メッセージは の方が優れているはずです。https://ghc.haskell.org/trac/ghc/ticket/8278ghc-7.8を参照してください。

于 2014-06-16T17:30:26.080 に答える