@@ -16,7 +16,7 @@ module Rel8.Expr.Text
1616 , initcap, left, length, lengthEncoding, lpad, ltrim, md5
1717 , pgClientEncoding, quoteIdent, quoteLiteral, quoteNullable, regexpReplace
1818 , regexpSplitToArray, repeat, replace, reverse, right, rpad, rtrim
19− , splitPart, strpos, substr, toAscii, toHex, translate
19+ , splitPart, strpos, substr, translate
2020 )
2121where
2222
@@ -50,24 +50,32 @@ infixr 6 ++.
5050
5151
5252-- | Matches regular expression, case sensitive
53+--
54+-- Corresponds to the @~.@ operator.
5355(~.) :: Expr Text -> Expr Text -> Expr Bool
5456(~.) = binaryOperator "~."
5557infix 2 ~.
5658
5759
5860-- | Matches regular expression, case insensitive
61+--
62+-- Corresponds to the @~*@ operator.
5963(~*) :: Expr Text -> Expr Text -> Expr Bool
6064(~*) = binaryOperator "~*"
6165infix 2 ~*
6266
6367
6468-- | Does not match regular expression, case sensitive
69+--
70+-- Corresponds to the @!~@ operator.
6571(!~) :: Expr Text -> Expr Text -> Expr Bool
6672(!~) = binaryOperator "!~"
6773infix 2 !~
6874
6975
7076-- | Does not match regular expression, case insensitive
77+--
78+-- Corresponds to the @!~*@ operator.
7179(!~*) :: Expr Text -> Expr Text -> Expr Bool
7280(!~*) = binaryOperator "!~*"
7381infix 2 !~*
@@ -78,164 +86,191 @@ infix 2 !~*
7886-- * Standard SQL functions
7987
8088
89+-- | Corresponds to the @bit_length@ function.
8190bitLength :: Expr Text -> Expr Int32
8291bitLength = function "bit_length"
8392
8493
94+-- | Corresponds to the @char_length@ function.
8595charLength :: Expr Text -> Expr Int32
8696charLength = function "char_length"
8797
8898
99+-- | Corresponds to the @lower@ function.
89100lower :: Expr Text -> Expr Text
90101lower = function "lower"
91102
92103
104+-- | Corresponds to the @octet_length@ function.
93105octetLength :: Expr Text -> Expr Int32
94106octetLength = function "octet_length"
95107
96108
109+-- | Corresponds to the @upper@ function.
97110upper :: Expr Text -> Expr Text
98111upper = function "upper"
99112
100113
101−-- * PostgreSQL functions
114+-- | Corresponds to the @ascii@ function.
102115ascii :: Expr Text -> Expr Int32
103116ascii = function "ascii"
104117
105118
119+-- | Corresponds to the @btrim@ function.
106120btrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
107121btrim a (Just b) = function "btrim" a b
108122btrim a Nothing = function "btrim" a
109123
110124
125+-- | Corresponds to the @chr@ function.
111126chr :: Expr Int32 -> Expr Text
112127chr = function "chr"
113128
114129
130+-- | Corresponds to the @convert@ function.
115131convert :: Expr ByteString -> Expr Text -> Expr Text -> Expr ByteString
116132convert = function "convert"
117133
118134
135+-- | Corresponds to the @convert_from@ function.
119136convertFrom :: Expr ByteString -> Expr Text -> Expr Text
120137convertFrom = function "convert_from"
121138
122139
140+-- | Corresponds to the @convert_to@ function.
123141convertTo :: Expr Text -> Expr Text -> Expr ByteString
124142convertTo = function "convert_to"
125143
126144
145+-- | Corresponds to the @decode@ function.
127146decode :: Expr Text -> Expr Text -> Expr ByteString
128147decode = function "decode"
129148
130149
150+-- | Corresponds to the @encode@ function.
131151encode :: Expr ByteString -> Expr Text -> Expr Text
132152encode = function "encode"
133153
134154
155+-- | Corresponds to the @initcap@ function.
135156initcap :: Expr Text -> Expr Text
136157initcap = function "initcap"
137158
138159
160+-- | Corresponds to the @left@ function.
139161left :: Expr Text -> Expr Int32 -> Expr Text
140162left = function "left"
141163
142164
165+-- | Corresponds to the @length@ function.
143166length :: Expr Text -> Expr Int32
144167length = function "length"
145168
146169
170+-- | Corresponds to the @length@ function.
147171lengthEncoding :: Expr ByteString -> Expr Text -> Expr Int32
148172lengthEncoding = function "length"
149173
150174
175+-- | Corresponds to the @lpad@ function.
151176lpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
152177lpad a b (Just c) = function "lpad" a b c
153178lpad a b Nothing = function "lpad" a b
154179
155180
181+-- | Corresponds to the @ltrim@ function.
156182ltrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
157183ltrim a (Just b) = function "ltrim" a b
158184ltrim a Nothing = function "ltrim" a
159185
160186
187+-- | Corresponds to the @md5@ function.
161188md5 :: Expr Text -> Expr Text
162189md5 = function "md5"
163190
164191
192+-- | Corresponds to the @pg_client_encoding()@ expression.
165193pgClientEncoding :: Expr Text
166194pgClientEncoding = nullaryFunction "pg_client_encoding"
167195
168196
197+-- | Corresponds to the @quote_ident@ function.
169198quoteIdent :: Expr Text -> Expr Text
170199quoteIdent = function "quote_ident"
171200
172201
202+-- | Corresponds to the @quote_literal@ function.
173203quoteLiteral :: Expr Text -> Expr Text
174204quoteLiteral = function "quote_literal"
175205
176206
207+-- | Corresponds to the @quote_nullable@ function.
177208quoteNullable :: Expr Text -> Expr Text
178209quoteNullable = function "quote_nullable"
179210
180211
212+-- | Corresponds to the @regexp_replace@ function.
181213regexpReplace :: ()
182214 => Expr Text -> Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr Text
183215regexpReplace a b c (Just d) = function "regexp_replace" a b c d
184216regexpReplace a b c Nothing = function "regexp_replace" a b c
185217
186218
219+-- | Corresponds to the @regexp_split_to_array@ function.
187220regexpSplitToArray :: ()
188221 => Expr Text -> Expr Text -> Maybe (Expr Text) -> Expr (Array1D Text)
189222regexpSplitToArray a b (Just c) = function "regexp_split_to_array" a b c
190223regexpSplitToArray a b Nothing = function "regexp_split_to_array" a b
191224
192225
226+-- | Corresponds to the @repeat@ function.
193227repeat :: Expr Text -> Expr Int32 -> Expr Text
194228repeat = function "repeat"
195229
196230
231+-- | Corresponds to the @replace@ function.
197232replace :: Expr Text -> Expr Text -> Expr Text -> Expr Text
198233replace = function "replace"
199234
200235
236+-- | Corresponds to the @reverse@ function.
201237reverse :: Expr Text -> Expr Text
202238reverse = function "reverse"
203239
204240
241+-- | Corresponds to the @right@ function.
205242right :: Expr Text -> Expr Int32 -> Expr Text
206243right = function "right"
207244
208245
246+-- | Corresponds to the @rpad@ function.
209247rpad :: Expr Text -> Expr Int32 -> Maybe (Expr Text) -> Expr Text
210248rpad a b (Just c) = function "rpad" a b c
211249rpad a b Nothing = function "rpad" a b
212250
213251
252+-- | Corresponds to the @rtrim@ function.
214253rtrim :: Expr Text -> Maybe (Expr Text) -> Expr Text
215254rtrim a (Just b) = function "rtrim" a b
216255rtrim a Nothing = function "rtrim" a
217256
218257
258+-- | Corresponds to the @split_part@ function.
219259splitPart :: Expr Text -> Expr Text -> Expr Int32 -> Expr Text
220260splitPart = function "split_part"
221261
222262
263+-- | Corresponds to the @strpos@ function.
223264strpos :: Expr Text -> Expr Text -> Expr Int32
224265strpos = function "strpos"
225266
226267
268+-- | Corresponds to the @substr@ function.
227269substr :: Expr Text -> Expr Int32 -> Maybe (Expr Int32) -> Expr Text
228270substr a b (Just c) = function "substr" a b c
229271substr a b Nothing = function "substr" a b
230272
231273
232−toAscii :: Expr Text -> Expr Text -> Expr Text
233−toAscii = function "toAscii"
234−
235−
236−toHex :: Expr Int32 -> Expr Text
237−toHex = function "toHex"
238−
239−
274+-- | Corresponds to the @translate@ function.
240275translate :: Expr Text -> Expr Text -> Expr Text -> Expr Text
241276translate = function "translate"