@@ -14,6 +14,8 @@ module Database.Beam.Postgres.Connection
1414 ( PgRowReadError (.. ), PgError (.. )
1515 , Pg (.. ), PgF (.. )
1616
17+ , runBeamPostgres , runBeamPostgresDebug
18+
1719 , pgRenderSyntax , runPgRowReader , getFields
1820
1921 , withPgDebug
@@ -300,11 +302,16 @@ newtype Pg a = Pg { runPg :: F PgF a }
300302instance MonadIO Pg where
301303 liftIO x = liftF (PgLiftIO x id )
302304
305+ runBeamPostgresDebug :: (String -> IO () ) -> Pg. Connection -> Pg a -> IO a
306+ runBeamPostgresDebug dbg conn action =
307+ withPgDebug dbg conn action >>= either throwIO pure
308+
309+ runBeamPostgres :: Pg. Connection -> Pg a -> IO a
310+ runBeamPostgres = runBeamPostgresDebug (\ _ -> pure () )
311+
303312instance MonadBeam PgCommandSyntax Postgres Pg. Connection Pg where
304- withDatabase conn action =
305- withPgDebug (\ _ -> pure () ) conn action >>= either throwIO pure
306- withDatabaseDebug dbg conn action =
307- withPgDebug dbg conn action >>= either throwIO pure
313+ withDatabase = runBeamPostgres
314+ withDatabaseDebug = runBeamPostgresDebug
308315
309316 runReturningMany cmd consume =
310317 liftF (PgRunReturning cmd consume id )
0 commit comments