make Control.Monad.Instances compilable by nhc98
[haskell-directory.git] / GHC / Weak.lhs
index 1af4b77..5935f18 100644 (file)
@@ -1,5 +1,5 @@
 \begin{code}
-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS_GHC -fno-implicit-prelude #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  GHC.Weak
 --
 -----------------------------------------------------------------------------
 
+-- #hide
 module GHC.Weak where
 
 import GHC.Base
 import Data.Maybe
 import GHC.IOBase      ( IO(..), unIO )
+import Data.Typeable   ( Typeable1(..), mkTyCon, mkTyConApp )
 
 {-|
 A weak pointer object with a key and a value.  The value has type @v@.
@@ -29,10 +31,16 @@ garbage collector, then the value is also alive.  A reference from
 the value to the key does /not/ keep the key alive.
 
 A weak pointer may also have a finalizer of type @IO ()@; if it does,
-then the finalizer will be run once, and once only, at a time after
-the key has become unreachable by the program (\"dead\").  The storage
-manager attempts to run the finalizer(s) for an object soon after the
-object dies, but promptness is not guaranteed.  
+then the finalizer will be run at most once, at a time after the key
+has become unreachable by the program (\"dead\").  The storage manager
+attempts to run the finalizer(s) for an object soon after the object
+dies, but promptness is not guaranteed.  
+
+It is not guaranteed that a finalizer will eventually run, and no
+attempt is made to run outstanding finalizers when the program exits.
+Therefore finalizers should not be relied on to clean up resources -
+other methods (eg. exception handlers) should be employed, possibly in
+addition to finalisers.
 
 References from the finalizer to the key are treated in the same way
 as references from the value to the key: they do not keep the key
@@ -56,6 +64,9 @@ for runnable finalizers before declaring the system to be deadlocked.
 -}
 data Weak v = Weak (Weak# v)
 
+#include "Typeable.h"
+INSTANCE_TYPEABLE1(Weak,weakTc,"Weak")
+
 -- | Establishes a weak pointer to @k@, with value @v@ and a finalizer.
 --
 -- This is the most general interface for building a weak pointer.