packages feed

sql-simple-pool (empty) → 0.3.0

raw patch · 4 files changed

+108/−0 lines, 4 filesdep +basedep +data-default-classdep +monad-controlsetup-changed

Dependencies added: base, data-default-class, monad-control, resource-pool, sql-simple, text, time

Files

+ Database/Sql/Simple/Pool.hs view
@@ -0,0 +1,59 @@+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE FlexibleInstances #-}++module Database.Sql.Simple.Pool where++import Control.Applicative+import Control.Monad.Trans.Control+import Data.Typeable+import Data.Default.Class+import Database.Sql.Simple.Internal+import Data.Time.Clock+import qualified Data.Pool as Pool++data Backend b => Pool b = Pool (Pool.Pool b)+    deriving (Typeable)++instance Elem (Pool a) (a ': as)++data PoolConfig = PoolConfig+    { numStripes   :: Int+    , idleTime     :: NominalDiffTime+    , maxResources :: Int+    } deriving (Show, Typeable)++instance Default PoolConfig where+    def = PoolConfig 1 20 100++instance Backend b => Backend (Pool b) where+    data ConnectInfo (Pool b) = ConnectionPool+        { poolConfig  :: PoolConfig+        , connectInfo :: ConnectInfo b +        }+    type ToRow   (Pool b) = ToRow b+    type FromRow (Pool b) = FromRow b++    connect (ConnectionPool PoolConfig{..} ci) = +        Pool <$> Pool.createPool (connect ci) close numStripes idleTime maxResources++    close (Pool p) = Pool.destroyAllResources p++    execute  (Pool p) t q = Pool.withResource p $ \c -> execute  c t q+    execute_ (Pool p) t   = Pool.withResource p $ \c -> execute_ c t+    query    (Pool p) t q = Pool.withResource p $ \c -> query    c t q+    query_   (Pool p) t   = Pool.withResource p $ \c -> query_   c t++    fold  (Pool p) t q a f = Pool.withResource p $ \c -> fold  c t q a f+    fold_ (Pool p) t   a f = Pool.withResource p $ \c -> fold_ c t   a f++withPool :: (Backend b, MonadBaseControl IO m) => Pool b -> (b -> m a) -> m a+withPool (Pool p) = Pool.withResource p++transaction :: Transaction b => Pool b -> (b -> Sql c a) -> Sql c a+transaction p m = withPool p $ \c -> withTransaction c (m c)
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2014 Hirotomo Moriwaki++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ sql-simple-pool.cabal view
@@ -0,0 +1,27 @@+name:                sql-simple-pool+version:             0.3.0+synopsis:            conection pool for sql-simple+-- description:         +license:             MIT+license-file:        LICENSE+author:              HirotomoMoriwaki<philopon.dependence@gmail.com>+maintainer:          HirotomoMoriwaki<philopon.dependence@gmail.com>+Homepage:            https://github.com/philopon/sql-simple+Bug-reports:         https://github.com/philopon/sql-simple/issues+copyright:           (c) 2014 Hirotomo Moriwaki+category:            Database+build-type:          Simple+cabal-version:       >=1.10++library+  exposed-modules:     Database.Sql.Simple.Pool+  build-depends:       base                 >=4.6 && <4.8+                     , text                 >=1.1 && <1.2+                     , sql-simple           >=0.3 && <0.4+                     , data-default-class   >=0.0 && <0.1+                     , resource-pool        >=0.2 && <0.3+                     , time                 >=1.4 && <1.5+                     , monad-control        >=0.3 && <0.4++  ghc-options:         -Wall -O2+  default-language:    Haskell2010