Control.Exception.bracket-like for MonadIO ?

Hello, I'm trying to build an application with a monad encapsulating its state, environment, ... For the sake of simplicity, let's say data MyState type Main = StateT MyState IO But I would like to use something like bracket with my Main monad, and I did not find how to to it. I'm looking for something like bracket' :: MonadIO m => m a -> (a -> m b) -> (a -> m c) -> m c or in my case myBracket :: Main a -> (a -> Main b) -> (a -> Main c) -> Main c Searching for that on hoogle did not give me anything interesting... Did someone encounter this problem, and have a solution ? -- Olivier

I'd recommend checking out Control.Exception.Lifted from lifted-base:
http://haddocks.fpcomplete.com/fp/7.4.2/20130922-179/lifted-base/Control-Exc...
On Thu, Oct 10, 2013 at 11:53 AM, Olivier Iffrig
Hello,
I'm trying to build an application with a monad encapsulating its state, environment, ... For the sake of simplicity, let's say
data MyState type Main = StateT MyState IO
But I would like to use something like bracket with my Main monad, and I did not find how to to it.
I'm looking for something like bracket' :: MonadIO m => m a -> (a -> m b) -> (a -> m c) -> m c
or in my case myBracket :: Main a -> (a -> Main b) -> (a -> Main c) -> Main c
Searching for that on hoogle did not give me anything interesting... Did someone encounter this problem, and have a solution ?
-- Olivier
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Michael Snoyman wrote (2013-10-10 11:03:06 +0200):
I'd recommend checking out Control.Exception.Lifted from lifted-base:
http://haddocks.fpcomplete.com/fp/7.4.2/20130922-179/lifted-base/Control-Exc...
Thanks, that seems to be what I was looking for. I didn't know about this package, and did not have the time to test yet, but I guess it will fit perfectly. -- Olivier
participants (2)
-
Michael Snoyman
-
Olivier Iffrig