-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
Description
I was trying to use mapsM and chunksOf to go from Stream (Of Word8) to Stream (Of ByteString), and found that consuming even just 200MB was allocating dozens of Gigabytes memory. Discovered that the problem was eagerness. My infinite source (Of Word8) was a series of Steps, which are strict on the Functor (why?). If I use repeats to construct the Stream, then the code behaves sanely again, albeit taking twice as long as using splitsAt by hand since, to add laziness, repeats interleaves pure Effects into the stream. (Which S.each does not do.)
Things to consider:
- Removing bang from
Step(unless there's a good reason for it to have a bang). - Adding a non-strict
Stepconstructor - Adding a lazy version of
S.each(by addingEffects to it likerepeats, or better using another constructor) - Adding a note about this problem, and how to get around it.