resourcet-pool (empty) → 0.1.0.0
raw patch · 5 files changed
+88/−0 lines, 5 filesdep +basedep +resource-pooldep +resourcet
Dependencies added: base, resource-pool, resourcet
Files
- CHANGELOG.md +5/−0
- LICENSE +11/−0
- README.md +11/−0
- resourcet-pool.cabal +46/−0
- src/Data/Pool/Acquire.hs +15/−0
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# `resourcet-pool`++## `0.1.0.0`++Initial release
+ LICENSE view
@@ -0,0 +1,11 @@+Copyright 2020 Brandon Chinn++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,11 @@+# `resourcet-pool`++`resource-pool` provides the `Pool` abstraction, which performs resource allocation. Independently, `resourcet` provides the `Acquire` abstraction, which also performs resource allocation, but also plugs into the `MonadResource` type class. This library provides a way of converting a `Pool` into an `Acquire`, if using `Acquire` functions is easier for your application.++This library exports a single function++```hs+poolToAcquire :: Pool a -> Acquire a+```++which pretty much does what it says on the box.
+ resourcet-pool.cabal view
@@ -0,0 +1,46 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.33.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 1b862e7a73b6b38f086f0ef3bae91f62384f6a84ee5556c672ea421b013cb22f++name: resourcet-pool+version: 0.1.0.0+synopsis: A small library to convert a Pool into an Acquire+description: A small library to convert a Pool into an Acquire, allowing+ one to use the `resourcet` framework with a resource exported+ as a `Pool`.+category: Data, Database, Network, Conduit+homepage: https://github.com/brandonchinn178/resourcet-pool#readme+bug-reports: https://github.com/brandonchinn178/resourcet-pool/issues+maintainer: Brandon Chinn <brandonchinn178@gmail.com>+license: BSD3+license-file: LICENSE+build-type: Simple+extra-source-files:+ README.md+ CHANGELOG.md++source-repository head+ type: git+ location: https://github.com/brandonchinn178/resourcet-pool++library+ exposed-modules:+ Data.Pool.Acquire+ other-modules:+ Paths_resourcet_pool+ hs-source-dirs:+ src+ ghc-options: -Wall+ build-depends:+ base >=4.9 && <5+ , resource-pool >=0.2.1.0 && <0.3+ , resourcet >=1.1.2 && <2+ if impl(ghc >= 8.0)+ ghc-options: -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wnoncanonical-monad-instances+ if impl(ghc < 8.8)+ ghc-options: -Wnoncanonical-monadfail-instances+ default-language: Haskell2010
+ src/Data/Pool/Acquire.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE LambdaCase #-}++module Data.Pool.Acquire (poolToAcquire) where++import Data.Pool (Pool, destroyResource, putResource, takeResource)+import Data.Acquire (Acquire, ReleaseType(..), mkAcquireType)++-- | Convert a 'Pool' into an 'Acquire'.+poolToAcquire :: Pool a -> Acquire a+poolToAcquire pool = fst <$> mkAcquireType getResource freeResource+ where+ getResource = takeResource pool+ freeResource (resource, localPool) = \case+ ReleaseException -> destroyResource pool localPool resource+ _ -> putResource localPool resource