@@ -1,5 +1,5 @@
11{-|
2−Module: Squeal.PostgreSQL.Expression.SetOf
2+Module: Squeal.PostgreSQL.Expression.Set
33Description: Set returning functions
44Copyright: (c) Eitan Chatav, 2019
55Maintainer: eitan@morphism.tech
@@ -20,17 +20,17 @@ Set returning functions
2020 , TypeOperators
2121#-}
2222
23−module Squeal.PostgreSQL.Expression.SetOf
23+module Squeal.PostgreSQL.Expression.Set
2424 ( generateSeries
2525 , generateSeriesStep
2626 , generateSeriesTimestamp
27− , SetOfFunction
28− , unsafeSetOfFunction
29− , SetOfFunctionDB
27+ , SetFunction
28+ , unsafeSetFunction
29+ , SetFunctionDB
3030 , setOfFunction
31− , SetOfFunctionN
32− , unsafeSetOfFunctionN
33− , SetOfFunctionNDB
31+ , SetFunctionN
32+ , unsafeSetFunctionN
33+ , SetFunctionNDB
3434 , setOfFunctionN
3535 ) where
3636
@@ -48,65 +48,65 @@ import Squeal.PostgreSQL.Schema
4848{- |
4949A @RankNType@ for set returning functions with 1 argument.
5050-}
51−type SetOfFunction fun ty setof
51+type SetFunction fun ty row
5252 = forall outer commons schemas params
5353 . Expression outer commons 'Ungrouped schemas params '[] ty
5454 -- ^ input
55− -> FromClause outer commons schemas params '[fun ::: setof]
55+ -> FromClause outer commons schemas params '[fun ::: row]
5656 -- ^ output
5757
58−type SetOfFunctionDB fun schemas ty setof
58+type SetFunctionDB fun schemas ty row
5959 = forall outer commons params
6060 . Expression outer commons 'Ungrouped schemas params '[] ty
6161 -- ^ input
62− -> FromClause outer commons schemas params '[fun ::: setof]
62+ -> FromClause outer commons schemas params '[fun ::: row]
6363 -- ^ output
6464
6565-- | Escape hatch for a set returning function with 1 argument.
66−unsafeSetOfFunction
67− :: forall fun ty setof. KnownSymbol fun
68− => SetOfFunction fun ty setof -- ^ set returning function
69−unsafeSetOfFunction x = UnsafeFromClause $
66+unsafeSetFunction
67+ :: forall fun ty row. KnownSymbol fun
68+ => SetFunction fun ty row -- ^ set returning function
69+unsafeSetFunction x = UnsafeFromClause $
7070 renderSymbol @fun <> parenthesized (renderSQL x)
7171
7272setOfFunction
7373 :: ( Has sch schemas schema
74− , Has fun schema ('Function ('[ty] :=> 'ReturnsTable setof)) )
74+ , Has fun schema ('Function ('[ty] :=> 'ReturnsTable row)) )
7575 => QualifiedAlias sch fun
76− -> SetOfFunctionDB fun schemas ty setof
77−setOfFunction _ = unsafeSetOfFunction
76+ -> SetFunctionDB fun schemas ty row
77+setOfFunction _ = unsafeSetFunction
7878
7979{- |
8080A @RankNType@ for set returning functions with multiple argument.
8181-}
82−type SetOfFunctionN fun tys setof
82+type SetFunctionN fun tys row
8383 = forall outer commons schemas params
8484 . NP (Expression outer commons 'Ungrouped schemas params '[]) tys
8585 -- ^ inputs
86− -> FromClause outer commons schemas params '[fun ::: setof]
86+ -> FromClause outer commons schemas params '[fun ::: row]
8787 -- ^ output
8888
8989-- | Escape hatch for a set returning function with multiple argument.
90−unsafeSetOfFunctionN
91− :: forall fun tys setof. (SOP.SListI tys, KnownSymbol fun)
92− => SetOfFunctionN fun tys setof -- ^ set returning function
93−unsafeSetOfFunctionN xs = UnsafeFromClause $
90+unsafeSetFunctionN
91+ :: forall fun tys row. (SOP.SListI tys, KnownSymbol fun)
92+ => SetFunctionN fun tys row -- ^ set returning function
93+unsafeSetFunctionN xs = UnsafeFromClause $
9494 renderSymbol @fun <> parenthesized (renderCommaSeparated renderSQL xs)
9595
96−type SetOfFunctionNDB fun schemas tys setof
96+type SetFunctionNDB fun schemas tys row
9797 = forall outer commons params
9898 . NP (Expression outer commons 'Ungrouped schemas params '[]) tys
9999 -- ^ inputs
100− -> FromClause outer commons schemas params '[fun ::: setof]
100+ -> FromClause outer commons schemas params '[fun ::: row]
101101 -- ^ output
102102
103103setOfFunctionN
104104 :: ( Has sch schemas schema
105− , Has fun schema ('Function (tys :=> 'ReturnsTable setof))
105+ , Has fun schema ('Function (tys :=> 'ReturnsTable row))
106106 , SOP.SListI tys )
107107 => QualifiedAlias sch fun
108− -> SetOfFunctionNDB fun schemas tys setof
109−setOfFunctionN _ = unsafeSetOfFunctionN
108+ -> SetFunctionNDB fun schemas tys row
109+setOfFunctionN _ = unsafeSetFunctionN
110110
111111{- | @generateSeries (start *: stop)@
112112
@@ -114,9 +114,9 @@ Generate a series of values, from @start@ to @stop@ with a step size of one
114114-}
115115generateSeries
116116 :: ty `In` '[ 'PGint4, 'PGint8, 'PGnumeric]
117− => SetOfFunctionN "generate_series" '[ null ty, null ty]
117+ => SetFunctionN "generate_series" '[ null ty, null ty]
118118 '["generate_series" ::: null ty] -- ^ set returning function
119−generateSeries = unsafeSetOfFunctionN
119+generateSeries = unsafeSetFunctionN
120120
121121{- | @generateSeries (start :* stop *: step)@
122122
@@ -124,9 +124,9 @@ Generate a series of values, from @start@ to @stop@ with a step size of @step@
124124-}
125125generateSeriesStep
126126 :: ty `In` '[ 'PGint4, 'PGint8, 'PGnumeric]
127− => SetOfFunctionN "generate_series" '[null ty, null ty, null ty]
127+ => SetFunctionN "generate_series" '[null ty, null ty, null ty]
128128 '["generate_series" ::: null ty] -- ^ set returning function
129−generateSeriesStep = unsafeSetOfFunctionN
129+generateSeriesStep = unsafeSetFunctionN
130130
131131{- | @generateSeries (start :* stop *: step)@
132132
@@ -134,6 +134,6 @@ Generate a series of values, from @start@ to @stop@ with a step size of @step@
134134-}
135135generateSeriesTimestamp
136136 :: ty `In` '[ 'PGtimestamp, 'PGtimestamptz]
137− => SetOfFunctionN "generate_series" '[null ty, null ty, null 'PGinterval]
137+ => SetFunctionN "generate_series" '[null ty, null ty, null 'PGinterval]
138138 '["generate_series" ::: null ty] -- ^ set returning function
139−generateSeriesTimestamp = unsafeSetOfFunctionN
139+generateSeriesTimestamp = unsafeSetFunctionN