[Haskell-cafe] Lazy IO.

Jules Bean jules at jellybean.co.uk
Mon Jun 16 09:14:18 EDT 2008

Sebastiaan Visser wrote:
> On Jun 16, 2008, at 2:58 PM, Jules Bean wrote:
>> Sebastiaan Visser wrote:
>>> Does anyone know a pattern in which I can do this easily?
>> Don't use hGetContents on a socket. That's asking for trouble.
> Can you please explain why?

Because it's a broken abstraction.

It's only correct if all you will ever do is read all the data into one 
String and don't care about it after that.

In my experience this is almost never true of sockets : there is always 
protocol overhead, handshaking, and the "next request".

It might be fine for unusually simple socket setups.

> What is a more easier method to spool your HTTP post data to a file than:
>   Bs.hGetContens sock >>= Bs.hPut fd
> ?

Yes, that's fine.

More information about the Haskell-Cafe mailing list