Generalisation of 'withResource' to allow any instance of MonadCatchIO #1

Merged
merged 1 commit into from May 22, 2011

Conversation

Projects
None yet
2 participants
@informatikr
Contributor

informatikr commented May 22, 2011

Hello Bryan,

thank you for writing and open-sourcing the resource-pool package. I am using it in one of my projects and it is very useful to me. However, I found the type of the withResource function to be too limited for my purpose, so I made some changes which are included in this pull request.

Specifically, I am using resource-pool for pooling database connections inside a "Snap" application (Snap is a Haskell web-framework). Snap provides me with an application-monad which is an instance of MonadCatchIO, so that is the type-class I generalised withResource's type to. This allows me to perform other actions in my application monad between database requests.

There are a couple of open points for me though, on which I would love to hear your opinion:

  • MonadCatchIO is provided by both "mtl" and "transformers". I chose the transformers-version for compatibility with Snap's application monad. I am unsure if there is a consensus in the community which one is "better".
  • High performance is your explicit design goal for resource-pool. I do not know the performace implications of my version versus your original. Perhaps you have some kind of benchmark to measure it?
  • Any critique of my code is welcome, although this sample is so small. :-)

Thanks again and cheers,
Falko

bos added a commit that referenced this pull request May 22, 2011

Merge pull request #1 from informatikr/master
Generalisation of 'withResource' to allow any instance of MonadCatchIO

@bos bos merged commit 2973911 into bos:master May 22, 2011

@bos

This comment has been minimized.

Show comment Hide comment
@bos

bos May 22, 2011

Owner

Thanks! Nice patch. I've integrated it into 0.1.1.0, and if you look at the change history, you'll see that I did very little to your code.

Owner

bos commented May 22, 2011

Thanks! Nice patch. I've integrated it into 0.1.1.0, and if you look at the change history, you'll see that I did very little to your code.

edahlgren referenced this pull request in edahlgren/pool May 31, 2013

Merge pull request #1 from edahlgren/limit-use
Optionally limit max number of times connected to single connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment