MonadMorphIO [Re: Move MonadIO to base]

Anders Kaseorg andersk at MIT.EDU
Fri Apr 23 06:38:35 EDT 2010

On Fri, 23 Apr 2010, Anders Kaseorg wrote:
> • What useful functions should be wrapped with it?  Some candidates are 
> catch, block, unblock (and friends from Control.Exception), forkIO, 
> runInBoundThread, runInUnboundThread, unsafeInterleaveIO, withProgName, 
> withArgs, alloca (and friends from Foreign.Marshal), withMVar, 
> modifyMVar_, modifyMVar.  Then of course there are all the functions that 
> could be wrapped with liftIO…

On the other hand, most of the functions I listed could be easily wrapped 
by the user, given

liftIO0 :: MonadMorphIO m =>
           (forall b. IO b -> IO b) -> m a -> m a
liftIO0 f m = morphIO $ \down -> f (down m)

liftIO1 :: MonadMorphIO m =>
           (forall b. (t -> IO b) -> IO b) -> (t -> m a) -> m a
liftIO1 f g = morphIO $ \down -> f (down . g)


More information about the Libraries mailing list