Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/docs/bugs/nhc13test8.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


-- FIXED.

{- Heap should not grow.  With nhc13:

nhc13test8 10000

runs out of space.  Whereas with hbc even:

nhc13test8 -H32K 50000

does not.  Also, do a heap profile and see it ramp. -}

import System(getArgs)

data Test = Test !Int

f :: Test -> Int -> Test
f (Test n) i = Test (n+i)

g :: Test -> Int
g (Test n) = n

sfoldl :: Eval a => (a -> b -> a) -> a -> [b] -> a
sfoldl f z [] = z
sfoldl f z (x:xs) = sfoldl f fzx (fzx `seq` xs)
                  where fzx = f z x

main = do argv <- getArgs
          print (g (sfoldl f (Test 0) [1..(read (argv!!0))]))

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].