Skip to content

Commit d9eee92

Browse files
committed
Add an instance declaration for Data.Pool
1 parent 5b63dcd commit d9eee92

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Network/Wai/Session/PostgreSQL.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# LANGUAGE FlexibleInstances #-}
2+
13
module Network.Wai.Session.PostgreSQL
24
( clearSession
35
, dbStore
@@ -19,6 +21,7 @@ import Control.Monad
1921
import Control.Monad.IO.Class
2022
import Data.Default
2123
import Data.Int (Int64)
24+
import Data.Pool (Pool, withResource)
2225
import Data.Serialize (encode, decode, Serialize)
2326
import Data.String (fromString)
2427
import Data.Time.Clock.POSIX (getPOSIXTime)
@@ -88,6 +91,9 @@ instance WithPostgreSQLConn SimpleConnection where
8891
withPostgreSQLConn (SimpleConnection (mvar, conn)) =
8992
bracket (takeMVar mvar >> return conn) (\_ -> putMVar mvar ())
9093

94+
instance WithPostgreSQLConn (Pool Connection) where
95+
withPostgreSQLConn = withResource
96+
9197
qryCreateTable1 :: Query
9298
qryCreateTable1 = "CREATE TABLE wai_pg_sessions (id bigserial NOT NULL, session_key character varying NOT NULL, session_created_at bigint NOT NULL, session_last_access bigint NOT NULL, session_invalidate_key boolean NOT NULL DEFAULT false, CONSTRAINT session_pkey PRIMARY KEY (id), CONSTRAINT session_session_key_key UNIQUE (session_key)) WITH ( OIDS=FALSE );"
9399

wai-session-postgresql.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ library
2626
, data-default >= 0.5.3 && < 0.6
2727
, entropy >= 0.3.7 && < 0.4
2828
, postgresql-simple >= 0.4.10 && < 0.6
29+
, resource-pool >= 0.2.3 && < 0.3
2930
, text >= 1.2.1 && < 1.3
3031
, time >= 1.5.0 && < 1.6
3132
, transformers >= 0.4.2 && < 0.5

0 commit comments

Comments
 (0)