[prev in list] [next in list] [prev in thread] [next in thread]
List: haskell-cafe
Subject: Re: [Haskell-cafe] Plug space leak with seq. How?
From: Alexey Khudyakov <alexey.skladnoy () gmail ! com>
Date: 2011-06-10 9:11:24
Message-ID: 4DF1DFBC.8060701 () gmail ! com
[Download RAW message or body]
>
> forever a = a>> forever a
>
> doesn't tie to itself without optimisations, so my guess is that it gets
> expanded when you run/eval/execState it in ghci, building the thunk
>
> a>> a>> a>> a>> ...
>
> If you define
>
> forever' a = let a' = a>> a' in a'
>
> the variant using forever' runs in constant space in ghci.
> This, like the explicit recursion, builds a cyclic structure, hence avoids
> the leak.
I see. It's difficult to reason about space complexity in presence of
optimizer.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic