This code doesn't typecheck:
import Network.HTTP.Conduit
import qualified Data.ByteString.Char8 as BS
main :: IO ()
main = do
resp <- simpleHttp "http://www.google.com"
putStrLn $ BS.unpack resp
Throws the following error:
Couldn't match expected type `BS.ByteString'
with actual type `Data.ByteString.Lazy.Internal.ByteString'
In the first argument of `BS.unpack', namely `resp'
In the second argument of `($)', namely `BS.unpack resp'
In a stmt of a 'do' block: putStrLn $ BS.unpack resp
Failed, modules loaded: none.
How to fix this ? Changing to other ByteString variant doesn't work.
The type of simpleHttp
function is like this: simpleHttp
:: Control.Monad.IO.Class.MonadIO m =>
String -> m Data.ByteString.Lazy.Internal.ByteString
. So I try to get the ByteString within the IO monad and try to unpack
it, but this results in an error.