[Haskell-cafe] Re: Move MonadIO to base
Heinrich Apfelmus
apfelmus at quantentunnel.de
Wed Apr 21 12:04:33 EDT 2010
Am 21.04.10 05:01, Anders Kaseorg wrote:
> On Tue, 20 Apr 2010, wren ng thornton wrote:
>> -- | The isomorphic Haskell98 version
>> class Monad m => MonadJoinIO m where
>> -- | Embed the IO into the monad m
>> joinIO :: IO (m a) -> m a
>>
>> -- | Extract the IO computation to the top level,
>> -- rendering the m pure from IO.
>> partIO :: m a -> IO (m a)
>>
>> -- | The isomorphisms
>> joinIO' m = morphIO (m >>=)
>> morphIO' f = joinIO (f partIO)
>
> To establish an isomorphism, you also need to define partIO from morphIO.
> For example, I don’t see how I could define
> partIO :: IO a -> IO (ReaderT r IO a)
> that extracts effects into the outer IO, because the effects depend on
> some unknown state of type r.
I think you mean
partIO :: ReaderT r IO a -> IO (ReaderT r IO a)
This does not affect the impossibility of pushing the effect to the
outer IO.
On a side note,
joinIO = join . liftIO
Regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
More information about the Libraries
mailing list