[Haskell-beginners] Control.Exception.bracket-like for MonadIO ?

Olivier Iffrig olivier
Thu Oct 10 08:53:19 UTC 2013


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




More information about the Beginners mailing list