[Haskell-cafe] Space efficiency problem
Adrian Victor CRISCIU
acrisciu at catedra.chfiz.pub.ro
Thu Nov 11 10:09:39 EST 2004
Thanks for the advice. However, though I don't know how ghc manages the heap, I am not sure it is possible to achieve constant heap usage, because a value of type State is a function, and >>= is creating a call stack in this case. I mean, I think that, even if the argument of f :: a -> State s a has a stricness flag, the value m0 :: State s a is itself a function of the state (with type s); then the value ((m0 >>= f) >>= f) >>= .....) >>= f is applied to a state s0, this must be passed down to the bottom of the call stack to perform the actual computation. And this may eat up a lot of heap space.
Do you know what can I do about this?
P.S. I appologize for bothering you, but my programming background is in C, not in Haskell, and I have many "white spots" as far as memory management in functional programming is concerned.
More information about the Haskell-Cafe