From 7f1c0cfb9b0e00f7b8af36bf4fe88519a2b6e69b Mon Sep 17 00:00:00 2001 From: Nikita Volkov Date: Tue, 2 Nov 2021 10:26:35 +0300 Subject: [PATCH] Revert "Migrate to new text-builder" This reverts commit d9bf8c8cea56bc7288e506374b364ab2871e3288. --- hasql.cabal | 2 +- library/Hasql/Private/Encoders.hs | 2 +- library/Hasql/Private/Encoders/Array.hs | 8 ++++---- library/Hasql/Private/Encoders/Params.hs | 4 ++-- library/Hasql/Private/Encoders/Value.hs | 6 +++--- stack.yaml | 4 ---- 6 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 stack.yaml diff --git a/hasql.cabal b/hasql.cabal index 25881ef..667d4dc 100644 --- a/hasql.cabal +++ b/hasql.cabal @@ -67,7 +67,7 @@ library postgresql-libpq ==0.9.*, profunctors >=5.1 && <6, text >=1 && <2, - text-builder >=0.7 && <0.8, + text-builder >=0.6.1.2 && <0.7, transformers >=0.3 && <0.6, vector >=0.10 && <0.13 diff --git a/library/Hasql/Private/Encoders.hs b/library/Hasql/Private/Encoders.hs index 20f5030..e61849c 100644 --- a/library/Hasql/Private/Encoders.hs +++ b/library/Hasql/Private/Encoders.hs @@ -7,7 +7,7 @@ where import Hasql.Private.Prelude hiding (bool) import qualified PostgreSQL.Binary.Encoding as A import qualified PostgreSQL.Binary.Data as B -import qualified TextBuilder as C +import qualified Text.Builder as C import qualified Hasql.Private.Encoders.Params as Params import qualified Hasql.Private.Encoders.Value as Value import qualified Hasql.Private.Encoders.Array as Array diff --git a/library/Hasql/Private/Encoders/Array.hs b/library/Hasql/Private/Encoders/Array.hs index bdc1878..b8a3ea1 100644 --- a/library/Hasql/Private/Encoders/Array.hs +++ b/library/Hasql/Private/Encoders/Array.hs @@ -3,23 +3,23 @@ module Hasql.Private.Encoders.Array where import Hasql.Private.Prelude import qualified PostgreSQL.Binary.Encoding as A import qualified Hasql.Private.PTI as B -import qualified TextBuilder as C +import qualified Text.Builder as C data Array a = - Array B.OID B.OID (Bool -> a -> A.Array) (a -> C.TextBuilder) + Array B.OID B.OID (Bool -> a -> A.Array) (a -> C.Builder) instance Contravariant Array where contramap fn (Array valueOid arrayOid encoder renderer) = Array valueOid arrayOid (\ intDateTimes -> encoder intDateTimes . fn) (renderer . fn) {-# INLINE value #-} -value :: B.OID -> B.OID -> (Bool -> a -> A.Encoding) -> (a -> C.TextBuilder) -> Array a +value :: B.OID -> B.OID -> (Bool -> a -> A.Encoding) -> (a -> C.Builder) -> Array a value valueOID arrayOID encoder = Array valueOID arrayOID (\params -> A.encodingArray . encoder params) {-# INLINE nullableValue #-} -nullableValue :: B.OID -> B.OID -> (Bool -> a -> A.Encoding) -> (a -> C.TextBuilder) -> Array (Maybe a) +nullableValue :: B.OID -> B.OID -> (Bool -> a -> A.Encoding) -> (a -> C.Builder) -> Array (Maybe a) nullableValue valueOID arrayOID encoder renderer = let maybeEncoder params = diff --git a/library/Hasql/Private/Encoders/Params.hs b/library/Hasql/Private/Encoders/Params.hs index 408e5d9..fcc61f8 100644 --- a/library/Hasql/Private/Encoders/Params.hs +++ b/library/Hasql/Private/Encoders/Params.hs @@ -5,7 +5,7 @@ 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 -import qualified TextBuilder as E +import qualified Text.Builder as E -- | @@ -27,5 +27,5 @@ nullableValue (C.Value valueOID arrayOID encode render) = encoder env = fmap (B.encodingBytes . encode env) input rendering = - maybe "null" (E.buildText . render) input + maybe "null" (E.run . render) input in pure (pqOid, format, encoder, rendering) diff --git a/library/Hasql/Private/Encoders/Value.hs b/library/Hasql/Private/Encoders/Value.hs index 1051a90..ee9b2a9 100644 --- a/library/Hasql/Private/Encoders/Value.hs +++ b/library/Hasql/Private/Encoders/Value.hs @@ -3,11 +3,11 @@ module Hasql.Private.Encoders.Value where import Hasql.Private.Prelude import qualified PostgreSQL.Binary.Encoding as B import qualified Hasql.Private.PTI as PTI -import qualified TextBuilder as C +import qualified Text.Builder as C data Value a = - Value PTI.OID PTI.OID (Bool -> a -> B.Encoding) (a -> C.TextBuilder) + Value PTI.OID PTI.OID (Bool -> a -> B.Encoding) (a -> C.Builder) instance Contravariant Value where {-# INLINE contramap #-} @@ -15,7 +15,7 @@ instance Contravariant Value where Value valueOID arrayOID (\integerDatetimes input -> encode integerDatetimes (f input)) (render . f) {-# INLINE unsafePTI #-} -unsafePTI :: PTI.PTI -> (Bool -> a -> B.Encoding) -> (a -> C.TextBuilder) -> Value a +unsafePTI :: PTI.PTI -> (Bool -> a -> B.Encoding) -> (a -> C.Builder) -> Value a unsafePTI pti = Value (PTI.ptiOID pti) (fromMaybe (error "No array OID") (PTI.ptiArrayOID pti)) diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index abdd685..0000000 --- a/stack.yaml +++ /dev/null @@ -1,4 +0,0 @@ -resolver: nightly-2021-10-18 -extra-deps: - - git: https://github.com/nikita-volkov/text-builder - commit: c13872edc976fac70231af5cc3bd13763c001f20