&引用;InternalIOException getAddrInfo:不存在(错误10093)";在Windows 8上

&引用;InternalIOException getAddrInfo:不存在(错误10093)";在Windows 8上,windows,http,haskell,conduit,http-conduit,Windows,Http,Haskell,Conduit,Http Conduit,为什么这么简单的代码不起作用 import Network.HTTP.Conduit import qualified Data.ByteString.Lazy as L main :: IO () main = simpleHttp "http://www.dir.bg/" >>= L.putStr 它会导致以下错误: TestConductor.exe:InternalIOException getAddrInfo:不存在 (错误10093) 您必须使用with socket

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

import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L

main :: IO ()
main = simpleHttp "http://www.dir.bg/" >>= L.putStr
它会导致以下错误:

TestConductor.exe:InternalIOException getAddrInfo:不存在 (错误10093)


您必须使用with socketsdo来初始化套接字。 像这样:

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

实际上,无论是否在Windows上,您都应该始终将
与SocketSDO一起使用。那你就永远不会有这个问题了。:-)我很好奇为什么这种初始化不是在幕后进行的,也不是自动按需进行的?@theu Ghost或设计成这样,好的类型代码不会爆炸,对吗?在哈斯凯尔真的没有理由做这种事。是的,但我们可以放很多其他的东西。我们可以在零件上使用SOCKETSDO刹车,让人们每次都初始化它。我认为这是没有道理的。如果有一种方法可以让人们隐式地编写更正确的代码,那就更好了。谢谢你帮我解决了这个问题。