10

为什么这么简单的代码不起作用?

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)

4

1 回答 1

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
于 2013-10-03T12:50:23.170 回答