hasql 0.19.17.1 → 0.19.18
raw patch · 13 files changed
+153/−189 lines, 13 filesdep +bytestring-strict-builderdep −aesondep −bytestring-tree-builderdep −network-ipdep ~postgresql-binarydep ~scientificdep ~timePVP ok
version bump matches the API change (PVP)
Dependencies added: bytestring-strict-builder
Dependencies removed: aeson, bytestring-tree-builder, network-ip
Dependency ranges changed: postgresql-binary, scientific, time, uuid
API changes (from Hackage documentation)
Files
- benchmark/Main/Prelude.hs +0/−12
- hasql.cabal +3/−8
- library/Hasql/Decoders.hs +46/−47
- library/Hasql/Encoders.hs +46/−47
- library/Hasql/Private/Decoders/Array.hs +9/−10
- library/Hasql/Private/Decoders/Composite.hs +8/−9
- library/Hasql/Private/Decoders/Row.hs +2/−2
- library/Hasql/Private/Decoders/Value.hs +5/−6
- library/Hasql/Private/Encoders/Array.hs +14/−15
- library/Hasql/Private/Encoders/Params.hs +14/−14
- library/Hasql/Private/Encoders/Value.hs +4/−5
- library/Hasql/Private/Prelude.hs +0/−12
- library/Hasql/Private/PreparedStatementRegistry.hs +2/−2
benchmark/Main/Prelude.hs view
@@ -52,18 +52,6 @@ ------------------------- import Data.ByteString as Exports (ByteString) --- scientific---------------------------import Data.Scientific as Exports (Scientific)---- uuid---------------------------import Data.UUID as Exports (UUID)---- time---------------------------import Data.Time as Exports- -- vector ------------------------- import Data.Vector as Exports (Vector)
hasql.cabal view
@@ -1,7 +1,7 @@ name: hasql version:- 0.19.17.1+ 0.19.18 category: Hasql, Database, PostgreSQL synopsis:@@ -74,22 +74,17 @@ -- parsing: attoparsec >= 0.10 && < 0.14, -- database:- postgresql-binary >= 0.10 && < 0.11,+ postgresql-binary >= 0.12.1 && < 0.13, postgresql-libpq == 0.9.*, -- builders:- bytestring-tree-builder >= 0.2.5 && < 0.3,+ bytestring-strict-builder >= 0.4 && < 0.5, -- data: dlist >= 0.7 && < 0.9,- aeson >= 0.7 && < 2,- uuid == 1.3.*, vector >= 0.10 && < 0.13,- time >= 1.4 && < 2, hashtables >= 1.1 && < 2,- scientific >= 0.2 && < 0.4, text >= 1 && < 2, bytestring >= 0.10 && < 0.11, hashable >= 1.2 && < 1.3,- network-ip >= 0.2 && < 0.4, -- control: semigroups >= 0.18 && < 0.20, data-default-class >= 0.0.1 && < 0.2,
library/Hasql/Decoders.hs view
@@ -60,9 +60,9 @@ where import Hasql.Private.Prelude hiding (maybe, bool)-import qualified Data.Aeson as Aeson import qualified Data.Vector as Vector-import qualified PostgreSQL.Binary.Decoder as Decoder+import qualified PostgreSQL.Binary.Decoding as A+import qualified PostgreSQL.Binary.Data as B import qualified Hasql.Private.Decoders.Results as Results import qualified Hasql.Private.Decoders.Result as Result import qualified Hasql.Private.Decoders.Row as Row@@ -70,7 +70,6 @@ import qualified Hasql.Private.Decoders.Array as Array import qualified Hasql.Private.Decoders.Composite as Composite import qualified Hasql.Private.Prelude as Prelude-import qualified Network.IP.Addr as IPAddr -- * Result -------------------------@@ -273,7 +272,7 @@ {-# INLINABLE bool #-} bool :: Value Bool bool =- Value (Value.decoder (const Decoder.bool))+ Value (Value.decoder (const A.bool)) -- | -- Decoder of the @INT2@ values.@@ -281,7 +280,7 @@ {-# INLINABLE int2 #-} int2 :: Value Int16 int2 =- Value (Value.decoder (const Decoder.int))+ Value (Value.decoder (const A.int)) -- | -- Decoder of the @INT4@ values.@@ -289,7 +288,7 @@ {-# INLINABLE int4 #-} int4 :: Value Int32 int4 =- Value (Value.decoder (const Decoder.int))+ Value (Value.decoder (const A.int)) -- | -- Decoder of the @INT8@ values.@@ -298,7 +297,7 @@ int8 :: Value Int64 int8 = {-# SCC "int8" #-} - Value (Value.decoder (const ({-# SCC "int8.int" #-} Decoder.int)))+ Value (Value.decoder (const ({-# SCC "int8.int" #-} A.int))) -- | -- Decoder of the @FLOAT4@ values.@@ -306,7 +305,7 @@ {-# INLINABLE float4 #-} float4 :: Value Float float4 =- Value (Value.decoder (const Decoder.float4))+ Value (Value.decoder (const A.float4)) -- | -- Decoder of the @FLOAT8@ values.@@ -314,15 +313,15 @@ {-# INLINABLE float8 #-} float8 :: Value Double float8 =- Value (Value.decoder (const Decoder.float8))+ Value (Value.decoder (const A.float8)) -- | -- Decoder of the @NUMERIC@ values. -- {-# INLINABLE numeric #-}-numeric :: Value Scientific+numeric :: Value B.Scientific numeric =- Value (Value.decoder (const Decoder.numeric))+ Value (Value.decoder (const A.numeric)) -- | -- Decoder of the @CHAR@ values.@@ -330,7 +329,7 @@ {-# INLINABLE char #-} char :: Value Char char =- Value (Value.decoder (const Decoder.char))+ Value (Value.decoder (const A.char)) -- | -- Decoder of the @TEXT@ values.@@ -338,7 +337,7 @@ {-# INLINABLE text #-} text :: Value Text text =- Value (Value.decoder (const Decoder.text_strict))+ Value (Value.decoder (const A.text_strict)) -- | -- Decoder of the @BYTEA@ values.@@ -346,23 +345,23 @@ {-# INLINABLE bytea #-} bytea :: Value ByteString bytea =- Value (Value.decoder (const Decoder.bytea_strict))+ Value (Value.decoder (const A.bytea_strict)) -- | -- Decoder of the @DATE@ values. -- {-# INLINABLE date #-}-date :: Value Day+date :: Value B.Day date =- Value (Value.decoder (const Decoder.date))+ Value (Value.decoder (const A.date)) -- | -- Decoder of the @TIMESTAMP@ values. -- {-# INLINABLE timestamp #-}-timestamp :: Value LocalTime+timestamp :: Value B.LocalTime timestamp =- Value (Value.decoder (Prelude.bool Decoder.timestamp_float Decoder.timestamp_int))+ Value (Value.decoder (Prelude.bool A.timestamp_float A.timestamp_int)) -- | -- Decoder of the @TIMESTAMPTZ@ values.@@ -375,17 +374,17 @@ -- However this library bypasses the silent conversions -- and communicates with Postgres using the UTC values directly. {-# INLINABLE timestamptz #-}-timestamptz :: Value UTCTime+timestamptz :: Value B.UTCTime timestamptz =- Value (Value.decoder (Prelude.bool Decoder.timestamptz_float Decoder.timestamptz_int))+ Value (Value.decoder (Prelude.bool A.timestamptz_float A.timestamptz_int)) -- | -- Decoder of the @TIME@ values. -- {-# INLINABLE time #-}-time :: Value TimeOfDay+time :: Value B.TimeOfDay time =- Value (Value.decoder (Prelude.bool Decoder.time_float Decoder.time_int))+ Value (Value.decoder (Prelude.bool A.time_float A.time_int)) -- | -- Decoder of the @TIMETZ@ values.@@ -396,41 +395,41 @@ -- that fits the task, so we use a pair of 'TimeOfDay' and 'TimeZone' -- to represent a value on the Haskell's side. {-# INLINABLE timetz #-}-timetz :: Value (TimeOfDay, TimeZone)+timetz :: Value (B.TimeOfDay, B.TimeZone) timetz =- Value (Value.decoder (Prelude.bool Decoder.timetz_float Decoder.timetz_int))+ Value (Value.decoder (Prelude.bool A.timetz_float A.timetz_int)) -- | -- Decoder of the @INTERVAL@ values. -- {-# INLINABLE interval #-}-interval :: Value DiffTime+interval :: Value B.DiffTime interval =- Value (Value.decoder (Prelude.bool Decoder.interval_float Decoder.interval_int))+ Value (Value.decoder (Prelude.bool A.interval_float A.interval_int)) -- | -- Decoder of the @UUID@ values. -- {-# INLINABLE uuid #-}-uuid :: Value UUID+uuid :: Value B.UUID uuid =- Value (Value.decoder (const Decoder.uuid))+ Value (Value.decoder (const A.uuid)) -- | -- Decoder of the @INET@ values. -- {-# INLINABLE inet #-}-inet :: Value (IPAddr.NetAddr IPAddr.IP)+inet :: Value (B.NetAddr B.IP) inet =- Value (Value.decoder (const Decoder.inet))+ Value (Value.decoder (const A.inet)) -- | -- Decoder of the @JSON@ values into a JSON AST. -- {-# INLINABLE json #-}-json :: Value Aeson.Value+json :: Value B.Value json =- Value (Value.decoder (const Decoder.json_ast))+ Value (Value.decoder (const A.json_ast)) -- | -- Decoder of the @JSON@ values into a raw JSON 'ByteString'.@@ -438,15 +437,15 @@ {-# INLINABLE jsonBytes #-} jsonBytes :: (ByteString -> Either Text a) -> Value a jsonBytes fn =- Value (Value.decoder (const (Decoder.json_bytes fn)))+ Value (Value.decoder (const (A.json_bytes fn))) -- | -- Decoder of the @JSONB@ values into a JSON AST. -- {-# INLINABLE jsonb #-}-jsonb :: Value Aeson.Value+jsonb :: Value B.Value jsonb =- Value (Value.decoder (const Decoder.jsonb_ast))+ Value (Value.decoder (const A.jsonb_ast)) -- | -- Decoder of the @JSONB@ values into a raw JSON 'ByteString'.@@ -454,7 +453,7 @@ {-# INLINABLE jsonbBytes #-} jsonbBytes :: (ByteString -> Either Text a) -> Value a jsonbBytes fn =- Value (Value.decoder (const (Decoder.jsonb_bytes fn)))+ Value (Value.decoder (const (A.jsonb_bytes fn))) -- | -- Lifts a custom value decoder function to a 'Value' decoder.@@ -498,14 +497,14 @@ {-# INLINABLE hstore #-} hstore :: (forall m. Monad m => Int -> m (Text, Maybe Text) -> m a) -> Value a hstore replicateM =- Value (Value.decoder (const (Decoder.hstore replicateM Decoder.text_strict Decoder.text_strict)))+ Value (Value.decoder (const (A.hstore replicateM A.text_strict A.text_strict))) -- | -- Given a partial mapping from text to value, -- produces a decoder of that value. enum :: (Text -> Maybe a) -> Value a enum mapping =- Value (Value.decoder (const (Decoder.enum mapping)))+ Value (Value.decoder (const (A.enum mapping))) -- ** Instances@@ -555,7 +554,7 @@ -- | -- Maps to 'numeric'.-instance Default (Value Scientific) where+instance Default (Value B.Scientific) where {-# INLINE def #-} def = numeric@@ -583,56 +582,56 @@ -- | -- Maps to 'date'.-instance Default (Value Day) where+instance Default (Value B.Day) where {-# INLINE def #-} def = date -- | -- Maps to 'timestamp'.-instance Default (Value LocalTime) where+instance Default (Value B.LocalTime) where {-# INLINE def #-} def = timestamp -- | -- Maps to 'timestamptz'.-instance Default (Value UTCTime) where+instance Default (Value B.UTCTime) where {-# INLINE def #-} def = timestamptz -- | -- Maps to 'time'.-instance Default (Value TimeOfDay) where+instance Default (Value B.TimeOfDay) where {-# INLINE def #-} def = time -- | -- Maps to 'timetz'.-instance Default (Value (TimeOfDay, TimeZone)) where+instance Default (Value (B.TimeOfDay, B.TimeZone)) where {-# INLINE def #-} def = timetz -- | -- Maps to 'interval'.-instance Default (Value DiffTime) where+instance Default (Value B.DiffTime) where {-# INLINE def #-} def = interval -- | -- Maps to 'uuid'.-instance Default (Value UUID) where+instance Default (Value B.UUID) where {-# INLINE def #-} def = uuid -- | -- Maps to 'json'.-instance Default (Value Aeson.Value) where+instance Default (Value B.Value) where {-# INLINE def #-} def = json
library/Hasql/Encoders.hs view
@@ -43,14 +43,13 @@ where import Hasql.Private.Prelude hiding (bool)-import qualified PostgreSQL.Binary.Encoder as Encoder-import qualified Data.Aeson as Aeson+import qualified PostgreSQL.Binary.Encoding as A+import qualified PostgreSQL.Binary.Data as B import qualified Hasql.Private.Encoders.Params as Params import qualified Hasql.Private.Encoders.Value as Value import qualified Hasql.Private.Encoders.Array as Array import qualified Hasql.Private.PTI as PTI import qualified Hasql.Private.Prelude as Prelude-import qualified Network.IP.Addr as IPAddr -- * Parameters Product Encoder -------------------------@@ -186,49 +185,49 @@ {-# INLINABLE bool #-} bool :: Value Bool bool =- Value (Value.unsafePTI PTI.bool (const Encoder.bool))+ Value (Value.unsafePTI PTI.bool (const A.bool)) -- | -- Encoder of @INT2@ values. {-# INLINABLE int2 #-} int2 :: Value Int16 int2 =- Value (Value.unsafePTI PTI.int2 (const Encoder.int2_int16))+ Value (Value.unsafePTI PTI.int2 (const A.int2_int16)) -- | -- Encoder of @INT4@ values. {-# INLINABLE int4 #-} int4 :: Value Int32 int4 =- Value (Value.unsafePTI PTI.int4 (const Encoder.int4_int32))+ Value (Value.unsafePTI PTI.int4 (const A.int4_int32)) -- | -- Encoder of @INT8@ values. {-# INLINABLE int8 #-} int8 :: Value Int64 int8 =- Value (Value.unsafePTI PTI.int8 (const Encoder.int8_int64))+ Value (Value.unsafePTI PTI.int8 (const A.int8_int64)) -- | -- Encoder of @FLOAT4@ values. {-# INLINABLE float4 #-} float4 :: Value Float float4 =- Value (Value.unsafePTI PTI.float4 (const Encoder.float4))+ Value (Value.unsafePTI PTI.float4 (const A.float4)) -- | -- Encoder of @FLOAT8@ values. {-# INLINABLE float8 #-} float8 :: Value Double float8 =- Value (Value.unsafePTI PTI.float8 (const Encoder.float8))+ Value (Value.unsafePTI PTI.float8 (const A.float8)) -- | -- Encoder of @NUMERIC@ values. {-# INLINABLE numeric #-}-numeric :: Value Scientific+numeric :: Value B.Scientific numeric =- Value (Value.unsafePTI PTI.numeric (const Encoder.numeric))+ Value (Value.unsafePTI PTI.numeric (const A.numeric)) -- | -- Encoder of @CHAR@ values.@@ -237,105 +236,105 @@ {-# INLINABLE char #-} char :: Value Char char =- Value (Value.unsafePTI PTI.text (const Encoder.char))+ Value (Value.unsafePTI PTI.text (const A.char_utf8)) -- | -- Encoder of @TEXT@ values. {-# INLINABLE text #-} text :: Value Text text =- Value (Value.unsafePTI PTI.text (const Encoder.text_strict))+ Value (Value.unsafePTI PTI.text (const A.text_strict)) -- | -- Encoder of @BYTEA@ values. {-# INLINABLE bytea #-} bytea :: Value ByteString bytea =- Value (Value.unsafePTI PTI.bytea (const Encoder.bytea_strict))+ Value (Value.unsafePTI PTI.bytea (const A.bytea_strict)) -- | -- Encoder of @DATE@ values. {-# INLINABLE date #-}-date :: Value Day+date :: Value B.Day date =- Value (Value.unsafePTI PTI.date (const Encoder.date))+ Value (Value.unsafePTI PTI.date (const A.date)) -- | -- Encoder of @TIMESTAMP@ values. {-# INLINABLE timestamp #-}-timestamp :: Value LocalTime+timestamp :: Value B.LocalTime timestamp =- Value (Value.unsafePTI PTI.timestamp (Prelude.bool Encoder.timestamp_float Encoder.timestamp_int))+ Value (Value.unsafePTI PTI.timestamp (Prelude.bool A.timestamp_float A.timestamp_int)) -- | -- Encoder of @TIMESTAMPTZ@ values. {-# INLINABLE timestamptz #-}-timestamptz :: Value UTCTime+timestamptz :: Value B.UTCTime timestamptz =- Value (Value.unsafePTI PTI.timestamptz (Prelude.bool Encoder.timestamptz_float Encoder.timestamptz_int))+ Value (Value.unsafePTI PTI.timestamptz (Prelude.bool A.timestamptz_float A.timestamptz_int)) -- | -- Encoder of @TIME@ values. {-# INLINABLE time #-}-time :: Value TimeOfDay+time :: Value B.TimeOfDay time =- Value (Value.unsafePTI PTI.time (Prelude.bool Encoder.time_float Encoder.time_int))+ Value (Value.unsafePTI PTI.time (Prelude.bool A.time_float A.time_int)) -- | -- Encoder of @TIMETZ@ values. {-# INLINABLE timetz #-}-timetz :: Value (TimeOfDay, TimeZone)+timetz :: Value (B.TimeOfDay, B.TimeZone) timetz =- Value (Value.unsafePTI PTI.timetz (Prelude.bool Encoder.timetz_float Encoder.timetz_int))+ Value (Value.unsafePTI PTI.timetz (Prelude.bool A.timetz_float A.timetz_int)) -- | -- Encoder of @INTERVAL@ values. {-# INLINABLE interval #-}-interval :: Value DiffTime+interval :: Value B.DiffTime interval =- Value (Value.unsafePTI PTI.interval (Prelude.bool Encoder.interval_float Encoder.interval_int))+ Value (Value.unsafePTI PTI.interval (Prelude.bool A.interval_float A.interval_int)) -- | -- Encoder of @UUID@ values. {-# INLINABLE uuid #-}-uuid :: Value UUID+uuid :: Value B.UUID uuid =- Value (Value.unsafePTI PTI.uuid (const Encoder.uuid))+ Value (Value.unsafePTI PTI.uuid (const A.uuid)) -- | -- Encoder of @INET@ values. {-# INLINABLE inet #-}-inet :: Value (IPAddr.NetAddr IPAddr.IP)+inet :: Value (B.NetAddr B.IP) inet =- Value (Value.unsafePTI PTI.inet (const Encoder.inet))+ Value (Value.unsafePTI PTI.inet (const A.inet)) -- | -- Encoder of @JSON@ values from JSON AST. {-# INLINABLE json #-}-json :: Value Aeson.Value+json :: Value B.Value json =- Value (Value.unsafePTI PTI.json (const Encoder.json_ast))+ Value (Value.unsafePTI PTI.json (const A.json_ast)) -- | -- Encoder of @JSON@ values from raw JSON. {-# INLINABLE jsonBytes #-} jsonBytes :: Value ByteString jsonBytes =- Value (Value.unsafePTI PTI.json (const Encoder.json_bytes))+ Value (Value.unsafePTI PTI.json (const A.json_bytes)) -- | -- Encoder of @JSONB@ values from JSON AST. {-# INLINABLE jsonb #-}-jsonb :: Value Aeson.Value+jsonb :: Value B.Value jsonb =- Value (Value.unsafePTI PTI.jsonb (const Encoder.jsonb_ast))+ Value (Value.unsafePTI PTI.jsonb (const A.jsonb_ast)) -- | -- Encoder of @JSONB@ values from raw JSON. {-# INLINABLE jsonbBytes #-} jsonbBytes :: Value ByteString jsonbBytes =- Value (Value.unsafePTI PTI.jsonb (const Encoder.jsonb_bytes))+ Value (Value.unsafePTI PTI.jsonb (const A.jsonb_bytes)) -- | -- Unlifts the 'Array' encoder to the plain 'Value' encoder.@@ -352,7 +351,7 @@ {-# INLINABLE enum #-} enum :: (a -> Text) -> Value a enum mapping =- Value (Value.unsafePTI PTI.text (const (Encoder.enum mapping)))+ Value (Value.unsafePTI PTI.text (const (A.text_strict . mapping))) -- | -- Identifies the value with the PostgreSQL's \"unknown\" type,@@ -369,7 +368,7 @@ {-# INLINABLE unknown #-} unknown :: Value ByteString unknown =- Value (Value.unsafePTI PTI.unknown (const Encoder.bytea_strict))+ Value (Value.unsafePTI PTI.unknown (const A.bytea_strict)) -- ** Instances@@ -412,7 +411,7 @@ float8 -- | Maps to 'numeric'.-instance Default (Value Scientific) where+instance Default (Value B.Scientific) where {-# INLINE def #-} def = numeric@@ -436,49 +435,49 @@ bytea -- | Maps to 'date'.-instance Default (Value Day) where+instance Default (Value B.Day) where {-# INLINE def #-} def = date -- | Maps to 'timestamp'.-instance Default (Value LocalTime) where+instance Default (Value B.LocalTime) where {-# INLINE def #-} def = timestamp -- | Maps to 'timestamptz'.-instance Default (Value UTCTime) where+instance Default (Value B.UTCTime) where {-# INLINE def #-} def = timestamptz -- | Maps to 'time'.-instance Default (Value TimeOfDay) where+instance Default (Value B.TimeOfDay) where {-# INLINE def #-} def = time -- | Maps to 'timetz'.-instance Default (Value (TimeOfDay, TimeZone)) where+instance Default (Value (B.TimeOfDay, B.TimeZone)) where {-# INLINE def #-} def = timetz -- | Maps to 'interval'.-instance Default (Value DiffTime) where+instance Default (Value B.DiffTime) where {-# INLINE def #-} def = interval -- | Maps to 'uuid'.-instance Default (Value UUID) where+instance Default (Value B.UUID) where {-# INLINE def #-} def = uuid -- | Maps to 'json'.-instance Default (Value Aeson.Value) where+instance Default (Value B.Value) where {-# INLINE def #-} def = json
library/Hasql/Private/Decoders/Array.hs view
@@ -1,31 +1,30 @@ module Hasql.Private.Decoders.Array where import Hasql.Private.Prelude-import qualified Database.PostgreSQL.LibPQ as LibPQ-import qualified PostgreSQL.Binary.Decoder as Decoder+import qualified PostgreSQL.Binary.Decoding as A newtype Array a =- Array (ReaderT Bool Decoder.ArrayDecoder a)+ Array (ReaderT Bool A.Array a) deriving (Functor) {-# INLINE run #-}-run :: Array a -> Bool -> Decoder.Decoder a+run :: Array a -> Bool -> A.Value a run (Array imp) env =- Decoder.array (runReaderT imp env)+ A.array (runReaderT imp env) {-# INLINE dimension #-} dimension :: (forall m. Monad m => Int -> m a -> m b) -> Array a -> Array b dimension replicateM (Array imp) =- Array $ ReaderT $ \env -> Decoder.arrayDimension replicateM (runReaderT imp env)+ Array $ ReaderT $ \env -> A.dimensionArray replicateM (runReaderT imp env) {-# INLINE value #-}-value :: (Bool -> Decoder.Decoder a) -> Array (Maybe a)+value :: (Bool -> A.Value a) -> Array (Maybe a) value decoder' =- Array $ ReaderT $ Decoder.arrayValue . decoder'+ Array $ ReaderT $ A.nullableValueArray . decoder' {-# INLINE nonNullValue #-}-nonNullValue :: (Bool -> Decoder.Decoder a) -> Array a+nonNullValue :: (Bool -> A.Value a) -> Array a nonNullValue decoder' =- Array $ ReaderT $ Decoder.arrayNonNullValue . decoder'+ Array $ ReaderT $ A.valueArray . decoder'
library/Hasql/Private/Decoders/Composite.hs view
@@ -1,26 +1,25 @@ module Hasql.Private.Decoders.Composite where import Hasql.Private.Prelude-import qualified Database.PostgreSQL.LibPQ as LibPQ-import qualified PostgreSQL.Binary.Decoder as Decoder+import qualified PostgreSQL.Binary.Decoding as A newtype Composite a =- Composite (ReaderT Bool Decoder.CompositeDecoder a)+ Composite (ReaderT Bool A.Composite a) deriving (Functor, Applicative, Monad) {-# INLINE run #-}-run :: Composite a -> Bool -> Decoder.Decoder a+run :: Composite a -> Bool -> A.Value a run (Composite imp) env =- Decoder.composite (runReaderT imp env)+ A.composite (runReaderT imp env) {-# INLINE value #-}-value :: (Bool -> Decoder.Decoder a) -> Composite (Maybe a)+value :: (Bool -> A.Value a) -> Composite (Maybe a) value decoder' =- Composite $ ReaderT $ Decoder.compositeValue . decoder'+ Composite $ ReaderT $ A.nullableValueComposite . decoder' {-# INLINE nonNullValue #-}-nonNullValue :: (Bool -> Decoder.Decoder a) -> Composite a+nonNullValue :: (Bool -> A.Value a) -> Composite a nonNullValue decoder' =- Composite $ ReaderT $ Decoder.compositeNonNullValue . decoder'+ Composite $ ReaderT $ A.valueComposite . decoder'
library/Hasql/Private/Decoders/Row.hs view
@@ -2,7 +2,7 @@ import Hasql.Private.Prelude import qualified Database.PostgreSQL.LibPQ as LibPQ-import qualified PostgreSQL.Binary.Decoder as Decoder+import qualified PostgreSQL.Binary.Decoding as A import qualified Hasql.Private.Decoders.Value as Value @@ -53,7 +53,7 @@ Right Nothing Just value -> fmap Just $ mapLeft ValueError $- {-# SCC "decode" #-} Decoder.run (Value.run valueDec integerDatetimes) value+ {-# SCC "decode" #-} A.valueParser (Value.run valueDec integerDatetimes) value else pure (Left EndOfInput) -- |
library/Hasql/Private/Decoders/Value.hs view
@@ -1,22 +1,21 @@ module Hasql.Private.Decoders.Value where import Hasql.Private.Prelude-import qualified Database.PostgreSQL.LibPQ as LibPQ-import qualified PostgreSQL.Binary.Decoder as Decoder+import qualified PostgreSQL.Binary.Decoding as A newtype Value a =- Value (ReaderT Bool Decoder.Decoder a)+ Value (ReaderT Bool A.Value a) deriving (Functor) {-# INLINE run #-}-run :: Value a -> Bool -> Decoder.Decoder a+run :: Value a -> Bool -> A.Value a run (Value imp) integerDatetimes = runReaderT imp integerDatetimes {-# INLINE decoder #-}-decoder :: (Bool -> Decoder.Decoder a) -> Value a+decoder :: (Bool -> A.Value a) -> Value a decoder = {-# SCC "decoder" #-} Value . ReaderT@@ -24,5 +23,5 @@ {-# INLINE decoderFn #-} decoderFn :: (Bool -> ByteString -> Either Text a) -> Value a decoderFn fn =- Value $ ReaderT $ \integerDatetimes -> Decoder.fn $ fn integerDatetimes+ Value $ ReaderT $ \integerDatetimes -> A.fn $ fn integerDatetimes
library/Hasql/Private/Encoders/Array.hs view
@@ -1,31 +1,30 @@ module Hasql.Private.Encoders.Array where import Hasql.Private.Prelude-import qualified Database.PostgreSQL.LibPQ as LibPQ-import qualified PostgreSQL.Binary.Encoder as Encoder-import qualified Hasql.Private.PTI as PTI+import qualified PostgreSQL.Binary.Encoding as A+import qualified Hasql.Private.PTI as B data Array a =- Array PTI.OID PTI.OID (Bool -> Encoder.ArrayEncoder a)+ Array B.OID B.OID (Bool -> a -> A.Array) {-# INLINE run #-}-run :: Array a -> (PTI.OID, Bool -> Encoder.Encoder a)-run (Array valueOID arrayOID encoder') =- (arrayOID, \env -> Encoder.array (PTI.oidWord32 valueOID) (encoder' env))+run :: Array a -> (B.OID, Bool -> a -> A.Encoding)+run (Array valueOID arrayOID encoder) =+ (arrayOID, \env input -> A.array (B.oidWord32 valueOID) (encoder env input)) {-# INLINE value #-}-value :: PTI.OID -> PTI.OID -> (Bool -> Encoder.Encoder a) -> Array a-value valueOID arrayOID encoder' =- Array valueOID arrayOID (Encoder.arrayValue . encoder')+value :: B.OID -> B.OID -> (Bool -> a -> A.Encoding) -> Array a+value valueOID arrayOID encoder =+ Array valueOID arrayOID (\params -> A.encodingArray . encoder params) {-# INLINE nullableValue #-}-nullableValue :: PTI.OID -> PTI.OID -> (Bool -> Encoder.Encoder a) -> Array (Maybe a)-nullableValue valueOID arrayOID encoder' =- Array valueOID arrayOID (Encoder.arrayNullableValue . encoder')+nullableValue :: B.OID -> B.OID -> (Bool -> a -> A.Encoding) -> Array (Maybe a)+nullableValue valueOID arrayOID encoder =+ Array valueOID arrayOID (\params -> maybe A.nullArray (A.encodingArray . encoder params)) {-# INLINE dimension #-} dimension :: (forall a. (a -> b -> a) -> a -> c -> a) -> Array b -> Array c-dimension foldl (Array valueOID arrayOID encoder') =- Array valueOID arrayOID (Encoder.arrayDimension foldl . encoder')+dimension fold (Array valueOID arrayOID encoder) =+ Array valueOID arrayOID (\params -> A.dimensionArray fold (encoder params))
library/Hasql/Private/Encoders/Params.hs view
@@ -1,26 +1,26 @@ module Hasql.Private.Encoders.Params where import Hasql.Private.Prelude-import qualified Database.PostgreSQL.LibPQ as LibPQ-import qualified PostgreSQL.Binary.Encoder as Encoder-import qualified Hasql.Private.Encoders.Value as Value-import qualified Hasql.Private.PTI as PTI+import qualified Database.PostgreSQL.LibPQ as A+import qualified PostgreSQL.Binary.Encoding as B+import qualified Hasql.Private.Encoders.Value as C+import qualified Hasql.Private.PTI as D -- | -- Encoder of some representation of a parameters product. newtype Params a =- Params (Op (DList (LibPQ.Oid, Bool -> Maybe ByteString)) a)+ Params (Op (DList (A.Oid, Bool -> Maybe ByteString)) a) deriving (Contravariant, Divisible, Decidable, Monoid) instance Semigroup (Params a) -run :: Params a -> a -> DList (LibPQ.Oid, Bool -> Maybe ByteString)+run :: Params a -> a -> DList (A.Oid, Bool -> Maybe ByteString) run (Params (Op op)) params = {-# SCC "run" #-} op params -run' :: Params a -> a -> Bool -> ([LibPQ.Oid], [Maybe (ByteString, LibPQ.Format)])+run' :: Params a -> a -> Bool -> ([A.Oid], [Maybe (ByteString, A.Format)]) run' (Params (Op op)) params integerDatetimes = {-# SCC "run'" #-} foldr step ([], []) (op params)@@ -28,9 +28,9 @@ step (oid, bytesGetter) ~(oidList, bytesAndFormatList) = (,) (oid : oidList)- (fmap (\bytes -> (bytes, LibPQ.Binary)) (bytesGetter integerDatetimes) : bytesAndFormatList)+ (fmap (\bytes -> (bytes, A.Binary)) (bytesGetter integerDatetimes) : bytesAndFormatList) -run'' :: Params a -> a -> Bool -> [Maybe (LibPQ.Oid, ByteString, LibPQ.Format)]+run'' :: Params a -> a -> Bool -> [Maybe (A.Oid, ByteString, A.Format)] run'' (Params (Op op)) params integerDatetimes = {-# SCC "run''" #-} foldr step [] (op params)@@ -39,13 +39,13 @@ mapping a : b where mapping (oid, bytesGetter) =- (,,) <$> pure oid <*> bytesGetter integerDatetimes <*> pure LibPQ.Binary+ (,,) <$> pure oid <*> bytesGetter integerDatetimes <*> pure A.Binary -value :: Value.Value a -> Params a+value :: C.Value a -> Params a value = contramap Just . nullableValue -nullableValue :: Value.Value a -> Params (Maybe a)-nullableValue (Value.Value valueOID arrayOID encoder') =+nullableValue :: C.Value a -> Params (Maybe a)+nullableValue (C.Value valueOID arrayOID encoder) = Params $ Op $ \input -> - pure (PTI.oidPQ valueOID, \env -> fmap (Encoder.run (encoder' env)) input)+ pure (D.oidPQ valueOID, \env -> fmap (B.encodingBytes . encoder env) input)
library/Hasql/Private/Encoders/Value.hs view
@@ -1,13 +1,12 @@ module Hasql.Private.Encoders.Value where import Hasql.Private.Prelude-import qualified Database.PostgreSQL.LibPQ as LibPQ-import qualified PostgreSQL.Binary.Encoder as Encoder+import qualified PostgreSQL.Binary.Encoding as B import qualified Hasql.Private.PTI as PTI data Value a =- Value PTI.OID PTI.OID (Bool -> Encoder.Encoder a)+ Value PTI.OID PTI.OID (Bool -> a -> B.Encoding) instance Contravariant Value where {-# INLINE contramap #-}@@ -15,12 +14,12 @@ Value valueOID arrayOID (\integerDatetimes input -> encoder integerDatetimes (f input)) {-# INLINE run #-}-run :: Value a -> (PTI.OID, PTI.OID, Bool -> Encoder.Encoder a)+run :: Value a -> (PTI.OID, PTI.OID, Bool -> a -> B.Encoding) run (Value valueOID arrayOID encoder') = (valueOID, arrayOID, encoder') {-# INLINE unsafePTI #-}-unsafePTI :: PTI.PTI -> (Bool -> Encoder.Encoder a) -> Value a+unsafePTI :: PTI.PTI -> (Bool -> a -> B.Encoding) -> Value a unsafePTI pti encoder' = Value (PTI.ptiOID pti) (fromMaybe ($bug "No array OID") (PTI.ptiArrayOID pti)) encoder'
library/Hasql/Private/Prelude.hs view
@@ -69,18 +69,6 @@ ------------------------- import Data.ByteString as Exports (ByteString) --- scientific---------------------------import Data.Scientific as Exports (Scientific)---- uuid---------------------------import Data.UUID as Exports (UUID)---- time---------------------------import Data.Time as Exports- -- vector ------------------------- import Data.Vector as Exports (Vector)
library/Hasql/Private/PreparedStatementRegistry.hs view
@@ -9,7 +9,7 @@ import Hasql.Private.Prelude hiding (lookup) import qualified Data.HashTable.IO as A-import qualified ByteString.TreeBuilder as B+import qualified ByteString.StrictBuilder as B data PreparedStatementRegistry =@@ -39,7 +39,7 @@ return result where remoteKey =- B.toByteString . B.asciiIntegral $ n+ B.builderBytes . B.asciiIntegral $ n old = onOldRemoteKey