X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FMem%2FWeak.hs;h=6a092e0347e873d56d7174377d1dd4b758714f6c;hb=a69d9d666f8fdb5b11275bda034c5c2f1c5a43d8;hp=09c095dfc8198e4efee2299e30d0940f57069400;hpb=d826359344d88e4c9b4b902c4a8cc6165728f016;p=ghc-base.git diff --git a/System/Mem/Weak.hs b/System/Mem/Weak.hs index 09c095d..6a092e0 100644 --- a/System/Mem/Weak.hs +++ b/System/Mem/Weak.hs @@ -8,7 +8,7 @@ -- Stability : experimental -- Portability : non-portable -- --- $Id: Weak.hs,v 1.1 2001/06/28 14:15:04 simonmar Exp $ +-- $Id: Weak.hs,v 1.2 2001/09/13 11:36:52 simonmar Exp $ -- -- Weak references, weak pairs, weak pointers, and finalizers. -- @@ -30,14 +30,16 @@ module System.Mem.Weak ( import Prelude -#include "Dynamic.h" -INSTANCE_TYPEABLE0(Weak,weakTc,"Weak") +import Data.Dynamic #ifdef __GLASGOW_HASKELL__ import GHC.Base import GHC.IOBase import GHC.Weak +#include "Dynamic.h" +INSTANCE_TYPEABLE1(Weak,weakTc,"Weak") + deRefWeak :: Weak v -> IO (Maybe v) deRefWeak (Weak w) = IO $ \s -> case deRefWeak# w s of @@ -54,3 +56,4 @@ finalize (Weak w) = IO $ \s -> (# s1, 0#, _ #) -> (# s1, () #) -- already dead, or no finaliser (# s1, _, f #) -> f s1 #endif +