@@ -155,6 +155,10 @@ defaultConnectInfo = ConnectInfo {
155connect :: ConnectInfo -> IO Connection
155connect :: ConnectInfo -> IO Connection
156connect = connectPostgreSQL . postgreSQLConnectionString
156connect = connectPostgreSQL . postgreSQLConnectionString
158+-- | Memory bracket around 'connect' and 'close'.
159+withConnect :: ConnectInfo -> (Connection -> IO c) -> IO c
160+withConnect connInfo = bracket (connect connInfo) close
158-- | Attempt to make a connection based on a libpq connection string.
162-- | Attempt to make a connection based on a libpq connection string.
159-- See <https://www.postgresql.org/docs/9.5/static/libpq-connect.html#LIBPQ-CONNSTRING>
163-- See <https://www.postgresql.org/docs/9.5/static/libpq-connect.html#LIBPQ-CONNSTRING>
160-- for more information. Also note that environment variables also affect
164-- for more information. Also note that environment variables also affect