On Apr 27, 2008, at 10:05 AM, Jake Mcarthur wrote:
On Apr 27, 2008, at 9:36 AM, Conal Elliott wrote:
I think we *do* want unsafeNewEmptyTMVar inlined. Here's a
convenient caching wrapper:
cached :: STM a -> TIVal a
cached m = TIVal m (unsafePerformIO newEmptyTMVarIO)
Yes, this is essentially what I am working with in Reaction at the
moment.
Actually, that is not quite what I have been doing. Here is what I had:
cachedFuture :: STM (a, Time) -> Future a
cachedFuture stm = unsafePerformIO $ return . Future stm =<<
newEmptyTMVarIO
{-# NOINLINE cachedFuture #-}
(Clearly I am skipping right past an implementation of TIVals, despite
the fact that they may be useful as a separate abstraction. This is
just laziness.)
If I replace the above with...
cachedFuture :: STM (a, Time) -> Future a
cachedFuture stm = Future stm (unsafePerformIO newEmptyTMVarIO)
then my test program hangs, with or without the NOINLINE pragma. I
can't guess why because, like I already said, I haven't yet thought
all the way through the relationship between unsafePerformIO and
NOINLINE.
- Jake
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe