Skip to content

Instantly share code, notes, and snippets.

@ion1
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save ion1/aaa5d1a840ed4f8dc4c0 to your computer and use it in GitHub Desktop.

Select an option

Save ion1/aaa5d1a840ed4f8dc4c0 to your computer and use it in GitHub Desktop.
addFinalizer (1 :: Integer)
% ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.1
% ghc -ignore-dot-ghci -e 'let f x = System.Mem.Weak.addFinalizer x (putStrLn ("bye " ++ show x)) in mapM_ f [-10..10 :: Integer] *> System.Mem.performGC *> Control.Concurrent.threadDelay 1000000'
bye 10
bye 9
bye 8
bye 7
bye 6
bye 5
bye 4
bye 3
bye 2
bye 0
bye -1
bye -2
bye -3
bye -4
bye -5
bye -6
bye -7
bye -8
bye -9
bye -10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment