This simple code leaks memory because the stream gets shared:
import qualified Streaming as S
import qualified Streaming.Prelude as S
n = 5000000
main = a >> a
a = S.mapM_ print $ S.take n $ S.enumFrom (0::Int)
The only workaround I have found is to introduce dummy monadic layers:
import qualified Streaming as S
import qualified Streaming.Prelude as S
n = 5000000
main = a >> a
a = S.mapM_ print $ S.take n $ myenumFrom (0::Int)
myenumFrom n = S.effect . return $ do
S.yield n
myenumFrom (n+1)
Are there any better approaches?
This simple code leaks memory because the stream gets shared:
The only workaround I have found is to introduce dummy monadic layers:
Are there any better approaches?