I've made an attempt to port Snap to monad-control, but it broke the entire framework in non-obvious ways. It is possible to define a `MonadControlIO` instance for `Handler`, though (monad-control-0.2.x). That would allow you to use the original resource-pool. I didn't get around to writing instances for the latest version of monad-control though (I decided to switch back to `MonadCatchIO` instead). Here's the code I had for `MonadControlIO`:
#if MIN_VERSION_monad_control(0,3,0)
#else
instance MonadControlIO (Handler b v) where
liftControlIO f = liftBase (f return)
#endif
Jurriën
On 5 Feb 2012, at 11:46, Gregory Collins wrote:
> On Sun, Feb 5, 2012 at 10:45 AM, Dmitry Dzhus <d
...@dzhus.org> wrote:
> How are you gentlemen?
> I'd like to switch to using Pool from resource-pool [1] package in my
> snaplet [2] to handle database connection pool. This requires my
> Handlers to have MonadBaseControl IO instance, whereas Snap provides
> MonadCatchIO. Seems like using resource-pool-catchio fork [3] could do
> the trick, but is there any chance to see MonadBaseControl support in
> Snap?
> [1]: http://hackage.haskell.org/package/resource-pool
> [2]: https://github.com/dzhus/snap-redis-crud/blob/master/src/RedisDB.hs
> [3]: http://hackage.haskell.org/package/resource-pool-catchio
> I think one of Jurriën or Jasper was working on it, but it's actually not easy to do; there are little wrinkles in our MonadCatchIO instance which MonadBaseControl doesn't support. You're better off just lifting to IO and running your database code there.
> G
> --
> Gregory Collins <g...@gregorycollins.net>