Running out of memory in a simple program

Magnus Lindberg f98mali@dd.chalmers.se
Fri, 15 Nov 2002 14:57:58 +0100


Hi again!
Thanks for your help, Malcolm. I added `seq' at two places to prevent
laziness and now I never run out of memory.

instance Monad M where
  return x  = M $ \i -> (x,i)
  M f >>= k = M $ \i -> let (x,i2) = i `seq' f i
                            M f2 = x `seq' k x
                        in f2 i2

(however, I think that just one of the two `seq' should do but if I
remove any single `seq' then I still run out of memory :(  )

Kind regards
  Magnus