为什么这么简单的代码不起作用?
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)
你必须使用 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