Closed Olathe closed 14 years ago
While it's true that you need to use withSocketsDo, this needs to be an application-wide action, not performed by this library. This is documented along with withHttpEnumerator: http://hackage.haskell.org/packages/archive/http-enumerator/0.2.0.2/doc/html/Network-HTTP-Enumerator.html#v:withHttpEnumerator
It's just one of those unfortunate annoyances of Windows programming.
It is mentioned there for sure, but I'm referring more to the two examples at the top of the documentation, which are full but admittedly-short applications.
If a Windows programmer was trying out this package and went to the docs and saw these two examples, they'd try them out verbatim and get a very unhelpful error message that they might not be able to or have the motivation to figure out, which could tarnish their impression of http-enumerator.
Wrapping those two example apps with withSocketsDo
would solve this problem and get new people into the habit of using an application-wide withSocketsDo
all in one step.
Perhaps -- Just download an HTML document and print it. import Network.HTTP.Enumerator import Network.Socket import qualified Data.ByteString.Lazy as L
main = withSocketsDo putHaskellWebsite
putHaskellWebsite = simpleHttp "http://www.haskell.org/" >>= L.putStr
Good idea. I'm uploading a new version of the package with a better explanation of this.
The initial examples (downloading www.haskell.org with
simpleHttp
and saving google.com to a file) don't work on Windows because they're missingwithSocketsDo
.It was very hard for me to figure out what was going on because the error message made it seem like the hostname couldn't be resolved. Could you please correct the documentation?
edit: Found out that
withSocketsDo
is the responsibility of the library user rather than the library