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