on dev help sign in
remove proxies from arguments
fe90800Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+13−15
@@ -198,7 +198,7 @@ class KnownNat n => HasParameter
198 :: TypeExpression schema ty
198 :: TypeExpression schema ty
199 -> Expression schema relations grouping params ty
199 -> Expression schema relations grouping params ty
200 parameter ty = UnsafeExpression $ parenthesized $
200 parameter ty = UnsafeExpression $ parenthesized $
201− "$" <> renderNat (Proxy @n) <+> "::"
201+ "$" <> renderNat @n <+> "::"
202 <+> renderTypeExpression ty
202 <+> renderTypeExpression ty
203instance {-# OVERLAPPING #-} HasParameter 1 schema (ty1:tys) ty1
203instance {-# OVERLAPPING #-} HasParameter 1 schema (ty1:tys) ty1
204instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) schema params ty)
204instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) schema params ty)
@@ -1157,19 +1157,17 @@ text :: TypeExpression schema (nullity 'PGtext)
1157text = UnsafeTypeExpression "text"
1157text = UnsafeTypeExpression "text"
1158-- | fixed-length character string
1158-- | fixed-length character string
1159char, character
1159char, character
1160− :: (KnownNat n, 1 <= n)
1160+ :: forall n schema nullity. (KnownNat n, 1 <= n)
1161− => proxy n
1162− -> TypeExpression schema (nullity ('PGchar n))
1161+ => TypeExpression schema (nullity ('PGchar n))
1163−char p = UnsafeTypeExpression $ "char(" <> renderNat p <> ")"
1162+char = UnsafeTypeExpression $ "char(" <> renderNat @n <> ")"
1164−character p = UnsafeTypeExpression $ "character(" <> renderNat p <> ")"
1163+character = UnsafeTypeExpression $ "character(" <> renderNat @n <> ")"
1165-- | variable-length character string
1164-- | variable-length character string
1166varchar, characterVarying
1165varchar, characterVarying
1167− :: (KnownNat n, 1 <= n)
1166+ :: forall n schema nullity. (KnownNat n, 1 <= n)
1168− => proxy n
1169− -> TypeExpression schema (nullity ('PGvarchar n))
1167+ => TypeExpression schema (nullity ('PGvarchar n))
1170−varchar p = UnsafeTypeExpression $ "varchar(" <> renderNat p <> ")"
1168+varchar = UnsafeTypeExpression $ "varchar(" <> renderNat @n <> ")"
1171−characterVarying p = UnsafeTypeExpression $
1169+characterVarying = UnsafeTypeExpression $
1172− "character varying(" <> renderNat p <> ")"
1170+ "character varying(" <> renderNat @n <> ")"
1173-- | binary data ("byte array")
1171-- | binary data ("byte array")
1174bytea :: TypeExpression schema (nullity 'PGbytea)
1172bytea :: TypeExpression schema (nullity 'PGbytea)
1175bytea = UnsafeTypeExpression "bytea"
1173bytea = UnsafeTypeExpression "bytea"
@@ -1217,7 +1215,7 @@ fixarray
1217 => TypeExpression schema pg
1215 => TypeExpression schema pg
1218 -> TypeExpression schema (nullity ('PGfixarray n pg))
1216 -> TypeExpression schema (nullity ('PGfixarray n pg))
1219fixarray ty = UnsafeTypeExpression $
1217fixarray ty = UnsafeTypeExpression $
1220− renderTypeExpression ty <> "[" <> renderNat (Proxy @n) <> "]"
1218+ renderTypeExpression ty <> "[" <> renderNat @n <> "]"
1221
1219
1222-- | `pgtype` is a demoted version of a `PGType`
1220-- | `pgtype` is a demoted version of a `PGType`
1223class PGTyped schema (ty :: PGType) where pgtype :: TypeExpression schema (nullity ty)
1221class PGTyped schema (ty :: PGType) where pgtype :: TypeExpression schema (nullity ty)
@@ -1230,9 +1228,9 @@ instance PGTyped schema 'PGfloat4 where pgtype = float4
1230instance PGTyped schema 'PGfloat8 where pgtype = float8
1228instance PGTyped schema 'PGfloat8 where pgtype = float8
1231instance PGTyped schema 'PGtext where pgtype = text
1229instance PGTyped schema 'PGtext where pgtype = text
1232instance (KnownNat n, 1 <= n)
1230instance (KnownNat n, 1 <= n)
1233− => PGTyped schema ('PGchar n) where pgtype = char (Proxy @n)
1231+ => PGTyped schema ('PGchar n) where pgtype = char @n
1234instance (KnownNat n, 1 <= n)
1232instance (KnownNat n, 1 <= n)
1235− => PGTyped schema ('PGvarchar n) where pgtype = varchar (Proxy @n)
1233+ => PGTyped schema ('PGvarchar n) where pgtype = varchar @n
1236instance PGTyped schema 'PGbytea where pgtype = bytea
1234instance PGTyped schema 'PGbytea where pgtype = bytea
1237instance PGTyped schema 'PGtimestamp where pgtype = timestamp
1235instance PGTyped schema 'PGtimestamp where pgtype = timestamp
1238instance PGTyped schema 'PGtimestamptz where pgtype = timestampWithTimeZone
1236instance PGTyped schema 'PGtimestamptz where pgtype = timestampWithTimeZone
squeal-postgresql/src/Squeal/PostgreSQL/Render.hs+5−3
@@ -9,12 +9,14 @@ Rendering helper functions.
9-}
9-}
10
10
11{-# LANGUAGE
11{-# LANGUAGE
12+ AllowAmbiguousTypes
12− FlexibleContexts
13+ , FlexibleContexts
13 , MagicHash
14 , MagicHash
14 , OverloadedStrings
15 , OverloadedStrings
15 , PolyKinds
16 , PolyKinds
16 , RankNTypes
17 , RankNTypes
17 , ScopedTypeVariables
18 , ScopedTypeVariables
19+ , TypeApplications
18#-}
20#-}
19
21
20module Squeal.PostgreSQL.Render
22module Squeal.PostgreSQL.Render
@@ -80,8 +82,8 @@ renderCommaSeparatedMaybe render
80 . hmap (K . render)
82 . hmap (K . render)
81
83
82-- | Render a promoted `Nat`.
84-- | Render a promoted `Nat`.
83−renderNat :: KnownNat n => proxy n -> ByteString
85+renderNat :: forall n. KnownNat n => ByteString
84−renderNat (_ :: proxy n) = fromString (show (natVal' (proxy# :: Proxy# n)))
86+renderNat = fromString (show (natVal (Proxy @n)))
85
87
86-- | A class for rendering SQL
88-- | A class for rendering SQL
87class RenderSQL sql where
89class RenderSQL sql where