Skip to content

Commit 0581122

Browse files
committed
Revive old UnliftIO instance for Hasql Sessions
1 parent 90b883f commit 0581122

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

share-api/src/Share/Postgres/Orphans.hs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import Unison.NameSegment.Internal (NameSegment (..))
4040
import Unison.Server.HistoryComments.Types
4141
import Unison.SyncV2.Types (CBORBytes (..))
4242
import Unison.Syntax.Name qualified as Name
43+
import UnliftIO (MonadUnliftIO (..))
4344

4445
-- Orphans for 'Hash'
4546
instance Hasql.EncodeValue Hash where
@@ -287,11 +288,11 @@ instance Logging.Loggable Hasql.SessionError where
287288

288289
-- | See https://github.com/nikita-volkov/hasql/issues/144
289290
-- This instance won't be added upstream.
290-
-- instance MonadUnliftIO Hasql.Session where
291-
-- withRunInIO inner = do
292-
-- conn <- ask
293-
-- res <- liftIO $ try $ inner $ \sess -> do
294-
-- Hasql.use conn sess >>= either throwIO pure
295-
-- case res of
296-
-- Left e -> throwError e
297-
-- Right a -> pure a
291+
instance MonadUnliftIO Hasql.Session where
292+
withRunInIO inner = do
293+
conn <- ask
294+
res <- liftIO $ try $ inner $ \sess -> do
295+
Hasql.run sess conn >>= either throwIO pure
296+
case res of
297+
Left e -> throwError e
298+
Right a -> pure a

0 commit comments

Comments
 (0)