
20 Feb
2011
20 Feb
'11
1:07 p.m.
On Sun, Feb 20, 2011 at 03:38:17PM +0000, tsuraan wrote:
lazy <- getContents clientSock let (lenBS, rest1) = splitAt 8 lazy let length = runGet getWord64be lenBS let (msg, rest2) = splitAt (fromIntegral length) rest1 -- process msg
The program never uses that initial "lazy" again, but it's there, and it's been assigned, so I assume that reference to the head of the stream will always be around, and thus always consuming memory.
The compiler should be able to figure it out, but if not you could
rewrite the first two lines as:
(lenBS, rest1) <- splitAt 8 `fmap` getContents clientSock
--
Helgi Kristvin Sigurbjarnarson