[project @ 2001-08-22 11:45:06 by sewardj]
[ghc-hetmet.git] / ghc / tests / lib / should_run / weak001.hs
1 import Addr
2 import Weak
3
4 kill:: Addr -> IO ()
5 kill a = do
6     w <- mkWeakPtr a Nothing
7     addFinalizer a $
8         deRefWeak w >> return ()
9
10 main:: IO ()
11 main = sequence_ . take 10000 . repeat $
12     malloc 100 >>= kill >> return ()
13
14 foreign import malloc :: Int -> IO Addr