为什么这么简单的代码不起作用?
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L
main :: IO ()
main = simpleHttp "http://www.dir.bg/" >>= L.putStr
导致以下错误:
TestConduit.exe:InternalIOException getAddrInfo:不存在 (错误10093)
答案 0 :(得分:15)
您必须使用 withSocketsDo 来初始化套接字。 像这样:
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L
import Network (withSocketsDo)
main :: IO ()
main = withSocketsDo
$ simpleHttp "http://www.dir.bg/" >>= L.putStr