Reputation: 34934
I want to perform a HTTP request using the simplest way. I decided to use conduits. Here is my main file:
{-# 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"
And .cabal:
executable AAA
main-is: Main.hs
hs-source-dirs: src
build-depends: base ==4.6.*, text ==0.11.*, http-conduit, transformers, bytestring
I can't build it, the error is:
$ cabal build
Building AAA-0.1.0.0...
Preprocessing executable 'AAA' for
AAA-0.1.0.0...
src/Main.hs:6:8:
Could not find module `Data.Conduit.Binary'
Perhaps you meant
Data.Conduit.List (needs flag -package conduit-1.1.4)
Data.Conduit.Lift (needs flag -package conduit-1.1.4)
Use -v to see a list of the files searched for.
I've already installed all the libraries shown in the .cabal file by saying cabal install xxx
.
What's up with this?
Update:
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"
Upvotes: 0
Views: 220
Reputation: 1697
Seems like now you have two (at least) versions of bytestring
installed, and different packages don't agree on which one has to be used.
I suggest reinstalling http-conduit
.
Upvotes: 0
Reputation: 1667
So the problem is that your program imports Data.Conduit.Binary
which isn't installed. It lives in the conduit-extra
package, so you have to add it to your dependencies and install it if you want to use it.
Your main function doesn't actually use it though, so you can just remove the import and it should fix the current error. You will however get a new error when attempting to build since you also import Data.Conduit
which isn't listed in your cabal file either. To fix this error remove the import or add conduit
to your build-depends.
Upvotes: 4