@@ -221,7 +221,7 @@ class KnownSymbol column => HasColumn column columns ty
221221 -> Expression tables 'Ungrouped params ty
222222 getColumn column = UnsafeExpression $ renderAlias column
223223instance {-# OVERLAPPING #-} KnownSymbol column
224− => HasColumn column ((column ::: optionality ty) ': tys) '( '[], ty)
224+ => HasColumn column ((column ::: optionality ty) ': tys) ( '[] :=> ty)
225225instance {-# OVERLAPPABLE #-} (KnownSymbol column, HasColumn column table ty)
226226 => HasColumn column (ty' ': table) ty
227227
@@ -299,23 +299,23 @@ instance
299299-- "DEFAULT"
300300def
301301 :: 'Default `In` constraints
302− => Expression '[] 'Ungrouped params '(constraints, (nullity ty))
302+ => Expression '[] 'Ungrouped params (constraints :=> nullity ty)
303303def = UnsafeExpression "DEFAULT"
304304
305305-- | >>> renderExpression $ unDef false
306306-- "FALSE"
307307unDef
308308 :: 'Default `In` constraints
309− => Expression '[] 'Ungrouped params '( '[], (nullity ty))
309+ => Expression '[] 'Ungrouped params ( '[] :=> nullity ty)
310310 -- ^ not @DEFAULT@
311− -> Expression '[] 'Ungrouped params '(constraints, (nullity ty))
311+ -> Expression '[] 'Ungrouped params (constraints :=> nullity ty)
312312unDef = UnsafeExpression . renderExpression
313313
314314-- | analagous to `Nothing`
315315--
316316-- >>> renderExpression $ null_
317317-- "NULL"
318−null_ :: Expression tables grouping params (optionality ('Null ty))
318+null_ :: Expression tables grouping params (constraints :=> 'Null ty)
319319null_ = UnsafeExpression "NULL"
320320
321321-- | analagous to `Just`
@@ -323,9 +323,9 @@ null_ = UnsafeExpression "NULL"
323323-- >>> renderExpression $ unNull true
324324-- "TRUE"
325325unNull
326− :: Expression tables grouping params (optionality ('NotNull ty))
326+ :: Expression tables grouping params (constraints :=> 'NotNull ty)
327327 -- ^ not @NULL@
328− -> Expression tables grouping params (optionality ('Null ty))
328+ -> Expression tables grouping params (constraints :=> 'Null ty)
329329unNull = UnsafeExpression . renderExpression
330330
331331-- | return the leftmost value which is not NULL
@@ -333,11 +333,11 @@ unNull = UnsafeExpression . renderExpression
333333-- >>> renderExpression $ coalesce [null_, unNull true] false
334334-- "COALESCE(NULL, TRUE, FALSE)"
335335coalesce
336− :: [Expression tables grouping params '( '[], ('Null ty))]
336+ :: [Expression tables grouping params ( '[] :=> 'Null ty)]
337337 -- ^ @NULL@s may be present
338− -> Expression tables grouping params '( '[], ('NotNull ty))
338+ -> Expression tables grouping params ( '[] :=> 'NotNull ty)
339339 -- ^ @NULL@ is absent
340− -> Expression tables grouping params '( '[], ('NotNull ty))
340+ -> Expression tables grouping params ( '[] :=> 'NotNull ty)
341341coalesce nullxs notNullx = UnsafeExpression $
342342 "COALESCE" <> parenthesized (commaSeparated
343343 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
@@ -347,16 +347,16 @@ coalesce nullxs notNullx = UnsafeExpression $
347347-- >>> renderExpression $ fromNull true null_
348348-- "COALESCE(NULL, TRUE)"
349349fromNull
350− :: Expression tables grouping params '( '[], ('NotNull ty))
350+ :: Expression tables grouping params ( '[] :=> 'NotNull ty)
351351 -- ^ what to convert @NULL@ to
352− -> Expression tables grouping params '( '[], ('Null ty))
353− -> Expression tables grouping params '( '[], ('NotNull ty))
352+ -> Expression tables grouping params ( '[] :=> 'Null ty)
353+ -> Expression tables grouping params ( '[] :=> 'NotNull ty)
354354fromNull notNullx nullx = coalesce [nullx] notNullx
355355
356356-- | >>> renderExpression $ null_ & isNull
357357-- "NULL IS NULL"
358358isNull
359− :: Expression tables grouping params '( '[], ('Null ty))
359+ :: Expression tables grouping params ( '[] :=> 'Null ty)
360360 -- ^ possibly @NULL@
361361 -> Condition tables grouping params
362362isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
@@ -364,7 +364,7 @@ isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
364364-- | >>> renderExpression $ null_ & isn'tNull
365365-- "NULL IS NOT NULL"
366366isn'tNull
367− :: Expression tables grouping params '( '[], ('Null ty))
367+ :: Expression tables grouping params ( '[] :=> 'Null ty)
368368 -- ^ possibly @NULL@
369369 -> Condition tables grouping params
370370isn'tNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
@@ -374,13 +374,13 @@ isn'tNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
374374-- >>> renderExpression $ matchNull true not_ null_
375375-- "CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END"
376376matchNull
377− :: Expression tables grouping params '( '[], nullty)
377+ :: Expression tables grouping params ( '[] :=> nullty)
378378 -- ^ what to convert @NULL@ to
379− -> ( Expression tables grouping params '( '[], ('NotNull ty))
380− -> Expression tables grouping params '( '[], nullty) )
379+ -> ( Expression tables grouping params ( '[] :=> 'NotNull ty)
380+ -> Expression tables grouping params ( '[] :=> nullty) )
381381 -- ^ function to perform when @NULL@ is absent
382− -> Expression tables grouping params '( '[], ('Null ty))
383− -> Expression tables grouping params '( '[], nullty)
382+ -> Expression tables grouping params ( '[] :=> 'Null ty)
383+ -> Expression tables grouping params ( '[] :=> nullty)
384384matchNull y f x = ifThenElse (isNull x) y
385385 (f (UnsafeExpression (renderExpression x)))
386386
@@ -391,33 +391,33 @@ matchNull y f x = ifThenElse (isNull x) y
391391-- >>> renderExpression @_ @_ @'[_] $ fromNull false (nullIf false (param @1))
392392-- "COALESCE(NULL IF (FALSE, ($1 :: bool)), FALSE)"
393393nullIf
394− :: Expression tables grouping params '( '[], ('NotNull ty))
394+ :: Expression tables grouping params ( '[] :=> 'NotNull ty)
395395 -- ^ @NULL@ is absent
396− -> Expression tables grouping params '( '[], ('NotNull ty))
396+ -> Expression tables grouping params ( '[] :=> 'NotNull ty)
397397 -- ^ @NULL@ is absent
398− -> Expression tables grouping params '( '[], ('Null ty))
398+ -> Expression tables grouping params ( '[] :=> 'Null ty)
399399nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
400400 (renderExpression x <> ", " <> renderExpression y)
401401
402402-- | >>> renderExpression @_ @_ @'[_] $ greatest currentTimestamp [param @1]
403403-- "GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))"
404404greatest
405− :: Expression tables grouping params '( '[], nullty)
405+ :: Expression tables grouping params ( '[] :=> nullty)
406406 -- ^ needs at least 1 argument
407− -> [Expression tables grouping params '( '[], nullty)]
407+ -> [Expression tables grouping params ( '[] :=> nullty)]
408408 -- ^ or more
409− -> Expression tables grouping params '( '[], nullty)
409+ -> Expression tables grouping params ( '[] :=> nullty)
410410greatest x xs = UnsafeExpression $ "GREATEST("
411411 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
412412
413413-- | >>> renderExpression $ least currentTimestamp [null_]
414414-- "LEAST(CURRENT_TIMESTAMP, NULL)"
415415least
416− :: Expression tables grouping params '( '[], nullty)
416+ :: Expression tables grouping params ( '[] :=> nullty)
417417 -- ^ needs at least 1 argument
418− -> [Expression tables grouping params '( '[], nullty)]
418+ -> [Expression tables grouping params ( '[] :=> nullty)]
419419 -- ^ or more
420− -> Expression tables grouping params '( '[], nullty)
420+ -> Expression tables grouping params ( '[] :=> nullty)
421421least x xs = UnsafeExpression $ "LEAST("
422422 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
423423
@@ -426,9 +426,9 @@ least x xs = UnsafeExpression $ "LEAST("
426426unsafeBinaryOp
427427 :: ByteString
428428 -- ^ operator
429− -> Expression tables grouping params '( '[], ty0)
430− -> Expression tables grouping params '( '[], ty1)
431− -> Expression tables grouping params '( '[], ty2)
429+ -> Expression tables grouping params ( '[] :=> ty0)
430+ -> Expression tables grouping params ( '[] :=> ty1)
431+ -> Expression tables grouping params ( '[] :=> ty2)
432432unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
433433 renderExpression x <+> op <+> renderExpression y
434434
@@ -437,8 +437,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
437437unsafeUnaryOp
438438 :: ByteString
439439 -- ^ operator
440− -> Expression tables grouping params '( '[], ty0)
441− -> Expression tables grouping params '( '[], ty1)
440+ -> Expression tables grouping params ( '[] :=> ty0)
441+ -> Expression tables grouping params ( '[] :=> ty1)
442442unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
443443 op <+> renderExpression x
444444
@@ -447,13 +447,13 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
447447unsafeFunction
448448 :: ByteString
449449 -- ^ function
450− -> Expression tables grouping params '( '[], xty)
451− -> Expression tables grouping params '( '[], yty)
450+ -> Expression tables grouping params ( '[] :=> xty)
451+ -> Expression tables grouping params ( '[] :=> yty)
452452unsafeFunction fun x = UnsafeExpression $
453453 fun <> parenthesized (renderExpression x)
454454
455455instance PGNum ty
456− => Num (Expression tables grouping params '( '[], (nullity ty))) where
456+ => Num (Expression tables grouping params ( '[] :=> nullity ty)) where
457457 (+) = unsafeBinaryOp "+"
458458 (-) = unsafeBinaryOp "-"
459459 (*) = unsafeBinaryOp "*"
@@ -465,12 +465,12 @@ instance PGNum ty
465465 . show
466466
467467instance (PGNum ty, PGFloating ty) => Fractional
468− (Expression tables grouping params '( '[], (nullity ty))) where
468+ (Expression tables grouping params ( '[] :=> nullity ty)) where
469469 (/) = unsafeBinaryOp "/"
470470 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
471471
472472instance (PGNum ty, PGFloating ty) => Floating
473− (Expression tables grouping params '( '[], (nullity ty))) where
473+ (Expression tables grouping params ( '[] :=> nullity ty)) where
474474 pi = UnsafeExpression "pi()"
475475 exp = unsafeFunction "exp"
476476 log = unsafeFunction "ln"
@@ -495,11 +495,11 @@ instance (PGNum ty, PGFloating ty) => Floating
495495-- "atan2(pi(), 2)"
496496atan2_
497497 :: PGFloating float
498− => Expression tables grouping params '( '[], (nullity float))
498+ => Expression tables grouping params ( '[] :=> nullity float)
499499 -- ^ numerator
500− -> Expression tables grouping params '( '[], (nullity float))
500+ -> Expression tables grouping params ( '[] :=> nullity float)
501501 -- ^ denominator
502− -> Expression tables grouping params '( '[], (nullity float))
502+ -> Expression tables grouping params ( '[] :=> nullity float)
503503atan2_ y x = UnsafeExpression $
504504 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
505505
@@ -510,11 +510,11 @@ atan2_ y x = UnsafeExpression $
510510-- | >>> renderExpression $ true & cast int4
511511-- "(TRUE :: int4)"
512512cast
513− :: TypeExpression '( '[], ('Null ty1))
513+ :: TypeExpression ( '[] :=> 'Null ty1)
514514 -- ^ type to cast as
515− -> Expression tables grouping params '( '[], (nullity ty0))
515+ -> Expression tables grouping params ( '[] :=> nullity ty0)
516516 -- ^ value to convert
517− -> Expression tables grouping params '( '[], (nullity ty1))
517+ -> Expression tables grouping params ( '[] :=> nullity ty1)
518518cast ty x = UnsafeExpression $ parenthesized $
519519 renderExpression x <+> "::" <+> renderTypeExpression ty
520520
@@ -524,11 +524,11 @@ cast ty x = UnsafeExpression $ parenthesized $
524524-- "(5 / 2)"
525525quot_
526526 :: PGIntegral int
527− => Expression tables grouping params '( '[], (nullity int))
527+ => Expression tables grouping params ( '[] :=> nullity int)
528528 -- ^ numerator
529− -> Expression tables grouping params '( '[], (nullity int))
529+ -> Expression tables grouping params ( '[] :=> nullity int)
530530 -- ^ denominator
531− -> Expression tables grouping params '( '[], (nullity int))
531+ -> Expression tables grouping params ( '[] :=> nullity int)
532532quot_ = unsafeBinaryOp "/"
533533
534534-- | remainder upon integer division
@@ -537,38 +537,38 @@ quot_ = unsafeBinaryOp "/"
537537-- "(5 % 2)"
538538rem_
539539 :: PGIntegral int
540− => Expression tables grouping params '( '[], (nullity int))
540+ => Expression tables grouping params ( '[] :=> nullity int)
541541 -- ^ numerator
542− -> Expression tables grouping params '( '[], (nullity int))
542+ -> Expression tables grouping params ( '[] :=> nullity int)
543543 -- ^ denominator
544− -> Expression tables grouping params '( '[], (nullity int))
544+ -> Expression tables grouping params ( '[] :=> nullity int)
545545rem_ = unsafeBinaryOp "%"
546546
547547-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGfloat4)) $ trunc pi
548548-- "trunc(pi())"
549549trunc
550550 :: PGFloating frac
551− => Expression tables grouping params '( '[], (nullity frac))
551+ => Expression tables grouping params ( '[] :=> nullity frac)
552552 -- ^ fractional number
553− -> Expression tables grouping params '( '[], (nullity frac))
553+ -> Expression tables grouping params ( '[] :=> nullity frac)
554554trunc = unsafeFunction "trunc"
555555
556556-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGfloat4)) $ round_ pi
557557-- "round(pi())"
558558round_
559559 :: PGFloating frac
560− => Expression tables grouping params '( '[], (nullity frac))
560+ => Expression tables grouping params ( '[] :=> nullity frac)
561561 -- ^ fractional number
562− -> Expression tables grouping params '( '[], (nullity frac))
562+ -> Expression tables grouping params ( '[] :=> nullity frac)
563563round_ = unsafeFunction "round"
564564
565565-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGfloat4)) $ ceiling_ pi
566566-- "ceiling(pi())"
567567ceiling_
568568 :: PGFloating frac
569− => Expression tables grouping params '( '[], (nullity frac))
569+ => Expression tables grouping params ( '[] :=> nullity frac)
570570 -- ^ fractional number
571− -> Expression tables grouping params '( '[], (nullity frac))
571+ -> Expression tables grouping params ( '[] :=> nullity frac)
572572ceiling_ = unsafeFunction "ceiling"
573573
574574-- | A `Condition` is a boolean valued `Expression`. While SQL allows
@@ -576,7 +576,7 @@ ceiling_ = unsafeFunction "ceiling"
576576-- forcing one to handle the case of @NULL@ explicitly to produce
577577-- a `Condition`.
578578type Condition tables grouping params =
579− Expression tables grouping params '( '[], ('NotNull 'PGbool))
579+ Expression tables grouping params ( '[] :=> 'NotNull 'PGbool)
580580
581581-- | >>> renderExpression true
582582-- "TRUE"
@@ -615,10 +615,10 @@ not_ = unsafeUnaryOp "NOT"
615615-- "CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END"
616616caseWhenThenElse
617617 :: [ ( Condition tables grouping params
618− , Expression tables grouping params '( '[], ty)
618+ , Expression tables grouping params ( '[] :=> ty)
619619 ) ]
620− -> Expression tables grouping params '( '[], ty)
621− -> Expression tables grouping params '( '[], ty)
620+ -> Expression tables grouping params ( '[] :=> ty)
621+ -> Expression tables grouping params ( '[] :=> ty)
622622caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
623623 [ "CASE"
624624 , mconcat
@@ -636,9 +636,9 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
636636-- "CASE WHEN TRUE THEN 1 ELSE 0 END"
637637ifThenElse
638638 :: Condition tables grouping params
639− -> Expression tables grouping params '( '[], ty)
640− -> Expression tables grouping params '( '[], ty)
641− -> Expression tables grouping params '( '[], ty)
639+ -> Expression tables grouping params ( '[] :=> ty)
640+ -> Expression tables grouping params ( '[] :=> ty)
641+ -> Expression tables grouping params ( '[] :=> ty)
642642ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
643643
644644-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -647,8 +647,8 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
647647-- >>> renderExpression $ unNull true .== null_
648648-- "(TRUE = NULL)"
649649(.==)
650− :: Expression tables grouping params '( '[], (nullity ty)) -- ^ lhs
651− -> Expression tables grouping params '( '[], (nullity ty)) -- ^ rhs
650+ :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
651+ -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
652652 -> Expression tables grouping params '( '[], (nullity 'PGbool))
653653(.==) = unsafeBinaryOp "="
654654infix 4 .==
@@ -656,8 +656,8 @@ infix 4 .==
656656-- | >>> renderExpression $ unNull true ./= null_
657657-- "(TRUE <> NULL)"
658658(./=)
659− :: Expression tables grouping params '( '[], (nullity ty)) -- ^ lhs
660− -> Expression tables grouping params '( '[], (nullity ty)) -- ^ rhs
659+ :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
660+ -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
661661 -> Expression tables grouping params '( '[], (nullity 'PGbool))
662662(./=) = unsafeBinaryOp "<>"
663663infix 4 ./=
@@ -665,8 +665,8 @@ infix 4 ./=
665665-- | >>> renderExpression $ unNull true .>= null_
666666-- "(TRUE >= NULL)"
667667(.>=)
668− :: Expression tables grouping params '( '[], (nullity ty)) -- ^ lhs
669− -> Expression tables grouping params '( '[], (nullity ty)) -- ^ rhs
668+ :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
669+ -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
670670 -> Expression tables grouping params '( '[], (nullity 'PGbool))
671671(.>=) = unsafeBinaryOp ">="
672672infix 4 .>=
@@ -674,8 +674,8 @@ infix 4 .>=
674674-- | >>> renderExpression $ unNull true .< null_
675675-- "(TRUE < NULL)"
676676(.<)
677− :: Expression tables grouping params '( '[], (nullity ty)) -- ^ lhs
678− -> Expression tables grouping params '( '[], (nullity ty)) -- ^ rhs
677+ :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
678+ -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
679679 -> Expression tables grouping params '( '[], (nullity 'PGbool))
680680(.<) = unsafeBinaryOp "<"
681681infix 4 .<
@@ -683,8 +683,8 @@ infix 4 .<
683683-- | >>> renderExpression $ unNull true .<= null_
684684-- "(TRUE <= NULL)"
685685(.<=)
686− :: Expression tables grouping params '( '[], (nullity ty)) -- ^ lhs
687− -> Expression tables grouping params '( '[], (nullity ty)) -- ^ rhs
686+ :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
687+ -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
688688 -> Expression tables grouping params '( '[], (nullity 'PGbool))
689689(.<=) = unsafeBinaryOp "<="
690690infix 4 .<=
@@ -692,8 +692,8 @@ infix 4 .<=
692692-- | >>> renderExpression $ unNull true .> null_
693693-- "(TRUE > NULL)"
694694(.>)
695− :: Expression tables grouping params '( '[], (nullity ty)) -- ^ lhs
696− -> Expression tables grouping params '( '[], (nullity ty)) -- ^ rhs
695+ :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
696+ -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
697697 -> Expression tables grouping params '( '[], (nullity 'PGbool))
698698(.>) = unsafeBinaryOp ">"
699699infix 4 .>
@@ -801,16 +801,16 @@ aggregation
801801-- | escape hatch to define aggregate functions
802802unsafeAggregate
803803 :: ByteString -- ^ aggregate function
804− -> Expression tables 'Ungrouped params '( '[], xty)
805− -> Expression tables ('Grouped bys) params '( '[], yty)
804+ -> Expression tables 'Ungrouped params ( '[] :=> xty)
805+ -> Expression tables ('Grouped bys) params ( '[] :=> yty)
806806unsafeAggregate fun x = UnsafeExpression $ mconcat
807807 [fun, "(", renderExpression x, ")"]
808808
809809-- | escape hatch to define aggregate functions over distinct values
810810unsafeAggregateDistinct
811811 :: ByteString -- ^ aggregate function
812− -> Expression tables 'Ungrouped params '( '[], xty)
813− -> Expression tables ('Grouped bys) params '( '[], yty)
812+ -> Expression tables 'Ungrouped params ( '[] :=> xty)
813+ -> Expression tables ('Grouped bys) params ( '[] :=> yty)
814814unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
815815 [fun, "(DISTINCT ", renderExpression x, ")"]
816816
@@ -818,25 +818,25 @@ unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
818818-- "sum(col)"
819819sum_
820820 :: PGNum ty
821− => Expression tables 'Ungrouped params '( '[], (nullity ty))
821+ => Expression tables 'Ungrouped params ( '[] :=> nullity ty)
822822 -- ^ what to sum
823− -> Expression tables ('Grouped bys) params '( '[], (nullity ty))
823+ -> Expression tables ('Grouped bys) params ( '[] :=> nullity ty)
824824sum_ = unsafeAggregate "sum"
825825
826826-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGnumeric)]] $ sumDistinct #col
827827-- "sum(DISTINCT col)"
828828sumDistinct
829829 :: PGNum ty
830− => Expression tables 'Ungrouped params '( '[], (nullity ty))
830+ => Expression tables 'Ungrouped params ( '[] :=> nullity ty)
831831 -- ^ what to sum
832− -> Expression tables ('Grouped bys) params '( '[], (nullity ty))
832+ -> Expression tables ('Grouped bys) params ( '[] :=> nullity ty)
833833sumDistinct = unsafeAggregateDistinct "sum"
834834
835835-- | A constraint for `PGType`s that you can take averages of and the resulting
836836-- `PGType`.
837837class PGAvg ty avg | ty -> avg where
838838 avg, avgDistinct
839− :: Expression tables 'Ungrouped params '( '[], (nullity ty))
839+ :: Expression tables 'Ungrouped params ( '[] :=> nullity ty)
840840 -- ^ what to average
841841 -> Expression tables ('Grouped bys) params '( '[], (nullity avg))
842842 avg = unsafeAggregate "avg"
@@ -853,36 +853,36 @@ instance PGAvg 'PGinterval 'PGinterval
853853-- "bit_and(col)"
854854bitAnd
855855 :: PGIntegral int
856− => Expression tables 'Ungrouped params '( '[], (nullity int))
856+ => Expression tables 'Ungrouped params ( '[] :=> nullity int)
857857 -- ^ what to aggregate
858− -> Expression tables ('Grouped bys) params '( '[], (nullity int))
858+ -> Expression tables ('Grouped bys) params ( '[] :=> nullity int)
859859bitAnd = unsafeAggregate "bit_and"
860860
861861-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGint4)]] $ bitOr #col
862862-- "bit_or(col)"
863863bitOr
864864 :: PGIntegral int
865− => Expression tables 'Ungrouped params '( '[], (nullity int))
865+ => Expression tables 'Ungrouped params ( '[] :=> nullity int)
866866 -- ^ what to aggregate
867− -> Expression tables ('Grouped bys) params '( '[], (nullity int))
867+ -> Expression tables ('Grouped bys) params ( '[] :=> nullity int)
868868bitOr = unsafeAggregate "bit_or"
869869
870870-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGint4)]] $ bitAndDistinct #col
871871-- "bit_and(DISTINCT col)"
872872bitAndDistinct
873873 :: PGIntegral int
874− => Expression tables 'Ungrouped params '( '[], (nullity int))
874+ => Expression tables 'Ungrouped params ( '[] :=> nullity int)
875875 -- ^ what to aggregate
876− -> Expression tables ('Grouped bys) params '( '[], (nullity int))
876+ -> Expression tables ('Grouped bys) params ( '[] :=> nullity int)
877877bitAndDistinct = unsafeAggregateDistinct "bit_and"
878878
879879-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGint4)]] $ bitOrDistinct #col
880880-- "bit_or(DISTINCT col)"
881881bitOrDistinct
882882 :: PGIntegral int
883− => Expression tables 'Ungrouped params '( '[], (nullity int))
883+ => Expression tables 'Ungrouped params ( '[] :=> nullity int)
884884 -- ^ what to aggregate
885− -> Expression tables ('Grouped bys) params '( '[], (nullity int))
885+ -> Expression tables ('Grouped bys) params ( '[] :=> nullity int)
886886bitOrDistinct = unsafeAggregateDistinct "bit_or"
887887
888888-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ boolAnd #col
@@ -928,7 +928,7 @@ countStar = UnsafeExpression $ "count(*)"
928928-- | >>> renderExpression @'[_ ::: '["col" ::: 'Optional _]] $ count #col
929929-- "count(col)"
930930count
931− :: Expression tables 'Ungrouped params '( '[], ty)
931+ :: Expression tables 'Ungrouped params ( '[] :=> ty)
932932 -- ^ what to count
933933 -> Expression tables ('Grouped bys) params '( '[], ('NotNull 'PGint8))
934934count = unsafeAggregate "count"
@@ -936,7 +936,7 @@ count = unsafeAggregate "count"
936936-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required _]] $ countDistinct #col
937937-- "count(DISTINCT col)"
938938countDistinct
939− :: Expression tables 'Ungrouped params '( '[], ty)
939+ :: Expression tables 'Ungrouped params ( '[] :=> ty)
940940 -- ^ what to count
941941 -> Expression tables ('Grouped bys) params '( '[], ('NotNull 'PGint8))
942942countDistinct = unsafeAggregateDistinct "count"
@@ -963,9 +963,9 @@ everyDistinct = unsafeAggregateDistinct "every"
963963
964964-- | minimum and maximum aggregation
965965max_, min_, maxDistinct, minDistinct
966− :: Expression tables 'Ungrouped params '( '[], (nullity ty))
966+ :: Expression tables 'Ungrouped params ( '[] :=> nullity ty)
967967 -- ^ what to aggregate
968− -> Expression tables ('Grouped bys) params '( '[], (nullity ty))
968+ -> Expression tables ('Grouped bys) params ( '[] :=> nullity ty)
969969max_ = unsafeAggregate "max"
970970min_ = unsafeAggregate "min"
971971maxDistinct = unsafeAggregateDistinct "max"
@@ -1008,45 +1008,48 @@ newtype TypeExpression (ty :: ColumnType)
10081008 deriving (GHC.Generic,Show,Eq,Ord,NFData)
10091009
10101010-- | logical Boolean (true/false)
1011−bool :: TypeExpression '( '[], ('Null 'PGbool))
1011+bool :: TypeExpression ( '[] :=> 'Null 'PGbool)
10121012bool = UnsafeTypeExpression "bool"
10131013-- | signed two-byte integer
1014−int2, smallint :: TypeExpression '( '[], ('Null 'PGint2))
1014+int2, smallint :: TypeExpression ( '[] :=> 'Null 'PGint2)
10151015int2 = UnsafeTypeExpression "int2"
10161016smallint = UnsafeTypeExpression "smallint"
10171017-- | signed four-byte integer
1018−int4, int, integer :: TypeExpression '( '[], ('Null 'PGint4))
1018+int4, int, integer :: TypeExpression ( '[] :=> 'Null 'PGint4)
10191019int4 = UnsafeTypeExpression "int4"
10201020int = UnsafeTypeExpression "int"
10211021integer = UnsafeTypeExpression "integer"
10221022-- | signed eight-byte integer
1023−int8, bigint :: TypeExpression '( '[], ('Null 'PGint8))
1023+int8, bigint :: TypeExpression ( '[] :=> 'Null 'PGint8)
10241024int8 = UnsafeTypeExpression "int8"
10251025bigint = UnsafeTypeExpression "bigint"
10261026-- | arbitrary precision numeric type
1027−numeric :: TypeExpression '( '[], ('Null 'PGnumeric))
1027+numeric :: TypeExpression ( '[] :=> 'Null 'PGnumeric)
10281028numeric = UnsafeTypeExpression "numeric"
10291029-- | single precision floating-point number (4 bytes)
1030−float4, real :: TypeExpression '( '[], ('Null 'PGfloat4))
1030+float4, real :: TypeExpression ( '[] :=> 'Null 'PGfloat4)
10311031float4 = UnsafeTypeExpression "float4"
10321032real = UnsafeTypeExpression "real"
10331033-- | double precision floating-point number (8 bytes)
1034−float8, doublePrecision :: TypeExpression '( '[], ('Null 'PGfloat8))
1034+float8, doublePrecision :: TypeExpression ( '[] :=> 'Null 'PGfloat8)
10351035float8 = UnsafeTypeExpression "float8"
10361036doublePrecision = UnsafeTypeExpression "double precision"
10371037-- | not a true type, but merely a notational convenience for creating
10381038-- unique identifier columns with type `'PGint2`
1039−serial2, smallserial :: TypeExpression '(constraints, ('NotNull 'PGint2))
1039+serial2, smallserial
1040+ :: TypeExpression ( '[ 'Default, 'Unique] :=> 'NotNull 'PGint2)
10401041serial2 = UnsafeTypeExpression "serial2"
10411042smallserial = UnsafeTypeExpression "smallserial"
10421043-- | not a true type, but merely a notational convenience for creating
10431044-- unique identifier columns with type `'PGint4`
1044−serial4, serial :: TypeExpression '(constraints, ('NotNull 'PGint4))
1045+serial4, serial
1046+ :: TypeExpression ( '[Default, 'Unique] :=> 'NotNull 'PGint4)
10451047serial4 = UnsafeTypeExpression "serial4"
10461048serial = UnsafeTypeExpression "serial"
10471049-- | not a true type, but merely a notational convenience for creating
10481050-- unique identifier columns with type `'PGint8`
1049−serial8, bigserial :: TypeExpression '(constraints, ('NotNull 'PGint8))
1051+serial8, bigserial
1052+ :: TypeExpression ( '[ 'Default, 'Unique] :=> 'NotNull 'PGint8)
10501053serial8 = UnsafeTypeExpression "serial8"
10511054bigserial = UnsafeTypeExpression "bigserial"
10521055-- | variable-length character string
@@ -1068,57 +1071,57 @@ varchar p = UnsafeTypeExpression $ "varchar(" <> renderNat p <> ")"
10681071characterVarying p = UnsafeTypeExpression $
10691072 "character varying(" <> renderNat p <> ")"
10701073-- | binary data ("byte array")
1071−bytea :: TypeExpression '( '[], ('Null 'PGbytea))
1074+bytea :: TypeExpression ( '[] :=> 'Null 'PGbytea)
10721075bytea = UnsafeTypeExpression "bytea"
10731076-- | date and time (no time zone)
1074−timestamp :: TypeExpression '( '[], ('Null 'PGtimestamp))
1077+timestamp :: TypeExpression ( '[] :=> 'Null 'PGtimestamp)
10751078timestamp = UnsafeTypeExpression "timestamp"
10761079-- | date and time, including time zone
1077−timestampWithTimeZone :: TypeExpression '( '[], ('Null 'PGtimestamptz))
1080+timestampWithTimeZone :: TypeExpression ( '[] :=> 'Null 'PGtimestamptz)
10781081timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
10791082-- | calendar date (year, month, day)
1080−date :: TypeExpression '( '[], ('Null 'PGdate))
1083+date :: TypeExpression ( '[] :=> 'Null 'PGdate)
10811084date = UnsafeTypeExpression "date"
10821085-- | time of day (no time zone)
1083−time :: TypeExpression '( '[], ('Null 'PGtime))
1086+time :: TypeExpression ( '[] :=> 'Null 'PGtime)
10841087time = UnsafeTypeExpression "time"
10851088-- | time of day, including time zone
1086−timeWithTimeZone :: TypeExpression '( '[], ('Null 'PGtimetz))
1089+timeWithTimeZone :: TypeExpression ( '[] :=> 'Null 'PGtimetz)
10871090timeWithTimeZone = UnsafeTypeExpression "time with time zone"
10881091-- | time span
1089−interval :: TypeExpression '( '[], ('Null 'PGinterval))
1092+interval :: TypeExpression ( '[] :=> 'Null 'PGinterval)
10901093interval = UnsafeTypeExpression "interval"
10911094-- | universally unique identifier
1092−uuid :: TypeExpression '( '[], ('Null 'PGuuid))
1095+uuid :: TypeExpression ( '[] :=> 'Null 'PGuuid)
10931096uuid = UnsafeTypeExpression "uuid"
10941097-- | IPv4 or IPv6 host address
1095−inet :: TypeExpression '( '[], ('Null 'PGinet))
1098+inet :: TypeExpression ( '[] :=> 'Null 'PGinet)
10961099inet = UnsafeTypeExpression "inet"
10971100-- | textual JSON data
1098−json :: TypeExpression '( '[], ('Null 'PGjson))
1101+json :: TypeExpression ( '[] :=> 'Null 'PGjson)
10991102json = UnsafeTypeExpression "json"
11001103-- | binary JSON data, decomposed
1101−jsonb :: TypeExpression '( '[], ('Null 'PGjsonb))
1104+jsonb :: TypeExpression ( '[] :=> 'Null 'PGjsonb)
11021105jsonb = UnsafeTypeExpression "jsonb"
11031106
11041107-- | used in `createTable` commands as a column constraint to ensure
11051108-- @NULL@ is not present
11061109notNull
1107− :: TypeExpression (optionality ('Null ty))
1108− -> TypeExpression (optionality ('NotNull ty))
1110+ :: TypeExpression (constraints :=> 'Null ty)
1111+ -> TypeExpression (constraints :=> 'NotNull ty)
11091112notNull ty = UnsafeTypeExpression $ renderTypeExpression ty <+> "NOT NULL"
11101113
11111114-- | used in `createTable` commands as a column constraint to give a default
11121115default_
1113− :: Expression '[] 'Ungrouped '[] '( '[], ty)
1114− -> TypeExpression '( '[], ty)
1116+ :: Expression '[] 'Ungrouped '[] ( '[] :=> ty)
1117+ -> TypeExpression ( '[] :=> ty)
11151118 -> TypeExpression '(constraints, ty)
11161119default_ x ty = UnsafeTypeExpression $
11171120 renderTypeExpression ty <+> "DEFAULT" <+> renderExpression x
11181121
11191122-- | `pgtype` is a demoted version of a `PGType`
11201123class PGTyped (ty :: PGType) where
1121− pgtype :: TypeExpression '( '[], ('Null ty))
1124+ pgtype :: TypeExpression ( '[] :=> 'Null ty)
11221125instance PGTyped 'PGbool where pgtype = bool
11231126instance PGTyped 'PGint2 where pgtype = int2
11241127instance PGTyped 'PGint4 where pgtype = int4