on dev help sign in
function changes
40ad89aEitan Chatav
RELEASE NOTES.md+2−2
@@ -138,11 +138,11 @@ type Expr x
138 . Expression outer commons grp schemas params from x
138 . Expression outer commons grp schemas params from x
139```
139```
140
140
141−There is also a function type `(:-->)`, which is a subtype of the usual Haskell function
141+There is also a function type `(-->)`, which is a subtype of the usual Haskell function
142type `(->)`.
142type `(->)`.
143
143
144```Haskell
144```Haskell
145−type (:-->) x y
145+type (-->) x y
146 = forall outer commons grp schemas params from
146 = forall outer commons grp schemas params from
147 . Expression outer commons grp schemas params from x
147 . Expression outer commons grp schemas params from x
148 -> Expression outer commons grp schemas params from y
148 -> Expression outer commons grp schemas params from y
squeal-postgresql/src/Squeal/PostgreSQL/Definition/Function.hs+11−11
@@ -73,7 +73,7 @@ createFunction
73 -> NP (TypeExpression schemas) args
73 -> NP (TypeExpression schemas) args
74 -> TypeExpression schemas ret
74 -> TypeExpression schemas ret
75 -> FunctionDefinition schemas args ('Returns ret)
75 -> FunctionDefinition schemas args ('Returns ret)
76− -> Definition schemas (Alter sch (Create fun ('Function (args '::--> 'Returns ret)) schema) schemas)
76+ -> Definition schemas (Alter sch (Create fun ('Function (args :=> 'Returns ret)) schema) schemas)
77createFunction fun args ret fundef = UnsafeDefinition $
77createFunction fun args ret fundef = UnsafeDefinition $
78 "CREATE" <+> "FUNCTION" <+> renderSQL fun
78 "CREATE" <+> "FUNCTION" <+> renderSQL fun
79 <+> parenthesized (renderCommaSeparated renderSQL args)
79 <+> parenthesized (renderCommaSeparated renderSQL args)
@@ -87,7 +87,7 @@ createOrReplaceFunction
87 -> NP (TypeExpression schemas) args
87 -> NP (TypeExpression schemas) args
88 -> TypeExpression schemas ret
88 -> TypeExpression schemas ret
89 -> FunctionDefinition schemas args ('Returns ret)
89 -> FunctionDefinition schemas args ('Returns ret)
90− -> Definition schemas (Alter sch (CreateOrReplace fun ('Function (args '::--> 'Returns ret)) schema) schemas)
90+ -> Definition schemas (Alter sch (CreateOrReplace fun ('Function (args :=> 'Returns ret)) schema) schemas)
91createOrReplaceFunction fun args ret fundef = UnsafeDefinition $
91createOrReplaceFunction fun args ret fundef = UnsafeDefinition $
92 "CREATE" <+> "OR" <+> "REPLACE" <+> "FUNCTION" <+> renderSQL fun
92 "CREATE" <+> "OR" <+> "REPLACE" <+> "FUNCTION" <+> renderSQL fun
93 <+> parenthesized (renderCommaSeparated renderSQL args)
93 <+> parenthesized (renderCommaSeparated renderSQL args)
@@ -115,7 +115,7 @@ createSetFunction
115 -> NP (TypeExpression schemas) args
115 -> NP (TypeExpression schemas) args
116 -> NP (Aliased (TypeExpression schemas)) rets
116 -> NP (Aliased (TypeExpression schemas)) rets
117 -> FunctionDefinition schemas args ('ReturnsTable rets)
117 -> FunctionDefinition schemas args ('ReturnsTable rets)
118− -> Definition schemas (Alter sch (Create fun ('Function (args '::--> 'ReturnsTable rets)) schema) schemas)
118+ -> Definition schemas (Alter sch (Create fun ('Function (args :=> 'ReturnsTable rets)) schema) schemas)
119createSetFunction fun args rets fundef = UnsafeDefinition $
119createSetFunction fun args rets fundef = UnsafeDefinition $
120 "CREATE" <+> "FUNCTION" <+> renderSQL fun
120 "CREATE" <+> "FUNCTION" <+> renderSQL fun
121 <+> parenthesized (renderCommaSeparated renderSQL args)
121 <+> parenthesized (renderCommaSeparated renderSQL args)
@@ -128,14 +128,14 @@ createSetFunction fun args rets fundef = UnsafeDefinition $
128
128
129createOrReplaceSetFunction
129createOrReplaceSetFunction
130 :: ( Has sch schemas schema
130 :: ( Has sch schemas schema
131− , Has fun schema ('Function (args0 '::--> ret0))
131+ , Has fun schema ('Function (args0 :=> ret0))
132 , SOP.SListI args
132 , SOP.SListI args
133 , SOP.SListI rets )
133 , SOP.SListI rets )
134 => QualifiedAlias sch fun
134 => QualifiedAlias sch fun
135 -> NP (TypeExpression schemas) args
135 -> NP (TypeExpression schemas) args
136 -> NP (Aliased (TypeExpression schemas)) rets
136 -> NP (Aliased (TypeExpression schemas)) rets
137 -> FunctionDefinition schemas args ('ReturnsTable rets)
137 -> FunctionDefinition schemas args ('ReturnsTable rets)
138− -> Definition schemas (Alter sch (CreateOrReplace fun ('Function (args '::--> 'ReturnsTable rets)) schema) schemas)
138+ -> Definition schemas (Alter sch (CreateOrReplace fun ('Function (args :=> 'ReturnsTable rets)) schema) schemas)
139createOrReplaceSetFunction fun args rets fundef = UnsafeDefinition $
139createOrReplaceSetFunction fun args rets fundef = UnsafeDefinition $
140 "CREATE" <+> "OR" <+> "REPLACE" <+> "FUNCTION" <+> renderSQL fun
140 "CREATE" <+> "OR" <+> "REPLACE" <+> "FUNCTION" <+> renderSQL fun
141 <+> parenthesized (renderCommaSeparated renderSQL args)
141 <+> parenthesized (renderCommaSeparated renderSQL args)
@@ -149,9 +149,9 @@ createOrReplaceSetFunction fun args rets fundef = UnsafeDefinition $
149createBinaryOp
149createBinaryOp
150 :: forall op fun sch schemas schema x y z.
150 :: forall op fun sch schemas schema x y z.
151 ( Has sch schemas schema
151 ( Has sch schemas schema
152− , Has fun schema ('Function ('[x,y] '::--> 'Returns z))
152+ , Has fun schema ('Function ('[x,y] :=> 'Returns z))
153 , KnownSymbol op )
153 , KnownSymbol op )
154− => Alias fun
154+ => QualifiedAlias sch fun
155 -> TypeExpression schemas x
155 -> TypeExpression schemas x
156 -> TypeExpression schemas y
156 -> TypeExpression schemas y
157 -> Definition schemas
157 -> Definition schemas
@@ -168,9 +168,9 @@ createBinaryOp fun x y = UnsafeDefinition $
168createLeftOp
168createLeftOp
169 :: forall op fun sch schemas schema x y.
169 :: forall op fun sch schemas schema x y.
170 ( Has sch schemas schema
170 ( Has sch schemas schema
171− , Has fun schema ('Function ('[x] '::--> 'Returns y))
171+ , Has fun schema ('Function ('[x] :=> 'Returns y))
172 , KnownSymbol op )
172 , KnownSymbol op )
173− => Alias fun
173+ => QualifiedAlias sch fun
174 -> TypeExpression schemas x
174 -> TypeExpression schemas x
175 -> Definition schemas
175 -> Definition schemas
176 (Alter sch (Create op ('Operator ('LeftOp x y)) schema) schemas)
176 (Alter sch (Create op ('Operator ('LeftOp x y)) schema) schemas)
@@ -185,9 +185,9 @@ createLeftOp fun x = UnsafeDefinition $
185createRightOp
185createRightOp
186 :: forall op fun sch schemas schema x y.
186 :: forall op fun sch schemas schema x y.
187 ( Has sch schemas schema
187 ( Has sch schemas schema
188− , Has fun schema ('Function ('[x] '::--> 'Returns y))
188+ , Has fun schema ('Function ('[x] :=> 'Returns y))
189 , KnownSymbol op )
189 , KnownSymbol op )
190− => Alias fun
190+ => QualifiedAlias sch fun
191 -> TypeExpression schemas x
191 -> TypeExpression schemas x
192 -> Definition schemas
192 -> Definition schemas
193 (Alter sch (Create op ('Operator ('RightOp x y)) schema) schemas)
193 (Alter sch (Create op ('Operator ('RightOp x y)) schema) schemas)
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+10−10
@@ -34,7 +34,7 @@ module Squeal.PostgreSQL.Expression
34 ( -- * Expression
34 ( -- * Expression
35 Expression (..)
35 Expression (..)
36 , Expr
36 , Expr
37− , (:-->)
37+ , type (-->)
38 , FunctionDB
38 , FunctionDB
39 , unsafeFunction
39 , unsafeFunction
40 , function
40 , function
@@ -48,7 +48,7 @@ module Squeal.PostgreSQL.Expression
48 , binaryOp
48 , binaryOp
49 , FunctionVar
49 , FunctionVar
50 , unsafeFunctionVar
50 , unsafeFunctionVar
51− , FunctionN
51+ , type (--->)
52 , FunctionNDB
52 , FunctionNDB
53 , unsafeFunctionN
53 , unsafeFunctionN
54 , functionN
54 , functionN
@@ -159,7 +159,7 @@ type OperatorDB schemas x1 x2 y
159-- This is a subtype of the usual Haskell function type `Prelude.->`,
159-- This is a subtype of the usual Haskell function type `Prelude.->`,
160-- indeed a subcategory as it is closed under the usual
160-- indeed a subcategory as it is closed under the usual
161-- `Prelude..` and `Prelude.id`.
161-- `Prelude..` and `Prelude.id`.
162−type (:-->) x y
162+type (-->) x y
163 = forall outer commons grp schemas params from
163 = forall outer commons grp schemas params from
164 . Expression outer commons grp schemas params from x
164 . Expression outer commons grp schemas params from x
165 -- ^ input
165 -- ^ input
@@ -179,7 +179,7 @@ Use the `*:` operator to end your argument lists, like so.
179>>> printSQL (unsafeFunctionN "fun" (true :* false :* localTime *: true))
179>>> printSQL (unsafeFunctionN "fun" (true :* false :* localTime *: true))
180fun(TRUE, FALSE, LOCALTIME, TRUE)
180fun(TRUE, FALSE, LOCALTIME, TRUE)
181-}
181-}
182−type FunctionN xs y
182+type (--->) xs y
183 = forall outer commons grp schemas params from
183 = forall outer commons grp schemas params from
184 . NP (Expression outer commons grp schemas params from) xs
184 . NP (Expression outer commons grp schemas params from) xs
185 -- ^ inputs
185 -- ^ inputs
@@ -327,7 +327,7 @@ binaryOp = unsafeBinaryOp $ renderSymbol @op
327
327
328-- | >>> printSQL $ unsafeLeftOp "NOT" true
328-- | >>> printSQL $ unsafeLeftOp "NOT" true
329-- (NOT TRUE)
329-- (NOT TRUE)
330−unsafeLeftOp :: ByteString -> x :--> y
330+unsafeLeftOp :: ByteString -> x --> y
331unsafeLeftOp op x = UnsafeExpression $ parenthesized $ op <+> renderSQL x
331unsafeLeftOp op x = UnsafeExpression $ parenthesized $ op <+> renderSQL x
332
332
333leftOp
333leftOp
@@ -339,7 +339,7 @@ leftOp = unsafeLeftOp $ renderSymbol @op
339
339
340-- | >>> printSQL $ true & unsafeRightOp "IS NOT TRUE"
340-- | >>> printSQL $ true & unsafeRightOp "IS NOT TRUE"
341-- (TRUE IS NOT TRUE)
341-- (TRUE IS NOT TRUE)
342−unsafeRightOp :: ByteString -> x :--> y
342+unsafeRightOp :: ByteString -> x --> y
343unsafeRightOp op x = UnsafeExpression $ parenthesized $ renderSQL x <+> op
343unsafeRightOp op x = UnsafeExpression $ parenthesized $ renderSQL x <+> op
344
344
345rightOp
345rightOp
@@ -351,25 +351,25 @@ rightOp = unsafeRightOp $ renderSymbol @op
351
351
352-- | >>> printSQL $ unsafeFunction "f" true
352-- | >>> printSQL $ unsafeFunction "f" true
353-- f(TRUE)
353-- f(TRUE)
354−unsafeFunction :: ByteString -> x :--> y
354+unsafeFunction :: ByteString -> x --> y
355unsafeFunction fun x = UnsafeExpression $
355unsafeFunction fun x = UnsafeExpression $
356 fun <> parenthesized (renderSQL x)
356 fun <> parenthesized (renderSQL x)
357
357
358function
358function
359− :: (Has sch schemas schema, Has fun schema ('Function ('[x] '::--> 'Returns y)))
359+ :: (Has sch schemas schema, Has fun schema ('Function ('[x] :=> 'Returns y)))
360 => QualifiedAlias sch fun
360 => QualifiedAlias sch fun
361 -> FunctionDB schemas x y
361 -> FunctionDB schemas x y
362function = unsafeFunction . renderSQL
362function = unsafeFunction . renderSQL
363
363
364-- | >>> printSQL $ unsafeFunctionN "f" (currentTime :* localTimestamp :* false *: literal 'a')
364-- | >>> printSQL $ unsafeFunctionN "f" (currentTime :* localTimestamp :* false *: literal 'a')
365-- f(CURRENT_TIME, LOCALTIMESTAMP, FALSE, E'a')
365-- f(CURRENT_TIME, LOCALTIMESTAMP, FALSE, E'a')
366−unsafeFunctionN :: SListI xs => ByteString -> FunctionN xs y
366+unsafeFunctionN :: SListI xs => ByteString -> xs ---> y
367unsafeFunctionN fun xs = UnsafeExpression $
367unsafeFunctionN fun xs = UnsafeExpression $
368 fun <> parenthesized (renderCommaSeparated renderSQL xs)
368 fun <> parenthesized (renderCommaSeparated renderSQL xs)
369
369
370functionN
370functionN
371 :: ( Has sch schemas schema
371 :: ( Has sch schemas schema
372− , Has fun schema ('Function (xs '::--> 'Returns y))
372+ , Has fun schema ('Function (xs :=> 'Returns y))
373 , SListI xs )
373 , SListI xs )
374 => QualifiedAlias sch fun
374 => QualifiedAlias sch fun
375 -> FunctionNDB schemas xs y
375 -> FunctionNDB schemas xs y
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Collection.hs+2−2
@@ -111,14 +111,14 @@ array2 xss = UnsafeExpression $ "ARRAY" <>
111
111
112-- | >>> printSQL $ cardinality (array [null_, false, true])
112-- | >>> printSQL $ cardinality (array [null_, false, true])
113-- cardinality(ARRAY[NULL, FALSE, TRUE])
113-- cardinality(ARRAY[NULL, FALSE, TRUE])
114−cardinality :: null ('PGvararray ty) :--> null 'PGint8
114+cardinality :: null ('PGvararray ty) --> null 'PGint8
115cardinality = unsafeFunction "cardinality"
115cardinality = unsafeFunction "cardinality"
116
116
117-- | >>> printSQL $ array [null_, false, true] & index 2
117-- | >>> printSQL $ array [null_, false, true] & index 2
118-- (ARRAY[NULL, FALSE, TRUE])[2]
118-- (ARRAY[NULL, FALSE, TRUE])[2]
119index
119index
120 :: Word64 -- ^ index
120 :: Word64 -- ^ index
121− -> null ('PGvararray ty) :--> NullifyType ty
121+ -> null ('PGvararray ty) --> NullifyType ty
122index n expr = UnsafeExpression $
122index n expr = UnsafeExpression $
123 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
123 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
124
124
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Comparison.hs+6−6
@@ -162,7 +162,7 @@ isNotDistinctFrom = unsafeBinaryOp "IS NOT DISTINCT FROM"
162>>> printSQL $ true & isTrue
162>>> printSQL $ true & isTrue
163(TRUE IS TRUE)
163(TRUE IS TRUE)
164-}
164-}
165−isTrue :: null0 'PGbool :--> null1 'PGbool
165+isTrue :: null0 'PGbool --> null1 'PGbool
166isTrue = unsafeRightOp "IS TRUE"
166isTrue = unsafeRightOp "IS TRUE"
167
167
168{- | is false or unknown
168{- | is false or unknown
@@ -170,7 +170,7 @@ isTrue = unsafeRightOp "IS TRUE"
170>>> printSQL $ true & isNotTrue
170>>> printSQL $ true & isNotTrue
171(TRUE IS NOT TRUE)
171(TRUE IS NOT TRUE)
172-}
172-}
173−isNotTrue :: null0 'PGbool :--> null1 'PGbool
173+isNotTrue :: null0 'PGbool --> null1 'PGbool
174isNotTrue = unsafeRightOp "IS NOT TRUE"
174isNotTrue = unsafeRightOp "IS NOT TRUE"
175
175
176{- | is false
176{- | is false
@@ -178,7 +178,7 @@ isNotTrue = unsafeRightOp "IS NOT TRUE"
178>>> printSQL $ true & isFalse
178>>> printSQL $ true & isFalse
179(TRUE IS FALSE)
179(TRUE IS FALSE)
180-}
180-}
181−isFalse :: null0 'PGbool :--> null1 'PGbool
181+isFalse :: null0 'PGbool --> null1 'PGbool
182isFalse = unsafeRightOp "IS FALSE"
182isFalse = unsafeRightOp "IS FALSE"
183
183
184{- | is true or unknown
184{- | is true or unknown
@@ -186,7 +186,7 @@ isFalse = unsafeRightOp "IS FALSE"
186>>> printSQL $ true & isNotFalse
186>>> printSQL $ true & isNotFalse
187(TRUE IS NOT FALSE)
187(TRUE IS NOT FALSE)
188-}
188-}
189−isNotFalse :: null0 'PGbool :--> null1 'PGbool
189+isNotFalse :: null0 'PGbool --> null1 'PGbool
190isNotFalse = unsafeRightOp "IS NOT FALSE"
190isNotFalse = unsafeRightOp "IS NOT FALSE"
191
191
192{- | is unknown
192{- | is unknown
@@ -194,7 +194,7 @@ isNotFalse = unsafeRightOp "IS NOT FALSE"
194>>> printSQL $ true & isUnknown
194>>> printSQL $ true & isUnknown
195(TRUE IS UNKNOWN)
195(TRUE IS UNKNOWN)
196-}
196-}
197−isUnknown :: null0 'PGbool :--> null1 'PGbool
197+isUnknown :: null0 'PGbool --> null1 'PGbool
198isUnknown = unsafeRightOp "IS UNKNOWN"
198isUnknown = unsafeRightOp "IS UNKNOWN"
199
199
200{- | is true or false
200{- | is true or false
@@ -202,5 +202,5 @@ isUnknown = unsafeRightOp "IS UNKNOWN"
202>>> printSQL $ true & isNotUnknown
202>>> printSQL $ true & isNotUnknown
203(TRUE IS NOT UNKNOWN)
203(TRUE IS NOT UNKNOWN)
204-}
204-}
205−isNotUnknown :: null0 'PGbool :--> null1 'PGbool
205+isNotUnknown :: null0 'PGbool --> null1 'PGbool
206isNotUnknown = unsafeRightOp "IS NOT UNKNOWN"
206isNotUnknown = unsafeRightOp "IS NOT UNKNOWN"
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Json.hs+27−34
@@ -188,7 +188,7 @@ Table 9.45: JSON creation functions
188-- otherwise, a scalar value is produced. For any scalar type other than a
188-- otherwise, a scalar value is produced. For any scalar type other than a
189-- number, a Boolean, or a null value, the text representation will be used, in
189-- number, a Boolean, or a null value, the text representation will be used, in
190-- such a fashion that it is a valid json value.
190-- such a fashion that it is a valid json value.
191−toJson :: null ty :--> null 'PGjson
191+toJson :: null ty --> null 'PGjson
192toJson = unsafeFunction "to_json"
192toJson = unsafeFunction "to_json"
193
193
194-- | Returns the value as jsonb. Arrays and composites are converted
194-- | Returns the value as jsonb. Arrays and composites are converted
@@ -197,26 +197,26 @@ toJson = unsafeFunction "to_json"
197-- otherwise, a scalar value is produced. For any scalar type other than a
197-- otherwise, a scalar value is produced. For any scalar type other than a
198-- number, a Boolean, or a null value, the text representation will be used, in
198-- number, a Boolean, or a null value, the text representation will be used, in
199-- such a fashion that it is a valid jsonb value.
199-- such a fashion that it is a valid jsonb value.
200−toJsonb :: null ty :--> null 'PGjsonb
200+toJsonb :: null ty --> null 'PGjsonb
201toJsonb = unsafeFunction "to_jsonb"
201toJsonb = unsafeFunction "to_jsonb"
202
202
203-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
203-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
204-- becomes a JSON array of arrays.
204-- becomes a JSON array of arrays.
205−arrayToJson :: null ('PGvararray ty) :--> null 'PGjson
205+arrayToJson :: null ('PGvararray ty) --> null 'PGjson
206arrayToJson = unsafeFunction "array_to_json"
206arrayToJson = unsafeFunction "array_to_json"
207
207
208-- | Returns the row as a JSON object.
208-- | Returns the row as a JSON object.
209−rowToJson :: null ('PGcomposite ty) :--> null 'PGjson
209+rowToJson :: null ('PGcomposite ty) --> null 'PGjson
210rowToJson = unsafeFunction "row_to_json"
210rowToJson = unsafeFunction "row_to_json"
211
211
212-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
212-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
213-- argument list.
213-- argument list.
214−jsonBuildArray :: SOP.SListI tuple => FunctionN tuple (null 'PGjson)
214+jsonBuildArray :: SOP.SListI tuple => tuple ---> null 'PGjson
215jsonBuildArray = unsafeFunctionN "json_build_array"
215jsonBuildArray = unsafeFunctionN "json_build_array"
216
216
217-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
217-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
218-- variadic argument list.
218-- variadic argument list.
219−jsonbBuildArray :: SOP.SListI tuple => FunctionN tuple (null 'PGjsonb)
219+jsonbBuildArray :: SOP.SListI tuple => tuple ---> null 'PGjsonb
220jsonbBuildArray = unsafeFunctionN "jsonb_build_array"
220jsonbBuildArray = unsafeFunctionN "jsonb_build_array"
221
221
222-- | Builds a possibly-heterogeneously-typed JSON object out of a variadic
222-- | Builds a possibly-heterogeneously-typed JSON object out of a variadic
@@ -224,10 +224,10 @@ jsonbBuildArray = unsafeFunctionN "jsonb_build_array"
224-- and values.
224-- and values.
225class SOP.SListI tys => JsonBuildObject tys where
225class SOP.SListI tys => JsonBuildObject tys where
226
226
227− jsonBuildObject :: FunctionN tys (null 'PGjson)
227+ jsonBuildObject :: tys ---> null 'PGjson
228 jsonBuildObject = unsafeFunctionN "json_build_object"
228 jsonBuildObject = unsafeFunctionN "json_build_object"
229
229
230− jsonbBuildObject :: FunctionN tys (null 'PGjsonb)
230+ jsonbBuildObject :: tys ---> null 'PGjsonb
231 jsonbBuildObject = unsafeFunctionN "jsonb_build_object"
231 jsonbBuildObject = unsafeFunctionN "jsonb_build_object"
232
232
233instance JsonBuildObject '[]
233instance JsonBuildObject '[]
@@ -240,7 +240,7 @@ instance (JsonBuildObject tys, key `In` PGJsonKey)
240-- which are taken as a key/value pair.
240-- which are taken as a key/value pair.
241jsonObject
241jsonObject
242 :: null ('PGfixarray '[n,2] ('NotNull 'PGtext))
242 :: null ('PGfixarray '[n,2] ('NotNull 'PGtext))
243− :--> null 'PGjson
243+ --> null 'PGjson
244jsonObject = unsafeFunction "json_object"
244jsonObject = unsafeFunction "json_object"
245
245
246-- | Builds a binary JSON object out of a text array.
246-- | Builds a binary JSON object out of a text array.
@@ -249,24 +249,24 @@ jsonObject = unsafeFunction "json_object"
249-- which are taken as a key/value pair.
249-- which are taken as a key/value pair.
250jsonbObject
250jsonbObject
251 :: null ('PGfixarray '[n,2] ('NotNull 'PGtext))
251 :: null ('PGfixarray '[n,2] ('NotNull 'PGtext))
252− :--> null 'PGjsonb
252+ --> null 'PGjsonb
253jsonbObject = unsafeFunction "jsonb_object"
253jsonbObject = unsafeFunction "jsonb_object"
254
254
255-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
255-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
256-- keys and one for values, that are zipped pairwise to create a JSON object.
256-- keys and one for values, that are zipped pairwise to create a JSON object.
257−jsonZipObject :: FunctionN
257+jsonZipObject ::
258 '[ null ('PGvararray ('NotNull 'PGtext))
258 '[ null ('PGvararray ('NotNull 'PGtext))
259 , null ('PGvararray ('NotNull 'PGtext)) ]
259 , null ('PGvararray ('NotNull 'PGtext)) ]
260− ( null 'PGjson )
260+ ---> null 'PGjson
261jsonZipObject = unsafeFunctionN "json_object"
261jsonZipObject = unsafeFunctionN "json_object"
262
262
263-- | This is an alternate form of 'jsonbObject' that takes two arrays; one for
263-- | This is an alternate form of 'jsonbObject' that takes two arrays; one for
264-- keys and one for values, that are zipped pairwise to create a binary JSON
264-- keys and one for values, that are zipped pairwise to create a binary JSON
265-- object.
265-- object.
266−jsonbZipObject :: FunctionN
266+jsonbZipObject ::
267 '[ null ('PGvararray ('NotNull 'PGtext))
267 '[ null ('PGvararray ('NotNull 'PGtext))
268 , null ('PGvararray ('NotNull 'PGtext)) ]
268 , null ('PGvararray ('NotNull 'PGtext)) ]
269− ( null 'PGjsonb )
269+ ---> null 'PGjsonb
270jsonbZipObject = unsafeFunctionN "jsonb_object"
270jsonbZipObject = unsafeFunctionN "jsonb_object"
271
271
272{-----------------------------------------
272{-----------------------------------------
@@ -274,31 +274,31 @@ Table 9.46: JSON processing functions
274-----------------------------------------}
274-----------------------------------------}
275
275
276-- | Returns the number of elements in the outermost JSON array.
276-- | Returns the number of elements in the outermost JSON array.
277−jsonArrayLength :: null 'PGjson :--> null 'PGint4
277+jsonArrayLength :: null 'PGjson --> null 'PGint4
278jsonArrayLength = unsafeFunction "json_array_length"
278jsonArrayLength = unsafeFunction "json_array_length"
279
279
280-- | Returns the number of elements in the outermost binary JSON array.
280-- | Returns the number of elements in the outermost binary JSON array.
281−jsonbArrayLength :: null 'PGjsonb :--> null 'PGint4
281+jsonbArrayLength :: null 'PGjsonb --> null 'PGint4
282jsonbArrayLength = unsafeFunction "jsonb_array_length"
282jsonbArrayLength = unsafeFunction "jsonb_array_length"
283
283
284-- | Returns the type of the outermost JSON value as a text string. Possible
284-- | Returns the type of the outermost JSON value as a text string. Possible
285-- types are object, array, string, number, boolean, and null.
285-- types are object, array, string, number, boolean, and null.
286−jsonTypeof :: null 'PGjson :--> null 'PGtext
286+jsonTypeof :: null 'PGjson --> null 'PGtext
287jsonTypeof = unsafeFunction "json_typeof"
287jsonTypeof = unsafeFunction "json_typeof"
288
288
289-- | Returns the type of the outermost binary JSON value as a text string.
289-- | Returns the type of the outermost binary JSON value as a text string.
290-- Possible types are object, array, string, number, boolean, and null.
290-- Possible types are object, array, string, number, boolean, and null.
291−jsonbTypeof :: null 'PGjsonb :--> null 'PGtext
291+jsonbTypeof :: null 'PGjsonb --> null 'PGtext
292jsonbTypeof = unsafeFunction "jsonb_typeof"
292jsonbTypeof = unsafeFunction "jsonb_typeof"
293
293
294-- | Returns its argument with all object fields that have null values omitted.
294-- | Returns its argument with all object fields that have null values omitted.
295-- Other null values are untouched.
295-- Other null values are untouched.
296−jsonStripNulls :: null 'PGjson :--> null 'PGjson
296+jsonStripNulls :: null 'PGjson --> null 'PGjson
297jsonStripNulls = unsafeFunction "json_strip_nulls"
297jsonStripNulls = unsafeFunction "json_strip_nulls"
298
298
299-- | Returns its argument with all object fields that have null values omitted.
299-- | Returns its argument with all object fields that have null values omitted.
300-- Other null values are untouched.
300-- Other null values are untouched.
301−jsonbStripNulls :: null 'PGjsonb :--> null 'PGjsonb
301+jsonbStripNulls :: null 'PGjsonb --> null 'PGjsonb
302jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
302jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
303
303
304-- | @ jsonbSet target path new_value create_missing @
304-- | @ jsonbSet target path new_value create_missing @
@@ -309,12 +309,9 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
309-- item designated by path does not exist. As with the path orientated
309-- item designated by path does not exist. As with the path orientated
310-- operators, negative integers that appear in path count from the end of JSON
310-- operators, negative integers that appear in path count from the end of JSON
311-- arrays.
311-- arrays.
312−jsonbSet
312+jsonbSet ::
313− :: FunctionN
314− '[ null 'PGjsonb
315− , null ('PGvararray ('NotNull 'PGtext))
313+ '[ null 'PGjsonb, null ('PGvararray ('NotNull 'PGtext))
316− , null 'PGjsonb
317− , null 'PGbool ] (null 'PGjsonb)
314+ , null 'PGjsonb, null 'PGbool ] ---> null 'PGjsonb
318jsonbSet = unsafeFunctionN "jsonbSet"
315jsonbSet = unsafeFunctionN "jsonbSet"
319
316
320-- | @ jsonbInsert target path new_value insert_after @
317-- | @ jsonbInsert target path new_value insert_after @
@@ -326,19 +323,15 @@ jsonbSet = unsafeFunctionN "jsonbSet"
326-- path is in JSONB object, @new_value@ will be inserted only if target does not
323-- path is in JSONB object, @new_value@ will be inserted only if target does not
327-- exist. As with the path orientated operators, negative integers that appear
324-- exist. As with the path orientated operators, negative integers that appear
328-- in path count from the end of JSON arrays.
325-- in path count from the end of JSON arrays.
329−jsonbInsert
326+jsonbInsert ::
330− :: FunctionN
331− '[ null 'PGjsonb
332− , null ('PGvararray ('NotNull 'PGtext))
327+ '[ null 'PGjsonb, null ('PGvararray ('NotNull 'PGtext))
333− , null 'PGjsonb
334− , null 'PGbool ] (null 'PGjsonb)
328+ , null 'PGjsonb, null 'PGbool ] ---> null 'PGjsonb
335jsonbInsert = unsafeFunctionN "jsonb_insert"
329jsonbInsert = unsafeFunctionN "jsonb_insert"
336
330
337-- | Returns its argument as indented JSON text.
331-- | Returns its argument as indented JSON text.
338−jsonbPretty :: null 'PGjsonb :--> null 'PGtext
332+jsonbPretty :: null 'PGjsonb --> null 'PGtext
339jsonbPretty = unsafeFunction "jsonb_pretty"
333jsonbPretty = unsafeFunction "jsonb_pretty"
340
334
341−
342{- | Expands the outermost JSON object into a set of key/value pairs.
335{- | Expands the outermost JSON object into a set of key/value pairs.
343
336
344>>> printSQL (select Star (from (jsonEach (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))))
337>>> printSQL (select Star (from (jsonEach (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))))
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Logic.hs+1−1
@@ -47,7 +47,7 @@ false = UnsafeExpression "FALSE"
47
47
48-- | >>> printSQL $ not_ true
48-- | >>> printSQL $ not_ true
49-- (NOT TRUE)
49-- (NOT TRUE)
50−not_ :: null 'PGbool :--> null 'PGbool
50+not_ :: null 'PGbool --> null 'PGbool
51not_ = unsafeLeftOp "NOT"
51not_ = unsafeLeftOp "NOT"
52
52
53-- | >>> printSQL $ true .&& false
53-- | >>> printSQL $ true .&& false
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Math.hs+4−6
@@ -37,9 +37,7 @@ import Squeal.PostgreSQL.Schema
37-- in printSQL expression
37-- in printSQL expression
38-- :}
38-- :}
39-- atan2(pi(), 2)
39-- atan2(pi(), 2)
40−atan2_
41− :: float `In` PGFloating
42− => FunctionN '[ null float, null float] (null float)
40+atan2_ :: float `In` PGFloating => '[ null float, null float] ---> null float
43atan2_ = unsafeFunctionN "atan2"
41atan2_ = unsafeFunctionN "atan2"
44
42
45
43
@@ -78,7 +76,7 @@ rem_ = unsafeBinaryOp "%"
78-- in printSQL expression
76-- in printSQL expression
79-- :}
77-- :}
80-- trunc(pi())
78-- trunc(pi())
81−trunc :: frac `In` PGFloating => null frac :--> null frac
79+trunc :: frac `In` PGFloating => null frac --> null frac
82trunc = unsafeFunction "trunc"
80trunc = unsafeFunction "trunc"
83
81
84-- | >>> :{
82-- | >>> :{
@@ -88,7 +86,7 @@ trunc = unsafeFunction "trunc"
88-- in printSQL expression
86-- in printSQL expression
89-- :}
87-- :}
90-- round(pi())
88-- round(pi())
91−round_ :: frac `In` PGFloating => null frac :--> null frac
89+round_ :: frac `In` PGFloating => null frac --> null frac
92round_ = unsafeFunction "round"
90round_ = unsafeFunction "round"
93
91
94-- | >>> :{
92-- | >>> :{
@@ -98,5 +96,5 @@ round_ = unsafeFunction "round"
98-- in printSQL expression
96-- in printSQL expression
99-- :}
97-- :}
100-- ceiling(pi())
98-- ceiling(pi())
101−ceiling_ :: frac `In` PGFloating => null frac :--> null frac
99+ceiling_ :: frac `In` PGFloating => null frac --> null frac
102ceiling_ = unsafeFunction "ceiling"
100ceiling_ = unsafeFunction "ceiling"
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Null.hs+4−4
@@ -44,7 +44,7 @@ null_ = UnsafeExpression "NULL"
44--
44--
45-- >>> printSQL $ notNull true
45-- >>> printSQL $ notNull true
46-- TRUE
46-- TRUE
47−notNull :: 'NotNull ty :--> 'Null ty
47+notNull :: 'NotNull ty --> 'Null ty
48notNull = UnsafeExpression . renderSQL
48notNull = UnsafeExpression . renderSQL
49
49
50-- | return the leftmost value which is not NULL
50-- | return the leftmost value which is not NULL
@@ -69,12 +69,12 @@ fromNull notNullx nullx = coalesce [nullx] notNullx
69
69
70-- | >>> printSQL $ null_ & isNull
70-- | >>> printSQL $ null_ & isNull
71-- NULL IS NULL
71-- NULL IS NULL
72−isNull :: 'Null ty :--> null 'PGbool
72+isNull :: 'Null ty --> null 'PGbool
73isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
73isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
74
74
75-- | >>> printSQL $ null_ & isNotNull
75-- | >>> printSQL $ null_ & isNotNull
76-- NULL IS NOT NULL
76-- NULL IS NOT NULL
77−isNotNull :: 'Null ty :--> null 'PGbool
77+isNotNull :: 'Null ty --> null 'PGbool
78isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
78isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
79
79
80-- | analagous to `maybe` using @IS NULL@
80-- | analagous to `maybe` using @IS NULL@
@@ -100,5 +100,5 @@ matchNull y f x = ifThenElse (isNull x) y
100>>> printSQL expr
100>>> printSQL expr
101NULLIF(FALSE, ($1 :: bool))
101NULLIF(FALSE, ($1 :: bool))
102-}
102-}
103−nullIf :: FunctionN '[ 'NotNull ty, 'NotNull ty] ('Null ty)
103+nullIf :: '[ 'NotNull ty, 'NotNull ty] ---> 'Null ty
104nullIf = unsafeFunctionN "NULLIF"
104nullIf = unsafeFunctionN "NULLIF"
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Range.hs+8−9
@@ -205,27 +205,26 @@ whole = NonEmpty Infinite Infinite
205(@-) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
205(@-) :: Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
206(@-) = unsafeBinaryOp "-"
206(@-) = unsafeBinaryOp "-"
207
207
208−lowerBound :: null ('PGrange ty) :--> 'Null ty
208+lowerBound :: null ('PGrange ty) --> 'Null ty
209lowerBound = unsafeFunction "lower"
209lowerBound = unsafeFunction "lower"
210
210
211−upperBound :: null ('PGrange ty) :--> 'Null ty
211+upperBound :: null ('PGrange ty) --> 'Null ty
212upperBound = unsafeFunction "upper"
212upperBound = unsafeFunction "upper"
213
213
214−isEmpty :: null ('PGrange ty) :--> 'Null 'PGbool
214+isEmpty :: null ('PGrange ty) --> 'Null 'PGbool
215isEmpty = unsafeFunction "isempty"
215isEmpty = unsafeFunction "isempty"
216
216
217−lowerInc :: null ('PGrange ty) :--> 'Null 'PGbool
217+lowerInc :: null ('PGrange ty) --> 'Null 'PGbool
218lowerInc = unsafeFunction "lower_inc"
218lowerInc = unsafeFunction "lower_inc"
219
219
220−lowerInf :: null ('PGrange ty) :--> 'Null 'PGbool
220+lowerInf :: null ('PGrange ty) --> 'Null 'PGbool
221lowerInf = unsafeFunction "lower_inf"
221lowerInf = unsafeFunction "lower_inf"
222
222
223−upperInc :: null ('PGrange ty) :--> 'Null 'PGbool
223+upperInc :: null ('PGrange ty) --> 'Null 'PGbool
224upperInc = unsafeFunction "upper_inc"
224upperInc = unsafeFunction "upper_inc"
225
225
226−upperInf :: null ('PGrange ty) :--> 'Null 'PGbool
226+upperInf :: null ('PGrange ty) --> 'Null 'PGbool
227upperInf = unsafeFunction "upper_inf"
227upperInf = unsafeFunction "upper_inf"
228
228
229−rangeMerge :: FunctionN
230− '[ null ('PGrange ty), null ('PGrange ty)] (null ('PGrange ty))
229+rangeMerge :: '[null ('PGrange ty), null ('PGrange ty)] ---> null ('PGrange ty)
231rangeMerge = unsafeFunctionN "range_merge"
230rangeMerge = unsafeFunctionN "range_merge"
squeal-postgresql/src/Squeal/PostgreSQL/Expression/SetOf.hs+22−10
@@ -26,9 +26,11 @@ module Squeal.PostgreSQL.Expression.SetOf
26 , generateSeriesTimestamp
26 , generateSeriesTimestamp
27 , SetOfFunction
27 , SetOfFunction
28 , unsafeSetOfFunction
28 , unsafeSetOfFunction
29+ , SetOfFunctionDB
29 , setOfFunction
30 , setOfFunction
30 , SetOfFunctionN
31 , SetOfFunctionN
31 , unsafeSetOfFunctionN
32 , unsafeSetOfFunctionN
33+ , SetOfFunctionNDB
32 , setOfFunctionN
34 , setOfFunctionN
33 ) where
35 ) where
34
36
@@ -53,6 +55,13 @@ type SetOfFunction fun ty setof
53 -> FromClause outer commons schemas params '[fun ::: setof]
55 -> FromClause outer commons schemas params '[fun ::: setof]
54 -- ^ output
56 -- ^ output
55
57
58+type SetOfFunctionDB fun schemas ty setof
59+ = forall outer commons params
60+ . Expression outer commons 'Ungrouped schemas params '[] ty
61+ -- ^ input
62+ -> FromClause outer commons schemas params '[fun ::: setof]
63+ -- ^ output
64+
56-- | Escape hatch for a set returning function with 1 argument.
65-- | Escape hatch for a set returning function with 1 argument.
57unsafeSetOfFunction
66unsafeSetOfFunction
58 :: forall fun ty setof. KnownSymbol fun
67 :: forall fun ty setof. KnownSymbol fun
@@ -62,11 +71,9 @@ unsafeSetOfFunction x = UnsafeFromClause $
62
71
63setOfFunction
72setOfFunction
64 :: ( Has sch schemas schema
73 :: ( Has sch schemas schema
65− , Has fun schema ('Function ('[ty] '::--> 'ReturnsTable setof)) )
74+ , Has fun schema ('Function ('[ty] :=> 'ReturnsTable setof)) )
66− => Alias fun
75+ => QualifiedAlias sch fun
67− -> ( forall outer commons params
76+ -> SetOfFunctionDB fun schemas ty setof
68− . Expression outer commons 'Ungrouped schemas params '[] ty
69− -> FromClause outer commons schemas params '[fun ::: setof] )
70setOfFunction _ = unsafeSetOfFunction
77setOfFunction _ = unsafeSetOfFunction
71
78
72{- |
79{- |
@@ -86,14 +93,19 @@ unsafeSetOfFunctionN
86unsafeSetOfFunctionN xs = UnsafeFromClause $
93unsafeSetOfFunctionN xs = UnsafeFromClause $
87 renderSymbol @fun <> parenthesized (renderCommaSeparated renderSQL xs)
94 renderSymbol @fun <> parenthesized (renderCommaSeparated renderSQL xs)
88
95
96+type SetOfFunctionNDB fun schemas tys setof
97+ = forall outer commons params
98+ . NP (Expression outer commons 'Ungrouped schemas params '[]) tys
99+ -- ^ inputs
100+ -> FromClause outer commons schemas params '[fun ::: setof]
101+ -- ^ output
102+
89setOfFunctionN
103setOfFunctionN
90 :: ( Has sch schemas schema
104 :: ( Has sch schemas schema
91− , Has fun schema ('Function (tys '::--> 'ReturnsTable setof))
105+ , Has fun schema ('Function (tys :=> 'ReturnsTable setof))
92 , SOP.SListI tys )
106 , SOP.SListI tys )
93− => Alias fun
107+ => QualifiedAlias sch fun
94− -> ( forall outer commons params
108+ -> SetOfFunctionNDB fun schemas tys setof
95− . NP (Expression outer commons 'Ungrouped schemas params '[]) tys
96− -> FromClause outer commons schemas params '[fun ::: setof] )
97setOfFunctionN _ = unsafeSetOfFunctionN
109setOfFunctionN _ = unsafeSetOfFunctionN
98
110
99{- | @generateSeries (start *: stop)@
111{- | @generateSeries (start *: stop)@
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Text.hs+3−3
@@ -30,17 +30,17 @@ import Squeal.PostgreSQL.Schema
30
30
31-- | >>> printSQL $ lower "ARRRGGG"
31-- | >>> printSQL $ lower "ARRRGGG"
32-- lower(E'ARRRGGG')
32-- lower(E'ARRRGGG')
33−lower :: null 'PGtext :--> null 'PGtext
33+lower :: null 'PGtext --> null 'PGtext
34lower = unsafeFunction "lower"
34lower = unsafeFunction "lower"
35
35
36-- | >>> printSQL $ upper "eeee"
36-- | >>> printSQL $ upper "eeee"
37-- upper(E'eeee')
37-- upper(E'eeee')
38−upper :: null 'PGtext :--> null 'PGtext
38+upper :: null 'PGtext --> null 'PGtext
39upper = unsafeFunction "upper"
39upper = unsafeFunction "upper"
40
40
41-- | >>> printSQL $ charLength "four"
41-- | >>> printSQL $ charLength "four"
42-- char_length(E'four')
42-- char_length(E'four')
43−charLength :: null 'PGtext :--> null 'PGint4
43+charLength :: null 'PGtext --> null 'PGint4
44charLength = unsafeFunction "char_length"
44charLength = unsafeFunction "char_length"
45
45
46-- | The `like` expression returns true if the @string@ matches
46-- | The `like` expression returns true if the @string@ matches
squeal-postgresql/src/Squeal/PostgreSQL/Expression/TextSearch.hs+19−20
@@ -55,7 +55,7 @@ import Squeal.PostgreSQL.Schema
55(.|) = unsafeBinaryOp "||"
55(.|) = unsafeBinaryOp "||"
56
56
57-- | negate a `Squeal.PostgreSQL.Expression.Type.tsquery`
57-- | negate a `Squeal.PostgreSQL.Expression.Type.tsquery`
58−(.!) :: null 'PGtsquery :--> null 'PGtsquery
58+(.!) :: null 'PGtsquery --> null 'PGtsquery
59(.!) = unsafeLeftOp "!!"
59(.!) = unsafeLeftOp "!!"
60
60
61-- | `Squeal.PostgreSQL.Expression.Type.tsquery` followed by
61-- | `Squeal.PostgreSQL.Expression.Type.tsquery` followed by
@@ -66,51 +66,50 @@ import Squeal.PostgreSQL.Schema
66-- | convert array of lexemes to `Squeal.PostgreSQL.Expression.Type.tsvector`
66-- | convert array of lexemes to `Squeal.PostgreSQL.Expression.Type.tsvector`
67arrayToTSvector
67arrayToTSvector
68 :: null ('PGvararray ('NotNull 'PGtext))
68 :: null ('PGvararray ('NotNull 'PGtext))
69− :--> null 'PGtsvector
69+ --> null 'PGtsvector
70arrayToTSvector = unsafeFunction "array_to_tsvector"
70arrayToTSvector = unsafeFunction "array_to_tsvector"
71
71
72-- | number of lexemes in `Squeal.PostgreSQL.Expression.Type.tsvector`
72-- | number of lexemes in `Squeal.PostgreSQL.Expression.Type.tsvector`
73−tsvectorLength :: null 'PGtsvector :--> null 'PGint4
73+tsvectorLength :: null 'PGtsvector --> null 'PGint4
74tsvectorLength = unsafeFunction "length"
74tsvectorLength = unsafeFunction "length"
75
75
76-- | number of lexemes plus operators in `Squeal.PostgreSQL.Expression.Type.tsquery`
76-- | number of lexemes plus operators in `Squeal.PostgreSQL.Expression.Type.tsquery`
77−numnode :: null 'PGtsquery :--> null 'PGint4
77+numnode :: null 'PGtsquery --> null 'PGint4
78numnode = unsafeFunction "numnode"
78numnode = unsafeFunction "numnode"
79
79
80-- | produce `Squeal.PostgreSQL.Expression.Type.tsquery` ignoring punctuation
80-- | produce `Squeal.PostgreSQL.Expression.Type.tsquery` ignoring punctuation
81−plainToTSquery :: null 'PGtext :--> null 'PGtsquery
81+plainToTSquery :: null 'PGtext --> null 'PGtsquery
82plainToTSquery = unsafeFunction "plainto_tsquery"
82plainToTSquery = unsafeFunction "plainto_tsquery"
83
83
84-- | produce `Squeal.PostgreSQL.Expression.Type.tsquery` that searches for a phrase,
84-- | produce `Squeal.PostgreSQL.Expression.Type.tsquery` that searches for a phrase,
85-- ignoring punctuation
85-- ignoring punctuation
86−phraseToTSquery :: null 'PGtext :--> null 'PGtsquery
86+phraseToTSquery :: null 'PGtext --> null 'PGtsquery
87phraseToTSquery = unsafeFunction "phraseto_tsquery"
87phraseToTSquery = unsafeFunction "phraseto_tsquery"
88
88
89-- | produce `Squeal.PostgreSQL.Expression.Type.tsquery` from a web search style query
89-- | produce `Squeal.PostgreSQL.Expression.Type.tsquery` from a web search style query
90−websearchToTSquery :: null 'PGtext :--> null 'PGtsquery
90+websearchToTSquery :: null 'PGtext --> null 'PGtsquery
91websearchToTSquery = unsafeFunction "websearch_to_tsquery"
91websearchToTSquery = unsafeFunction "websearch_to_tsquery"
92
92
93-- | get indexable part of a `Squeal.PostgreSQL.Expression.Type.tsquery`
93-- | get indexable part of a `Squeal.PostgreSQL.Expression.Type.tsquery`
94−queryTree :: null 'PGtsquery :--> null 'PGtext
94+queryTree :: null 'PGtsquery --> null 'PGtext
95queryTree = unsafeFunction "query_tree"
95queryTree = unsafeFunction "query_tree"
96
96
97-- | normalize words and convert to `Squeal.PostgreSQL.Expression.Type.tsquery`
97-- | normalize words and convert to `Squeal.PostgreSQL.Expression.Type.tsquery`
98−toTSquery :: null 'PGtext :--> null 'PGtsquery
98+toTSquery :: null 'PGtext --> null 'PGtsquery
99toTSquery = unsafeFunction "to_tsquery"
99toTSquery = unsafeFunction "to_tsquery"
100
100
101-- | reduce document text to `Squeal.PostgreSQL.Expression.Type.tsvector`
101-- | reduce document text to `Squeal.PostgreSQL.Expression.Type.tsvector`
102toTSvector
102toTSvector
103 :: ty `In` '[ 'PGtext, 'PGjson, 'PGjsonb]
103 :: ty `In` '[ 'PGtext, 'PGjson, 'PGjsonb]
104− => null ty :--> null 'PGtsvector
104+ => null ty --> null 'PGtsvector
105toTSvector = unsafeFunction "to_tsvector"
105toTSvector = unsafeFunction "to_tsvector"
106
106
107-- | assign weight to each element of `Squeal.PostgreSQL.Expression.Type.tsvector`
107-- | assign weight to each element of `Squeal.PostgreSQL.Expression.Type.tsvector`
108−setWeight
109− :: FunctionN '[null 'PGtsvector, null ('PGchar 1)] (null 'PGtsvector)
108+setWeight :: '[null 'PGtsvector, null ('PGchar 1)] ---> null 'PGtsvector
110setWeight = unsafeFunctionN "set_weight"
109setWeight = unsafeFunctionN "set_weight"
111
110
112-- | remove positions and weights from `Squeal.PostgreSQL.Expression.Type.tsvector`
111-- | remove positions and weights from `Squeal.PostgreSQL.Expression.Type.tsvector`
113−strip :: null 'PGtsvector :--> null 'PGtsvector
112+strip :: null 'PGtsvector --> null 'PGtsvector
114strip = unsafeFunction "strip"
113strip = unsafeFunction "strip"
115
114
116-- | @jsonToTSvector (document *: filter)@
115-- | @jsonToTSvector (document *: filter)@
@@ -123,7 +122,7 @@ strip = unsafeFunction "strip"
123-- "boolean" (to include all Boolean values in the string format "true"/"false"),
122-- "boolean" (to include all Boolean values in the string format "true"/"false"),
124-- "key" (to include all keys) or "all" (to include all above).
123-- "key" (to include all keys) or "all" (to include all above).
125-- These values can be combined together to include, e.g. all string and numeric values.
124-- These values can be combined together to include, e.g. all string and numeric values.
126−jsonToTSvector :: FunctionN '[null 'PGjson, null 'PGjson] (null 'PGtsvector)
125+jsonToTSvector :: '[null 'PGjson, null 'PGjson] ---> null 'PGtsvector
127jsonToTSvector = unsafeFunctionN "json_to_tsvector"
126jsonToTSvector = unsafeFunctionN "json_to_tsvector"
128
127
129-- | @jsonbToTSvector (document *: filter)@
128-- | @jsonbToTSvector (document *: filter)@
@@ -136,23 +135,23 @@ jsonToTSvector = unsafeFunctionN "json_to_tsvector"
136-- "boolean" (to include all Boolean values in the string format "true"/"false"),
135-- "boolean" (to include all Boolean values in the string format "true"/"false"),
137-- "key" (to include all keys) or "all" (to include all above).
136-- "key" (to include all keys) or "all" (to include all above).
138-- These values can be combined together to include, e.g. all string and numeric values.
137-- These values can be combined together to include, e.g. all string and numeric values.
139−jsonbToTSvector :: FunctionN '[null 'PGjsonb, null 'PGjsonb] (null 'PGtsvector)
138+jsonbToTSvector :: '[null 'PGjsonb, null 'PGjsonb] ---> null 'PGtsvector
140jsonbToTSvector = unsafeFunctionN "jsonb_to_tsvector"
139jsonbToTSvector = unsafeFunctionN "jsonb_to_tsvector"
141
140
142-- | remove given lexeme from `Squeal.PostgreSQL.Expression.Type.tsvector`
141-- | remove given lexeme from `Squeal.PostgreSQL.Expression.Type.tsvector`
143−tsDelete :: FunctionN
142+tsDelete ::
144 '[null 'PGtsvector, null ('PGvararray ('NotNull 'PGtext))]
143 '[null 'PGtsvector, null ('PGvararray ('NotNull 'PGtext))]
145− (null 'PGtsvector)
144+ ---> null 'PGtsvector
146tsDelete = unsafeFunctionN "ts_delete"
145tsDelete = unsafeFunctionN "ts_delete"
147
146
148-- | select only elements with given weights from `Squeal.PostgreSQL.Expression.Type.tsvector`
147-- | select only elements with given weights from `Squeal.PostgreSQL.Expression.Type.tsvector`
149−tsFilter :: FunctionN
148+tsFilter ::
150 '[null 'PGtsvector, null ('PGvararray ('NotNull ('PGchar 1)))]
149 '[null 'PGtsvector, null ('PGvararray ('NotNull ('PGchar 1)))]
151− (null 'PGtsvector)
150+ ---> null 'PGtsvector
152tsFilter = unsafeFunctionN "ts_filter"
151tsFilter = unsafeFunctionN "ts_filter"
153
152
154-- | display a `Squeal.PostgreSQL.Expression.Type.tsquery` match
153-- | display a `Squeal.PostgreSQL.Expression.Type.tsquery` match
155tsHeadline
154tsHeadline
156 :: document `In` '[ 'PGtext, 'PGjson, 'PGjsonb]
155 :: document `In` '[ 'PGtext, 'PGjson, 'PGjsonb]
157− => FunctionN '[null document, null 'PGtsquery] (null 'PGtext)
156+ => '[null document, null 'PGtsquery] ---> null 'PGtext
158tsHeadline = unsafeFunctionN "ts_headline"
157tsHeadline = unsafeFunctionN "ts_headline"
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Time.hs+7−12
@@ -17,6 +17,7 @@ Date/Time functions and operators
17 , OverloadedStrings
17 , OverloadedStrings
18 , PolyKinds
18 , PolyKinds
19 , RankNTypes
19 , RankNTypes
20+ , TypeOperators
20#-}
21#-}
21
22
22module Squeal.PostgreSQL.Expression.Time
23module Squeal.PostgreSQL.Expression.Time
@@ -85,9 +86,7 @@ Create date from year, month and day fields
85>>> printSQL (makeDate (1984 :* 7 *: 3))
86>>> printSQL (makeDate (1984 :* 7 *: 3))
86make_date(1984, 7, 3)
87make_date(1984, 7, 3)
87-}
88-}
88−makeDate :: FunctionN
89− '[ null 'PGint4, null 'PGint4, null 'PGint4 ]
89+makeDate :: '[ null 'PGint4, null 'PGint4, null 'PGint4 ] ---> null 'PGdate
90− ( null 'PGdate )
91makeDate = unsafeFunctionN "make_date"
90makeDate = unsafeFunctionN "make_date"
92
91
93{-|
92{-|
@@ -96,9 +95,7 @@ Create time from hour, minute and seconds fields
96>>> printSQL (makeTime (8 :* 15 *: 23.5))
95>>> printSQL (makeTime (8 :* 15 *: 23.5))
97make_time(8, 15, 23.5)
96make_time(8, 15, 23.5)
98-}
97-}
99−makeTime :: FunctionN
100− '[ null 'PGint4, null 'PGint4, null 'PGfloat8 ]
98+makeTime :: '[ null 'PGint4, null 'PGint4, null 'PGfloat8 ] ---> null 'PGtime
101− ( null 'PGtime )
102makeTime = unsafeFunctionN "make_time"
99makeTime = unsafeFunctionN "make_time"
103
100
104{-|
101{-|
@@ -107,10 +104,9 @@ Create timestamp from year, month, day, hour, minute and seconds fields
107>>> printSQL (makeTimestamp (2013 :* 7 :* 15 :* 8 :* 15 *: 23.5))
104>>> printSQL (makeTimestamp (2013 :* 7 :* 15 :* 8 :* 15 *: 23.5))
108make_timestamp(2013, 7, 15, 8, 15, 23.5)
105make_timestamp(2013, 7, 15, 8, 15, 23.5)
109-}
106-}
110−makeTimestamp :: FunctionN
107+makeTimestamp ::
111 '[ null 'PGint4, null 'PGint4, null 'PGint4
108 '[ null 'PGint4, null 'PGint4, null 'PGint4
112− , null 'PGint4, null 'PGint4, null 'PGfloat8 ]
109+ , null 'PGint4, null 'PGint4, null 'PGfloat8 ] ---> null 'PGtimestamp
113− ( null 'PGtimestamp )
114makeTimestamp = unsafeFunctionN "make_timestamp"
110makeTimestamp = unsafeFunctionN "make_timestamp"
115
111
116{-|
112{-|
@@ -121,10 +117,9 @@ the current time zone is used
121>>> printSQL (makeTimestamptz (2013 :* 7 :* 15 :* 8 :* 15 *: 23.5))
117>>> printSQL (makeTimestamptz (2013 :* 7 :* 15 :* 8 :* 15 *: 23.5))
122make_timestamptz(2013, 7, 15, 8, 15, 23.5)
118make_timestamptz(2013, 7, 15, 8, 15, 23.5)
123-}
119-}
124−makeTimestamptz :: FunctionN
120+makeTimestamptz ::
125 '[ null 'PGint4, null 'PGint4, null 'PGint4
121 '[ null 'PGint4, null 'PGint4, null 'PGint4
126− , null 'PGint4, null 'PGint4, null 'PGfloat8 ]
122+ , null 'PGint4, null 'PGint4, null 'PGfloat8 ] ---> null 'PGtimestamptz
127− ( null 'PGtimestamptz )
128makeTimestamptz = unsafeFunctionN "make_timestamptz"
123makeTimestamptz = unsafeFunctionN "make_timestamptz"
129
124
130{-|
125{-|
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+2−2
@@ -45,7 +45,7 @@ module Squeal.PostgreSQL.Schema
45 , TableType
45 , TableType
46 , SchemumType (..)
46 , SchemumType (..)
47 , IndexType (..)
47 , IndexType (..)
48− , FunctionType (..)
48+ , FunctionType
49 , OperatorType (..)
49 , OperatorType (..)
50 , ReturnsType (..)
50 , ReturnsType (..)
51 , SchemaType
51 , SchemaType
@@ -433,7 +433,7 @@ data SchemumType
433 | Operator OperatorType
433 | Operator OperatorType
434 | UnsafeSchemum Symbol
434 | UnsafeSchemum Symbol
435
435
436−data FunctionType = (::-->) [NullityType] ReturnsType
436+type FunctionType = ([NullityType], ReturnsType)
437
437
438data IndexType
438data IndexType
439 = Btree
439 = Btree