[Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework
Felipe Lessa
felipe.lessa at gmail.com
Fri Oct 9 11:12:34 EDT 2009
On Thu, Oct 08, 2009 at 12:54:14AM -0700, oleg at okmij.org wrote:
> Actually it is possible to implement all three evaluation orders
> within the same final tagless framework, using the same interpretation
> of types and reusing most of the code save the semantics of lam. That
> is where the three orders differ, by their own definition.
That's really nice, Oleg, thanks! I just wanted to comment that
I'd prefer to write
share :: IO a -> IO (IO a)
share m = mdo r <- newIORef (do x <- m
writeIORef r (return x)
return x)
return (readIORef r >>= id)
which unfortunately needs {-# LANGUAGE RecursiveDo #-} or
some ugliness from mfix
share :: IO a -> IO (IO a)
share m = do r <- mfix $ \r -> newIORef (do x <- m
writeIORef r (return x)
return x)
return (readIORef r >>= id)
Thanks,
--
Felipe.
More information about the Haskell-Cafe
mailing list