[Haskell-beginners] Space leak debugging

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Fri Jun 4 01:25:16 EDT 2010

On Jun 3, 2010, at 16:18 , Philip Scott wrote:
> that if you replace the 'if' line with
>    if (B.null bs || i== -1) then return 1
> (i never equals -1) then it runs in constant space! That just  
> boggles my mind.

That's your clue:  since adding i there makes it run in constant  
space, you must be forcing its evaluation when it otherwise was just  
building thunks.  So you need to make i strict with seq or case.

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/beginners/attachments/20100604/118366b7/PGP.bin

More information about the Beginners mailing list