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 <helgikrs (at) gmail (dot) com>

Attachment: pgpLTAoRWhfzK.pgp
Description: PGP signature

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to