Compare commits

..

No commits in common. "901e931af48a43c7ce32d9ccecd3f7321f91b9eb" and "341971d3f35901fc7b9dc318a8fac75a89b11d26" have entirely different histories.

9 changed files with 60 additions and 73 deletions

View File

@ -259,59 +259,59 @@ the api of [`node-postgres`]:
- release clients with [`Pool.release`] or [`Pool.destroy`]
- release with [`Pool.end`]
[`Pool`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Pool#t:Pool
[`Config`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Pool#t:Config
[`Pool.make`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Pool#v:make
[`Pool.end`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Pool#v:end
[`Pool.connect`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Pool#v:connect
[`Pool.destroy`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Pool#v:destroy
[`Pool.release`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Pool#v:release
[`Pool`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Pool#t:Pool
[`Config`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Pool#t:Config
[`Pool.make`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Pool#v:make
[`Pool.end`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Pool#v:end
[`Pool.connect`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Pool#v:connect
[`Pool.destroy`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Pool#v:destroy
[`Pool.release`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Pool#v:release
[`Client`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Client#t:Client
[`Client.end`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Client#v:end
[`Client.make`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Client#v:make
[`Client.connected`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Client#v:connected
[`Client.query`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Client#v:query
[`Client.queryRaw`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Client#v:queryRaw
[`Client.exec`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Effect.Aff.Postgres.Client#v:exec
[`Client`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Client#t:Client
[`Client.end`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Client#v:end
[`Client.make`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Client#v:make
[`Client.connected`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Client#v:connected
[`Client.query`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Client#v:query
[`Client.queryRaw`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Client#v:queryRaw
[`Client.exec`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Effect.Aff.Postgres.Client#v:exec
[`Range`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Range#t:Range
[`Range.gt`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Range#v:gt
[`Range.gte`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Range#v:gte
[`Range.lt`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Range#v:lt
[`Range.lte`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Range#v:lte
[`Range`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Range#t:Range
[`Range.gt`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Range#v:gt
[`Range.gte`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Range#v:gte
[`Range.lt`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Range#v:lt
[`Range.lte`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Range#v:lte
[`Raw`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Raw#t:Raw
[`Null`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Raw#t:Null
[`Raw`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Raw#t:Raw
[`Null`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Raw#t:Null
[`Serialize`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres#t:Serialize
[`Deserialize`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres#t:Deserialize
[`Rep`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres#t:Rep
[`modifyPgTypes`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres#v:modifyPgTypes
[`Serialize`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres#t:Serialize
[`Deserialize`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres#t:Deserialize
[`Rep`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres#t:Rep
[`modifyPgTypes`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres#v:modifyPgTypes
[`Result`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Result#t:Result
[`FromRow`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Result#t:FromRow
[`FromRows`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Result#t:FromRows
[`Result`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Result#t:Result
[`FromRow`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Result#t:FromRow
[`FromRows`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Result#t:FromRows
[`Query`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Query#t:Query
[`AsQuery`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Query#t:AsQuery
[`Query`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Query#t:Query
[`AsQuery`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Query#t:AsQuery
[`Query.Builder`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Query.Builder#t:Builder
[`Query.Builder.param`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Query.Builder#v:param
[`Query.Builder.build`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Data.Postgres.Query.Builder#v:build
[`Query.Builder`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Query.Builder#t:Builder
[`Query.Builder.param`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Query.Builder#v:param
[`Query.Builder.build`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Data.Postgres.Query.Builder#v:build
[`MonadCursor`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#t:MonadCursor
[`MonadSession`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#t:MonadSession
[`CursorT`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#t:CursorT
[`SessionT`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#t:SessionT
[`PostgresT`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#t:PostgresT
[`cursor`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#v:cursor
[`session`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#v:session
[`transaction`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#v:transaction
[`runPostgres`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#v:runPostgres
[`query`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#v:query
[`exec`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#v:exec
[`exec_`]: https://pursuit.purescript.org//////////////////////////////////////////////////////packages/purescript-postgresql/2.0.11/Control.Monad.Postgres#v:exec_
[`MonadCursor`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#t:MonadCursor
[`MonadSession`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#t:MonadSession
[`CursorT`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#t:CursorT
[`SessionT`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#t:SessionT
[`PostgresT`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#t:PostgresT
[`cursor`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#v:cursor
[`session`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#v:session
[`transaction`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#v:transaction
[`runPostgres`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#v:runPostgres
[`query`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#v:query
[`exec`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#v:exec
[`exec_`]: https://pursuit.purescript.org////////////////////////////////////////////packages/purescript-postgresql/2.0.1/Control.Monad.Postgres#v:exec_
[`node-postgres`]: https://node-postgres.com/
[`pg-types`]: https://github.com/brianc/node-pg-types/

View File

@ -25,7 +25,6 @@ workspace:
- newtype: ">=5.0.0 <6.0.0"
- node-buffer: ">=9.0.0 <10.0.0"
- node-event-emitter: ">=3.0.0 <4.0.0"
- node-fs: ">=9.1.0 <9.2.0"
- node-stream-pipes: ">=2.1.0 <3.0.0"
- node-streams: ">=9.0.0 <10.0.0"
- nullable: ">=6.0.0 <7.0.0"
@ -732,8 +731,8 @@ packages:
- unsafe-coerce
node-stream-pipes:
type: registry
version: 2.1.4
integrity: sha256-/DyKe03WTu5e4EJ5Ym7lvRhakhztLtNhy8fccE8+Ouw=
version: 2.1.1
integrity: sha256-j7ZE+Vtc9gwXlH8s8pyVsbbCMd91AIRk05IOsZAO7x0=
dependencies:
- aff
- arrays

View File

@ -1,7 +1,7 @@
package:
name: postgresql
publish:
version: '2.0.11'
version: '2.0.1'
license: 'GPL-3.0-or-later'
location:
githubOwner: 'cakekindel'
@ -54,7 +54,6 @@ package:
- typelevel-prelude: ">=7.0.0 <8.0.0"
- unlift: ">=1.0.1 <2.0.0"
- unsafe-coerce: ">=6.0.0 <7.0.0"
- node-fs: ">=9.1.0 <9.2.0"
test:
main: Test.Main
dependencies:

View File

@ -71,7 +71,8 @@ class (Monad m, MonadSession session, MonadCursor cursor ct) <= MonadPostgres m
cursorWith :: forall q. AsQuery q => (Array Raw -> RepT ct) -> String -> q -> cursor ~> m
instance
( MonadAff m
( MonadBracket Effect.Error f m
, MonadAff m
, MonadSession (SessionT m)
, MonadCursor (CursorT t (SessionT m)) t
) => MonadPostgres

View File

@ -22,6 +22,7 @@ import Data.Tuple.Nested (type (/\), (/\))
import Effect.Aff.Class (class MonadAff)
import Effect.Aff.Unlift (class MonadUnliftAff)
import Effect.Class (class MonadEffect, liftEffect)
import Effect.Postgres.Error as E
import Effect.Unlift (class MonadUnliftEffect)
data Move
@ -118,7 +119,7 @@ instance (MonadSession m) => MonadCursor (CursorT t m) t where
RowsAffected n' <- query $ ("move relative $1 from " <> cur) /\ n
pure n'
instance (MonadSession m) => MonadSession (CursorT t m) where
instance (MonadThrow E.E m, MonadSession m) => MonadSession (CursorT t m) where
query = lift <<< query
exec = lift <<< exec
exec_ = lift <<< exec_

View File

@ -2,7 +2,7 @@ module Control.Monad.Postgres.Session where
import Prelude hiding (join)
import Control.Monad.Error.Class (class MonadError, catchError, throwError)
import Control.Monad.Error.Class (class MonadError, class MonadThrow, catchError, throwError)
import Control.Monad.Fork.Class (class MonadBracket)
import Control.Monad.Morph (hoist)
import Control.Monad.Reader (ask)
@ -17,7 +17,6 @@ import Effect.Aff.Postgres.Client (Client)
import Effect.Aff.Postgres.Client as Client
import Effect.Aff.Postgres.Pool (Pool)
import Effect.Aff.Postgres.Pool as Pool
import Effect.Aff.Unlift (class MonadUnliftAff)
import Effect.Class (class MonadEffect, liftEffect)
import Effect.Exception as Effect
import Effect.Postgres.Error (RE)
@ -45,7 +44,7 @@ instance MonadStartSession Client where
endSession _ _ = pure unit
-- | A monad representing a connected session to a database
class MonadAff m <= MonadSession m where
class (MonadThrow E.E m, MonadAff m) <= MonadSession m where
-- | Executes a query and unmarshals the result into `r`
query :: forall q r. AsQuery q => FromRows r => q -> m r
-- | Executes a query and returns the number of rows affected
@ -71,7 +70,7 @@ class MonadAff m <= MonadSession m where
-- | ```
streamOut :: String -> m (Readable ())
instance (MonadStartSession s, MonadAff m) => MonadSession (RE s m) where
instance (MonadStartSession s, MonadBracket Effect.Error f m, MonadAff m) => MonadSession (RE s m) where
query q = do
pool <- ask
client <- hoist liftAff $ RE.liftExcept $ startSession pool

View File

@ -3,7 +3,6 @@ module Effect.Postgres.Error.RE where
import Prelude hiding (join)
import Control.Alt (class Alt)
import Control.Alternative (class Alternative, class Plus)
import Control.Monad.Base (class MonadBase)
import Control.Monad.Error.Class (class MonadError, class MonadThrow, catchError, liftEither, throwError)
import Control.Monad.Except (ExceptT, runExceptT)
@ -34,7 +33,7 @@ newtype RE r m a = RE (ReaderT r (ExceptT E m) a)
newtype ParRE r f a = ParRE (ReaderT r (Compose f (Either E)) a)
finally :: forall r m a. Monad m => RE r m Unit -> RE r m a -> RE r m a
finally :: forall r f m a. MonadBracket Effect.Error f m => RE r m Unit -> RE r m a -> RE r m a
finally after m = (m <* after) `catchError` \e -> after *> throwError e
run :: forall m r a. MonadThrow Effect.Error m => RE r m a -> r -> m a
@ -53,9 +52,6 @@ derive instance Newtype (ParRE r m a) _
derive newtype instance Functor m => Functor (ParRE r m)
derive newtype instance Apply m => Apply (ParRE r m)
derive newtype instance Applicative m => Applicative (ParRE r m)
derive newtype instance Alt m => Alt (ParRE r m)
derive newtype instance Plus m => Plus (ParRE r m)
derive newtype instance Alternative m => Alternative (ParRE r m)
derive instance Newtype (RE r m a) _
derive newtype instance Monad m => MonadAsk r (RE r m)
@ -71,7 +67,7 @@ derive newtype instance MonadEffect m => MonadEffect (RE r m)
derive newtype instance MonadAff m => MonadAff (RE r m)
derive newtype instance MonadRec m => MonadRec (RE r m)
instance (Monad m, Parallel p m) => Parallel (ParRE r p) (RE r m) where
instance Parallel p m => Parallel (ParRE r p) (RE r m) where
parallel = wrap <<< parallel <<< unwrap
sequential = wrap <<< sequential <<< unwrap

View File

@ -1,10 +0,0 @@
module Node.FS.PinnedVersion where
import Prelude
import Effect.Aff (Aff)
import Node.Encoding (Encoding(..))
import Node.FS.Aff as FS
foo :: Aff Unit
foo = FS.writeTextFile UTF8 "foo" "foo"

View File

@ -6,10 +6,11 @@ import Control.Monad.Cont (lift)
import Control.Monad.Error.Class (class MonadError, class MonadThrow, catchError, throwError)
import Control.Monad.Morph (hoist)
import Control.Monad.Postgres (PostgresT)
import Control.Monad.Reader (ask)
import Control.Monad.Reader (class MonadAsk, ask)
import Data.Maybe (Maybe(..))
import Effect.Aff.Class (class MonadAff, liftAff)
import Effect.Aff.Postgres.Client as Client
import Effect.Aff.Postgres.Pool (Pool)
import Effect.Aff.Postgres.Pool as Pool
import Effect.Class (liftEffect)
import Effect.Exception (Error)
@ -25,6 +26,7 @@ stdin
:: forall m
. MonadAff m
=> MonadError Error m
=> MonadAsk Pool m
=> String
-> Consumer (Maybe Buffer) (PostgresT m) Unit
stdin q = do