Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
MonadBaseControl IO instance for Handlers
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dmitry Dzhus  
View profile  
 More options Feb 5 2012, 4:45 am
From: Dmitry Dzhus <d...@dzhus.org>
Date: Sun, 05 Feb 2012 12:45:13 +0300
Local: Sun, Feb 5 2012 4:45 am
Subject: MonadBaseControl IO instance for Handlers
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gregory Collins  
View profile  
 More options Feb 5 2012, 5:46 am
From: Gregory Collins <g...@gregorycollins.net>
Date: Sun, 5 Feb 2012 11:46:08 +0100
Local: Sun, Feb 5 2012 5:46 am
Subject: Re: MonadBaseControl IO instance for Handlers

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>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jurriën Stutterheim  
View profile  
 More options Feb 5 2012, 9:11 am
From: Jurriën Stutterheim <j.stutterh...@me.com>
Date: Sun, 05 Feb 2012 15:11:33 +0100
Local: Sun, Feb 5 2012 9:11 am
Subject: Re: MonadBaseControl IO instance for Handlers
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »