rightfold / purescript-postgresql-client

https://pursuit.purescript.org/packages/purescript-postgresql-client
BSD 3-Clause "New" or "Revised" License
35 stars 20 forks source link

Introduce scoped version of `withConnection` #38

Open paluh opened 5 years ago

paluh commented 5 years ago

Currently withConnection can leak Connection value outside of the bracket. Consider adding two versions :

withConnection
    :: forall a
     . Pool
    -> (forall h. Either PGError (Connection h) -> Aff a)
    -> Aff a

and

unsafeWithConnection
    :: forall a h
     . Pool
    -> (Either PGError (Connection h) -> Aff a)
    -> Aff a

The second one should be introduced for convenience as scoped version can cause some troubles regarding type inference and composition.