
On April 16, 2010 01:46:43 wren ng thornton wrote:
wren ng thornton wrote:
Anders Kaseorg wrote:
class Monad m => MonadMorphIO m where morphIO :: (forall b. (m a -> IO b) -> IO b) -> m a
[...] Putting these together, your class means: if you can construct/eliminate an (F m a) in the IO category, then you can construct an (m a) in the Hask category. I.e., IO(m a) is a subset of (m a).
Which is more general than liftIO which only says (IO a) is a subset of (m a). That is, liftIO requires that the non-IO layers of m are constructed via `return`, whereas morphIO permits non-pointed use of IO. In other words, liftIO only allows lifting "effectful" values, whereas morphIO also allows lifting "structural" values.
Are you then saying that liftIO should be able to be defined via morphIO? I would be curious to see that as, after a bit of trying, I still can't see how to. Specifically, I can't capture the results of the desired IO operation. If it is complementary to liftIO, and not strictly more powerful, maybe it should be named lowerIO because it's function seems to be that it gives the ability to lower (or push) a computation down onto the IO layer. Cheers! -Tyson