StateT space leak

Wojtek Moczydlowski wojtek at cs.cornell.edu
Thu Nov 13 17:19:28 EST 2003


Consider the following program:

module A where

import Control.Monad.State

f :: StateT Int IO ()
f = (sequence_ $ repeat $ return ())

t = runStateT f 0


When t is evaluated under ghci or hugs, the program quickly runs out of heap
memory. What's going on here? Is this inherent in StateT monad? If so, then
this is very surprising, I would expect f to run in constant space for any
sensible monad.

Wojtek



More information about the Haskell mailing list