[Haskell-cafe] Too much strictness in binary-

Khudyakov Alexey alexey.skladnoy at gmail.com
Fri Sep 18 16:36:10 EDT 2009


I run into problems with new binary package. Following function reads a list 
of elements one by one until end of stream. List is very long (won't fit into 

In binary- and earlier it read list lazily. Now it seems that it tries 
to read whole list to memory. Program does not produce any output and memory 
usage steadily grows.

> getStream :: Get a -> Get [a]
> getStream getter = do
>   empty <- isEmpty
>   if empty
>     then return []
>     else do x <- getter
>             xs <- getStream getter
>             return (x:xs)

How could I add laziness to this function to revert to old behavior.

  Khudyakov Alexey

More information about the Haskell-Cafe mailing list