#7285: mkWeakMVar is non-compositional
------------------------------+---------------------------------------------
Reporter: edsko | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 7.6.1 | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Testcase:
Blockedby: | Blocking:
Related: |
------------------------------+---------------------------------------------
In base 4.6 `addMVarFinalizer` is deprecated in favour of `mkWeakMVar` of
type
{{{
mkWeakMVar :: MVar a -> IO () -> IO (Weak (MVar a))
}}}
This type makes it inherently non-compositional. For instance, if we have
a larger datatype T that contains an MVar somewhere inside then there in
no way to define mkWeakT in terms of mkWeakMVar; instead, mkWeakT would
have to be defined along the lines of
{{{
mkWeakT :: T a -> IO () -> IO (Weak (T a))
mkWeakT m@(MkT (MVar m#) _) f = IO $ \s ->
case mkWeak# m# m f s of (# s1, w #) -> (# s1, Weak w #)
}}}
It would be better if the type of mkWeakMVar would change to
{{{
mkWeakMVar :: MVar a -> v -> Maybe (IO ()) -> IO (Weak v)
}}}
(i.e., following `mkWeak` rather than `mkWeakPtr`).
(The same comment goes for related functions such as mkWeakIORef.)
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7285>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs