X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FMem%2FWeak.hs;h=62495fc3f4ee8a0f8b15420e0f362b8136c33cc4;hb=f7a485978f04e84b086f1974b88887cc72d832d0;hp=09c095dfc8198e4efee2299e30d0940f57069400;hpb=7f1f4e7a695c402ddd3a1dc2cc7114e649a78ebc;p=ghc-base.git diff --git a/System/Mem/Weak.hs b/System/Mem/Weak.hs index 09c095d..62495fc 100644 --- a/System/Mem/Weak.hs +++ b/System/Mem/Weak.hs @@ -1,15 +1,13 @@ ----------------------------------------------------------------------------- --- +-- | -- Module : System.Mem.Weak -- Copyright : (c) The University of Glasgow 2001 --- License : BSD-style (see the file libraries/core/LICENSE) +-- License : BSD-style (see the file libraries/base/LICENSE) -- -- Maintainer : libraries@haskell.org -- Stability : experimental -- Portability : non-portable -- --- $Id: Weak.hs,v 1.1 2001/06/28 14:15:04 simonmar Exp $ --- -- Weak references, weak pairs, weak pointers, and finalizers. -- ----------------------------------------------------------------------------- @@ -30,14 +28,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 +54,4 @@ finalize (Weak w) = IO $ \s -> (# s1, 0#, _ #) -> (# s1, () #) -- already dead, or no finaliser (# s1, _, f #) -> f s1 #endif +