[Haskell-cafe] Plug space leak with seq. How?

Daniel Fischer daniel.is.fischer at googlemail.com
Thu Jun 9 18:32:17 CEST 2011


On Thursday 09 June 2011, 18:09:44, Yves Parès wrote:
> Is it not:
> > noLeak :: State Int ()
> > noLeak = do
> >
> >   a <- get
> 
> *>*  * let a' = (a + 1)
> 
> >   a' `seq` put a'*
> >   noLeak
> 
> ??

Alternatively,

noLeak = do
  a <- get
  a `seq` put (a+1)
  noLeak

or

noLeak = do
  a <- get
  put $! a+1
  noLeak

should eliminate the leak too.



More information about the Haskell-Cafe mailing list