on dev help sign in
remove some more proxy arguments
2d5e744Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+39−40
@@ -350,61 +350,61 @@ instance (SListI tys, IsProductType x xs, AllZip ToNullityParam xs tys)
350class FromValue (pg :: PGType) (y :: Type) where
350class FromValue (pg :: PGType) (y :: Type) where
351 -- | >>> newtype Id = Id { getId :: Int16 } deriving Show
351 -- | >>> newtype Id = Id { getId :: Int16 } deriving Show
352 -- >>> instance FromValue 'PGint2 Id where fromValue = fmap Id . fromValue
352 -- >>> instance FromValue 'PGint2 Id where fromValue = fmap Id . fromValue
353− fromValue :: proxy pg -> Decoding.Value y
353+ fromValue :: Decoding.Value y
354−instance FromValue 'PGbool Bool where fromValue _ = Decoding.bool
354+instance FromValue 'PGbool Bool where fromValue = Decoding.bool
355−instance FromValue 'PGint2 Int16 where fromValue _ = Decoding.int
355+instance FromValue 'PGint2 Int16 where fromValue = Decoding.int
356−instance FromValue 'PGint4 Int32 where fromValue _ = Decoding.int
356+instance FromValue 'PGint4 Int32 where fromValue = Decoding.int
357−instance FromValue 'PGint8 Int64 where fromValue _ = Decoding.int
357+instance FromValue 'PGint8 Int64 where fromValue = Decoding.int
358−instance FromValue 'PGfloat4 Float where fromValue _ = Decoding.float4
358+instance FromValue 'PGfloat4 Float where fromValue = Decoding.float4
359−instance FromValue 'PGfloat8 Double where fromValue _ = Decoding.float8
359+instance FromValue 'PGfloat8 Double where fromValue = Decoding.float8
360−instance FromValue 'PGnumeric Scientific where fromValue _ = Decoding.numeric
360+instance FromValue 'PGnumeric Scientific where fromValue = Decoding.numeric
361−instance FromValue 'PGuuid UUID where fromValue _ = Decoding.uuid
361+instance FromValue 'PGuuid UUID where fromValue = Decoding.uuid
362−instance FromValue 'PGinet (NetAddr IP) where fromValue _ = Decoding.inet
362+instance FromValue 'PGinet (NetAddr IP) where fromValue = Decoding.inet
363−instance FromValue ('PGchar 1) Char where fromValue _ = Decoding.char
363+instance FromValue ('PGchar 1) Char where fromValue = Decoding.char
364−instance FromValue 'PGtext Strict.Text where fromValue _ = Decoding.text_strict
364+instance FromValue 'PGtext Strict.Text where fromValue = Decoding.text_strict
365−instance FromValue 'PGtext Lazy.Text where fromValue _ = Decoding.text_lazy
365+instance FromValue 'PGtext Lazy.Text where fromValue = Decoding.text_lazy
366instance FromValue 'PGbytea Strict.ByteString where
366instance FromValue 'PGbytea Strict.ByteString where
367− fromValue _ = Decoding.bytea_strict
367+ fromValue = Decoding.bytea_strict
368instance FromValue 'PGbytea Lazy.ByteString where
368instance FromValue 'PGbytea Lazy.ByteString where
369− fromValue _ = Decoding.bytea_lazy
369+ fromValue = Decoding.bytea_lazy
370−instance FromValue 'PGdate Day where fromValue _ = Decoding.date
370+instance FromValue 'PGdate Day where fromValue = Decoding.date
371−instance FromValue 'PGtime TimeOfDay where fromValue _ = Decoding.time_int
371+instance FromValue 'PGtime TimeOfDay where fromValue = Decoding.time_int
372instance FromValue 'PGtimetz (TimeOfDay, TimeZone) where
372instance FromValue 'PGtimetz (TimeOfDay, TimeZone) where
373− fromValue _ = Decoding.timetz_int
373+ fromValue = Decoding.timetz_int
374instance FromValue 'PGtimestamp LocalTime where
374instance FromValue 'PGtimestamp LocalTime where
375− fromValue _ = Decoding.timestamp_int
375+ fromValue = Decoding.timestamp_int
376instance FromValue 'PGtimestamptz UTCTime where
376instance FromValue 'PGtimestamptz UTCTime where
377− fromValue _ = Decoding.timestamptz_int
377+ fromValue = Decoding.timestamptz_int
378instance FromValue 'PGinterval DiffTime where
378instance FromValue 'PGinterval DiffTime where
379− fromValue _ = Decoding.interval_int
379+ fromValue = Decoding.interval_int
380−instance FromValue 'PGjson Value where fromValue _ = Decoding.json_ast
380+instance FromValue 'PGjson Value where fromValue = Decoding.json_ast
381−instance FromValue 'PGjsonb Value where fromValue _ = Decoding.jsonb_ast
381+instance FromValue 'PGjsonb Value where fromValue = Decoding.jsonb_ast
382instance FromValue pg y
382instance FromValue pg y
383 => FromValue ('PGvararray ('Null pg)) (Vector (Maybe y)) where
383 => FromValue ('PGvararray ('Null pg)) (Vector (Maybe y)) where
384− fromValue _ = Decoding.array
384+ fromValue = Decoding.array
385 (Decoding.dimensionArray Vector.replicateM
385 (Decoding.dimensionArray Vector.replicateM
386− (Decoding.nullableValueArray (fromValue (Proxy @pg))))
386+ (Decoding.nullableValueArray (fromValue @pg)))
387instance FromValue pg y
387instance FromValue pg y
388 => FromValue ('PGvararray ('NotNull pg)) (Vector y) where
388 => FromValue ('PGvararray ('NotNull pg)) (Vector y) where
389− fromValue _ = Decoding.array
389+ fromValue = Decoding.array
390 (Decoding.dimensionArray Vector.replicateM
390 (Decoding.dimensionArray Vector.replicateM
391− (Decoding.valueArray (fromValue (Proxy @pg))))
391+ (Decoding.valueArray (fromValue @pg)))
392instance FromValue pg y
392instance FromValue pg y
393 => FromValue ('PGfixarray n ('Null pg)) (Vector (Maybe y)) where
393 => FromValue ('PGfixarray n ('Null pg)) (Vector (Maybe y)) where
394− fromValue _ = Decoding.array
394+ fromValue = Decoding.array
395 (Decoding.dimensionArray Vector.replicateM
395 (Decoding.dimensionArray Vector.replicateM
396− (Decoding.nullableValueArray (fromValue (Proxy @pg))))
396+ (Decoding.nullableValueArray (fromValue @pg)))
397instance FromValue pg y
397instance FromValue pg y
398 => FromValue ('PGfixarray n ('NotNull pg)) (Vector y) where
398 => FromValue ('PGfixarray n ('NotNull pg)) (Vector y) where
399− fromValue _ = Decoding.array
399+ fromValue = Decoding.array
400 (Decoding.dimensionArray Vector.replicateM
400 (Decoding.dimensionArray Vector.replicateM
401− (Decoding.valueArray (fromValue (Proxy @pg))))
401+ (Decoding.valueArray (fromValue @pg)))
402instance
402instance
403 ( IsEnumType y
403 ( IsEnumType y
404 , HasDatatypeInfo y
404 , HasDatatypeInfo y
405 , LabelsFrom y ~ labels
405 , LabelsFrom y ~ labels
406 ) => FromValue ('PGenum labels) y where
406 ) => FromValue ('PGenum labels) y where
407− fromValue _ =
407+ fromValue =
408 let
408 let
409 greadConstructor
409 greadConstructor
410 :: All ((~) '[]) xss
410 :: All ((~) '[]) xss
@@ -425,7 +425,7 @@ instance
425instance
425instance
426 ( FromRow fields y
426 ( FromRow fields y
427 ) => FromValue ('PGcomposite fields) y where
427 ) => FromValue ('PGcomposite fields) y where
428− fromValue p =
428+ fromValue =
429 let
429 let
430 -- <number of fields: 4 bytes>
430 -- <number of fields: 4 bytes>
431 -- [for each field]
431 -- [for each field]
@@ -438,11 +438,10 @@ instance
438 -- [end if]
438 -- [end if]
439 -- [end for]
439 -- [end for]
440 composite
440 composite
441− :: forall proxy pgs. SListI pgs
441+ :: forall pgs. SListI pgs
442− => proxy ('PGcomposite pgs)
443− -> Strict.ByteString
442+ => Strict.ByteString
444 -> Either Strict.Text (NP (K (Maybe Strict.ByteString)) pgs)
443 -> Either Strict.Text (NP (K (Maybe Strict.ByteString)) pgs)
445− composite _ = Decoding.valueParser $ do
444+ composite = Decoding.valueParser $ do
446 unitOfSize 4
445 unitOfSize 4
447 let
446 let
448 each _ = do
447 each _ = do
@@ -453,7 +452,7 @@ instance
453 else K . Just <$> bytesOfSize len
452 else K . Just <$> bytesOfSize len
454 htraverse' each (hpure Proxy :: NP Proxy pgs)
453 htraverse' each (hpure Proxy :: NP Proxy pgs)
455 in
454 in
456− Decoding.fn (fromRow @fields @y <=< composite p)
455+ Decoding.fn (fromRow @fields @y <=< composite)
457
456
458-- | A `FromField` constraint lifts the `FromValue` parser
457-- | A `FromField` constraint lifts the `FromValue` parser
459-- to a decoding of a @(Symbol, NullityType)@ to a `Type`,
458-- to a decoding of a @(Symbol, NullityType)@ to a `Type`,
@@ -468,13 +467,13 @@ instance FromValue pg y
468 fromField = Comp . \case
467 fromField = Comp . \case
469 K Nothing -> Left "fromField: saw NULL when expecting NOT NULL"
468 K Nothing -> Left "fromField: saw NULL when expecting NOT NULL"
470 K (Just bytestring) -> P <$>
469 K (Just bytestring) -> P <$>
471− Decoding.valueParser (fromValue @pg @y Proxy) bytestring
470+ Decoding.valueParser (fromValue @pg @y) bytestring
472instance FromValue pg y
471instance FromValue pg y
473 => FromField (column ::: 'Null pg) (column ::: Maybe y) where
472 => FromField (column ::: 'Null pg) (column ::: Maybe y) where
474 fromField = Comp . \case
473 fromField = Comp . \case
475 K Nothing -> Right $ P Nothing
474 K Nothing -> Right $ P Nothing
476 K (Just bytestring) -> P . Just <$>
475 K (Just bytestring) -> P . Just <$>
477− Decoding.valueParser (fromValue @pg @y Proxy) bytestring
476+ Decoding.valueParser (fromValue @pg @y) bytestring
478
477
479-- | A `FromRow` constraint generically sequences the parsings of the columns
478-- | A `FromRow` constraint generically sequences the parsings of the columns
480-- of a `RelationType` into the fields of a record `Type` provided they have
479-- of a `RelationType` into the fields of a record `Type` provided they have
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+1−1
@@ -417,7 +417,7 @@ instance Has field fields ty => IsLabel field
417 -> Expression schema relation grouping params ty ) where
417 -> Expression schema relation grouping params ty ) where
418 fromLabel expr = UnsafeExpression $
418 fromLabel expr = UnsafeExpression $
419 parenthesized (renderExpression expr) <> "." <>
419 parenthesized (renderExpression expr) <> "." <>
420− fromString (symbolVal (Proxy @field))
420+ renderSymbol @field
421
421
422instance Semigroup
422instance Semigroup
423 (Expression schema relations grouping params (nullity ('PGvararray ty))) where
423 (Expression schema relations grouping params (nullity ('PGvararray ty))) where
squeal-postgresql/src/Squeal/PostgreSQL/Render.hs+6−1
@@ -28,6 +28,7 @@ module Squeal.PostgreSQL.Render
28 , renderCommaSeparated
28 , renderCommaSeparated
29 , renderCommaSeparatedMaybe
29 , renderCommaSeparatedMaybe
30 , renderNat
30 , renderNat
31+ , renderSymbol
31 , RenderSQL (..)
32 , RenderSQL (..)
32 , printSQL
33 , printSQL
33 ) where
34 ) where
@@ -83,7 +84,11 @@ renderCommaSeparatedMaybe render
83
84
84-- | Render a promoted `Nat`.
85-- | Render a promoted `Nat`.
85renderNat :: forall n. KnownNat n => ByteString
86renderNat :: forall n. KnownNat n => ByteString
86−renderNat = fromString (show (natVal (Proxy @n)))
87+renderNat = fromString (show (natVal' (proxy# :: Proxy# n)))
88+
89+-- | Render a promoted `Symbol`.
90+renderSymbol :: forall s. KnownSymbol s => ByteString
91+renderSymbol = fromString (symbolVal' (proxy# :: Proxy# s))
87
92
88-- | A class for rendering SQL
93-- | A class for rendering SQL
89class RenderSQL sql where
94class RenderSQL sql where
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+1−1
@@ -632,7 +632,7 @@ data PGlabel (label :: Symbol) = PGlabel
632-- | Renders a label
632-- | Renders a label
633renderLabel :: KnownSymbol label => proxy label -> ByteString
633renderLabel :: KnownSymbol label => proxy label -> ByteString
634renderLabel (_ :: proxy label) =
634renderLabel (_ :: proxy label) =
635− "\'" <> fromString (symbolVal (Proxy @label)) <> "\'"
635+ "\'" <> renderSymbol @label <> "\'"
636-- | Renders a list of labels
636-- | Renders a list of labels
637renderLabels
637renderLabels
638 :: All KnownSymbol labels => NP PGlabel labels -> [ByteString]
638 :: All KnownSymbol labels => NP PGlabel labels -> [ByteString]