@@ -293,15 +293,15 @@ and other operations.
293293-}
294294newtype Expression
295295 (outer :: FromType)
296− (grp :: Grouping)
297296 (commons :: FromType)
297+ (grp :: Grouping)
298298 (schemas :: SchemasType)
299299 (params :: [NullityType])
300300 (from :: FromType)
301301 (ty :: NullityType)
302302 = UnsafeExpression { renderExpression :: ByteString }
303303 deriving (GHC.Generic,Show,Eq,Ord,NFData)
304−instance RenderSQL (Expression outer grp commons schemas params from ty) where
304+instance RenderSQL (Expression outer commons grp schemas params from ty) where
305305 renderSQL = renderExpression
306306
307307-- | An `Expr` is a closed `Expression`.
@@ -311,18 +311,18 @@ instance RenderSQL (Expression outer grp commons schemas params from ty) where
311311-- or alias references. It can be used as
312312-- a simple piece of more complex `Expression`s.
313313type Expr x
314− = forall outer grp commons schemas params from
315− . Expression outer grp commons schemas params from x
314+ = forall outer commons grp schemas params from
315+ . Expression outer commons grp schemas params from x
316316 -- ^ cannot reference aliases
317317
318318-- | A `RankNType` for binary operators.
319319type Operator x1 x2 y
320− = forall outer grp commons schemas params from
321− . Expression outer grp commons schemas params from x1
320+ = forall outer commons grp schemas params from
321+ . Expression outer commons grp schemas params from x1
322322 -- ^ left input
323− -> Expression outer grp commons schemas params from x2
323+ -> Expression outer commons grp schemas params from x2
324324 -- ^ right input
325− -> Expression outer grp commons schemas params from y
325+ -> Expression outer commons grp schemas params from y
326326 -- ^ output
327327
328328-- | A `RankNType` for functions with a single argument.
@@ -331,10 +331,10 @@ type Operator x1 x2 y
331331-- indeed a subcategory as it is closed under the usual
332332-- `Prelude..` and `Prelude.id`.
333333type (:-->) x y
334− = forall outer grp commons schemas params from
335− . Expression outer grp commons schemas params from x
334+ = forall outer commons grp schemas params from
335+ . Expression outer commons grp schemas params from x
336336 -- ^ input
337− -> Expression outer grp commons schemas params from y
337+ -> Expression outer commons grp schemas params from y
338338 -- ^ output
339339
340340{- | A `RankNType` for functions with a fixed-length list of heterogeneous arguments.
@@ -344,22 +344,22 @@ Use the `*:` operator to end your argument lists, like so.
344344fun(TRUE, FALSE, LOCALTIME, TRUE)
345345-}
346346type FunctionHet xs y
347− = forall outer grp commons schemas params from
348− . NP (Expression outer grp commons schemas params from) xs
347+ = forall outer commons grp schemas params from
348+ . NP (Expression outer commons grp schemas params from) xs
349349 -- ^ inputs
350− -> Expression outer grp commons schemas params from y
350+ -> Expression outer commons grp schemas params from y
351351 -- ^ output
352352
353353{- | A `RankNType` for functions with a variable-length list of
354354homogeneous arguments and at least 1 more argument.
355355-}
356356type FunctionHom x0 x1 y
357− = forall outer grp commons schemas params from
358− . [Expression outer grp commons schemas params from x0]
357+ = forall outer commons grp schemas params from
358+ . [Expression outer commons grp schemas params from x0]
359359 -- ^ inputs
360− -> Expression outer grp commons schemas params from x1
360+ -> Expression outer commons grp schemas params from x1
361361 -- ^ must have at least 1 input
362− -> Expression outer grp commons schemas params from y
362+ -> Expression outer commons grp schemas params from y
363363 -- ^ output
364364
365365{- | >>> printSQL (unsafeFunctionHom "greatest" [true, null_] false)
@@ -384,12 +384,12 @@ class KnownNat n => HasParameter
384384 | n params -> ty where
385385 -- | `parameter` takes a `Nat` using type application and a `TypeExpression`.
386386 --
387− -- >>> let expr = parameter @1 int4 :: Expression outer grp '[] schemas '[ 'Null 'PGint4] from ('Null 'PGint4)
387+ -- >>> let expr = parameter @1 int4 :: Expression outer '[] grp schemas '[ 'Null 'PGint4] from ('Null 'PGint4)
388388 -- >>> printSQL expr
389389 -- ($1 :: int4)
390390 parameter
391391 :: TypeExpression schemas ty
392− -> Expression outer grp commons schemas params from ty
392+ -> Expression outer commons grp schemas params from ty
393393 parameter ty = UnsafeExpression $ parenthesized $
394394 "$" <> renderNat @n <+> "::"
395395 <+> renderSQL ty
@@ -400,44 +400,44 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
400400-- | `param` takes a `Nat` using type application and for basic types,
401401-- infers a `TypeExpression`.
402402--
403−-- >>> let expr = param @1 :: Expression outer grp commons schemas '[ 'Null 'PGint4] from ('Null 'PGint4)
403+-- >>> let expr = param @1 :: Expression outer commons grp schemas '[ 'Null 'PGint4] from ('Null 'PGint4)
404404-- >>> printSQL expr
405405-- ($1 :: int4)
406406param
407407 :: forall n outer commons schemas params from grp ty
408408 . (PGTyped schemas ty, HasParameter n params ty)
409− => Expression outer grp commons schemas params from ty -- ^ param
409+ => Expression outer commons grp schemas params from ty -- ^ param
410410param = parameter @n (pgtype @schemas)
411411
412412instance (HasUnique tab (Join outer from) row, Has col row ty)
413− => IsLabel col (Expression outer 'Ungrouped commons schemas params from ty) where
413+ => IsLabel col (Expression outer commons 'Ungrouped schemas params from ty) where
414414 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
415415instance (HasUnique tab (Join outer from) row, Has col row ty, tys ~ '[ty])
416− => IsLabel col (NP (Expression outer 'Ungrouped commons schemas params from) tys) where
416+ => IsLabel col (NP (Expression outer commons 'Ungrouped schemas params from) tys) where
417417 fromLabel = fromLabel @col :* Nil
418418instance (HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty))
419419 => IsLabel col
420− (Aliased (Expression outer 'Ungrouped commons schemas params from) column) where
420+ (Aliased (Expression outer commons 'Ungrouped schemas params from) column) where
421421 fromLabel = fromLabel @col `As` Alias
422422instance (HasUnique tab (Join outer from) row, Has col row ty, columns ~ '[col ::: ty])
423423 => IsLabel col
424− (NP (Aliased (Expression outer 'Ungrouped commons schemas params from)) columns) where
424+ (NP (Aliased (Expression outer commons 'Ungrouped schemas params from)) columns) where
425425 fromLabel = fromLabel @col :* Nil
426426
427427instance (Has tab (Join outer from) row, Has col row ty)
428− => IsQualified tab col (Expression outer 'Ungrouped commons schemas params from ty) where
428+ => IsQualified tab col (Expression outer commons 'Ungrouped schemas params from ty) where
429429 tab ! col = UnsafeExpression $
430430 renderSQL tab <> "." <> renderSQL col
431431instance (Has tab (Join outer from) row, Has col row ty, tys ~ '[ty])
432− => IsQualified tab col (NP (Expression outer 'Ungrouped commons schemas params from) tys) where
432+ => IsQualified tab col (NP (Expression outer commons 'Ungrouped schemas params from) tys) where
433433 tab ! col = tab ! col :* Nil
434434instance (Has tab (Join outer from) row, Has col row ty, column ~ (col ::: ty))
435435 => IsQualified tab col
436− (Aliased (Expression outer 'Ungrouped commons schemas params from) column) where
436+ (Aliased (Expression outer commons 'Ungrouped schemas params from) column) where
437437 tab ! col = tab ! col `As` col
438438instance (Has tab (Join outer from) row, Has col row ty, columns ~ '[col ::: ty])
439439 => IsQualified tab col
440− (NP (Aliased (Expression outer 'Ungrouped commons schemas params from)) columns) where
440+ (NP (Aliased (Expression outer commons 'Ungrouped schemas params from)) columns) where
441441 tab ! col = tab ! col :* Nil
442442
443443instance
@@ -445,7 +445,7 @@ instance
445445 , Has col row ty
446446 , GroupedBy tab col bys
447447 ) => IsLabel col
448− (Expression outer ('Grouped bys) commons schemas params from ty) where
448+ (Expression outer commons ('Grouped bys) schemas params from ty) where
449449 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
450450instance
451451 ( HasUnique tab (Join outer from) row
@@ -453,7 +453,7 @@ instance
453453 , GroupedBy tab col bys
454454 , tys ~ '[ty]
455455 ) => IsLabel col
456− (NP (Expression outer ('Grouped bys) commons schemas params from) tys) where
456+ (NP (Expression outer commons ('Grouped bys) schemas params from) tys) where
457457 fromLabel = fromLabel @col :* Nil
458458instance
459459 ( HasUnique tab (Join outer from) row
@@ -461,7 +461,7 @@ instance
461461 , GroupedBy tab col bys
462462 , column ~ (col ::: ty)
463463 ) => IsLabel col
464− (Aliased (Expression outer ('Grouped bys) commons schemas params from) column) where
464+ (Aliased (Expression outer commons ('Grouped bys) schemas params from) column) where
465465 fromLabel = fromLabel @col `As` Alias
466466instance
467467 ( HasUnique tab (Join outer from) row
@@ -469,7 +469,7 @@ instance
469469 , GroupedBy tab col bys
470470 , columns ~ '[col ::: ty]
471471 ) => IsLabel col
472− (NP (Aliased (Expression outer ('Grouped bys) commons schemas params from)) columns) where
472+ (NP (Aliased (Expression outer commons ('Grouped bys) schemas params from)) columns) where
473473 fromLabel = fromLabel @col :* Nil
474474
475475instance
@@ -477,7 +477,7 @@ instance
477477 , Has col row ty
478478 , GroupedBy tab col bys
479479 ) => IsQualified tab col
480− (Expression outer ('Grouped bys) commons schemas params from ty) where
480+ (Expression outer commons ('Grouped bys) schemas params from ty) where
481481 tab ! col = UnsafeExpression $
482482 renderSQL tab <> "." <> renderSQL col
483483instance
@@ -486,7 +486,7 @@ instance
486486 , GroupedBy tab col bys
487487 , tys ~ '[ty]
488488 ) => IsQualified tab col
489− (NP (Expression outer ('Grouped bys) commons schemas params from) tys) where
489+ (NP (Expression outer commons ('Grouped bys) schemas params from) tys) where
490490 tab ! col = tab ! col :* Nil
491491instance
492492 ( Has tab (Join outer from) row
@@ -494,7 +494,7 @@ instance
494494 , GroupedBy tab col bys
495495 , column ~ (col ::: ty)
496496 ) => IsQualified tab col
497− (Aliased (Expression outer ('Grouped bys) commons schemas params from) column) where
497+ (Aliased (Expression outer commons ('Grouped bys) schemas params from) column) where
498498 tab ! col = tab ! col `As` col
499499instance
500500 ( Has tab (Join outer from) row
@@ -502,7 +502,7 @@ instance
502502 , GroupedBy tab col bys
503503 , columns ~ '[col ::: ty]
504504 ) => IsQualified tab col
505− (NP (Aliased (Expression outer ('Grouped bys) commons schemas params from)) columns) where
505+ (NP (Aliased (Expression outer commons ('Grouped bys) schemas params from)) columns) where
506506 tab ! col = tab ! col :* Nil
507507
508508-- | analagous to `Nothing`
@@ -533,10 +533,10 @@ coalesce nullxs notNullx = UnsafeExpression $
533533-- >>> printSQL $ fromNull true null_
534534-- COALESCE(NULL, TRUE)
535535fromNull
536− :: Expression outer grp commons schemas params from ('NotNull ty)
536+ :: Expression outer commons grp schemas params from ('NotNull ty)
537537 -- ^ what to convert @NULL@ to
538− -> Expression outer grp commons schemas params from ('Null ty)
539− -> Expression outer grp commons schemas params from ('NotNull ty)
538+ -> Expression outer commons grp schemas params from ('Null ty)
539+ -> Expression outer commons grp schemas params from ('NotNull ty)
540540fromNull notNullx nullx = coalesce [nullx] notNullx
541541
542542-- | >>> printSQL $ null_ & isNull
@@ -554,13 +554,13 @@ isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
554554-- >>> printSQL $ matchNull true not_ null_
555555-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
556556matchNull
557− :: Expression outer grp commons schemas params from (nullty)
557+ :: Expression outer commons grp schemas params from (nullty)
558558 -- ^ what to convert @NULL@ to
559− -> ( Expression outer grp commons schemas params from ('NotNull ty)
560− -> Expression outer grp commons schemas params from (nullty) )
559+ -> ( Expression outer commons grp schemas params from ('NotNull ty)
560+ -> Expression outer commons grp schemas params from (nullty) )
561561 -- ^ function to perform when @NULL@ is absent
562− -> Expression outer grp commons schemas params from ('Null ty)
563− -> Expression outer grp commons schemas params from (nullty)
562+ -> Expression outer commons grp schemas params from ('Null ty)
563+ -> Expression outer commons grp schemas params from (nullty)
564564matchNull y f x = ifThenElse (isNull x) y
565565 (f (UnsafeExpression (renderSQL x)))
566566
@@ -568,7 +568,7 @@ matchNull y f x = ifThenElse (isNull x) y
568568`nullIf` gives @NULL@.
569569
570570>>> :set -XTypeApplications -XDataKinds
571−>>> let expr = nullIf (false *: param @1) :: Expression outer grp commons schemas '[ 'NotNull 'PGbool] from ('Null 'PGbool)
571+>>> let expr = nullIf (false *: param @1) :: Expression outer commons grp schemas '[ 'NotNull 'PGbool] from ('Null 'PGbool)
572572>>> printSQL expr
573573NULLIF(FALSE, ($1 :: bool))
574574-}
@@ -578,9 +578,9 @@ nullIf = unsafeFunctionHet "NULLIF"
578578-- | >>> printSQL $ array [null_, false, true]
579579-- ARRAY[NULL, FALSE, TRUE]
580580array
581− :: [Expression outer grp commons schemas params from ty]
581+ :: [Expression outer commons grp schemas params from ty]
582582 -- ^ array elements
583− -> Expression outer grp commons schemas params from (null ('PGvararray ty))
583+ -> Expression outer commons grp schemas params from (null ('PGvararray ty))
584584array xs = UnsafeExpression $ "ARRAY" <>
585585 bracketed (commaSeparated (renderSQL <$> xs))
586586
@@ -593,8 +593,8 @@ ARRAY[NULL, FALSE, TRUE]
593593array1 (null_ :* false *: true)
594594 :: Expression
595595 outer
596− grp
597596 commons
597+ grp
598598 schemas
599599 params
600600 from
@@ -602,8 +602,8 @@ array1 (null_ :* false *: true)
602602-}
603603array1
604604 :: (n ~ Length tys, SOP.All ((~) ty) tys)
605− => NP (Expression outer grp commons schemas params from) tys
606− -> Expression outer grp commons schemas params from (null ('PGfixarray '[n] ty))
605+ => NP (Expression outer commons grp schemas params from) tys
606+ -> Expression outer commons grp schemas params from (null ('PGfixarray '[n] ty))
607607array1 xs = UnsafeExpression $ "ARRAY" <>
608608 bracketed (renderCommaSeparated renderSQL xs)
609609
@@ -616,8 +616,8 @@ ARRAY[[NULL, FALSE, TRUE], [FALSE, NULL, TRUE]]
616616array2 ((null_ :* false *: true) *: (false :* null_ *: true))
617617 :: Expression
618618 outer
619− grp
620619 commons
620+ grp
621621 schemas
622622 params
623623 from
@@ -629,8 +629,8 @@ array2
629629 , Length tyss ~ n1
630630 , SOP.All ((~) ty) tys
631631 , Length tys ~ n2 )
632− => NP (NP (Expression outer grp commons schemas params from)) tyss
633− -> Expression outer grp commons schemas params from (null ('PGfixarray '[n1,n2] ty))
632+ => NP (NP (Expression outer commons grp schemas params from)) tyss
633+ -> Expression outer commons grp schemas params from (null ('PGfixarray '[n1,n2] ty))
634634array2 xss = UnsafeExpression $ "ARRAY" <>
635635 bracketed (renderCommaSeparatedConstraint @SOP.SListI (bracketed . renderCommaSeparated renderSQL) xss)
636636
@@ -648,7 +648,7 @@ index n expr = UnsafeExpression $
648648 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
649649
650650instance (KnownSymbol label, label `In` labels) => IsPGlabel label
651− (Expression outer grp commons schemas params from (null ('PGenum labels))) where
651+ (Expression outer commons grp schemas params from (null ('PGenum labels))) where
652652 label = UnsafeExpression $ renderSQL (PGlabel @label)
653653
654654-- | A row constructor is an expression that builds a row value
@@ -660,14 +660,14 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
660660-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
661661-- :}
662662--
663−-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression outer grp commons schemas params from ('NotNull Complex)
663+-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression outer commons grp schemas params from ('NotNull Complex)
664664-- >>> printSQL i
665665-- ROW(0, 1)
666666row
667667 :: SListI row
668− => NP (Aliased (Expression outer grp commons schemas params from)) row
668+ => NP (Aliased (Expression outer commons grp schemas params from)) row
669669 -- ^ zero or more expressions for the row field values
670− -> Expression outer grp commons schemas params from (null ('PGcomposite row))
670+ -> Expression outer commons grp schemas params from (null ('PGcomposite row))
671671row exprs = UnsafeExpression $ "ROW" <> parenthesized
672672 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
673673
@@ -678,7 +678,7 @@ row exprs = UnsafeExpression $ "ROW" <> parenthesized
678678-- type Schema = '["complex" ::: 'Typedef Complex]
679679-- :}
680680--
681−-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression outer grp '[] (Public Schema) from params ('NotNull Complex)
681+-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression outer '[] grp (Public Schema) from params ('NotNull Complex)
682682-- >>> printSQL $ i & field #complex #imaginary
683683-- (ROW(0, 1)::"complex")."imaginary"
684684field
@@ -687,22 +687,22 @@ field
687687 , Has field row ty)
688688 => QualifiedAlias sch tydef -- ^ row type
689689 -> Alias field -- ^ field name
690− -> Expression outer grp commons schemas params from ('NotNull ('PGcomposite row))
691− -> Expression outer grp commons schemas params from ty
690+ -> Expression outer commons grp schemas params from ('NotNull ('PGcomposite row))
691+ -> Expression outer commons grp schemas params from ty
692692field td fld expr = UnsafeExpression $
693693 parenthesized (renderSQL expr <> "::" <> renderSQL td)
694694 <> "." <> renderSQL fld
695695
696696instance Semigroup
697− (Expression outer grp commons schemas params from (null ('PGvararray ty))) where
697+ (Expression outer commons grp schemas params from (null ('PGvararray ty))) where
698698 (<>) = unsafeBinaryOp "||"
699699
700700instance Monoid
701− (Expression outer grp commons schemas params from (null ('PGvararray ty))) where
701+ (Expression outer commons grp schemas params from (null ('PGvararray ty))) where
702702 mempty = array []
703703 mappend = (<>)
704704
705−-- | >>> let expr = greatest [param @1] currentTimestamp :: Expression outer grp commons schemas '[ 'NotNull 'PGtimestamptz] from ('NotNull 'PGtimestamptz)
705+-- | >>> let expr = greatest [param @1] currentTimestamp :: Expression outer commons grp schemas '[ 'NotNull 'PGtimestamptz] from ('NotNull 'PGtimestamptz)
706706-- >>> printSQL expr
707707-- GREATEST(($1 :: timestamp with time zone), CURRENT_TIMESTAMP)
708708greatest :: FunctionHom ty ty ty
@@ -745,7 +745,7 @@ unsafeFunctionHet fun xs = UnsafeExpression $
745745 fun <> parenthesized (renderCommaSeparated renderSQL xs)
746746
747747instance ty `In` PGNum
748− => Num (Expression outer grp commons schemas params from (null ty)) where
748+ => Num (Expression outer commons grp schemas params from (null ty)) where
749749 (+) = unsafeBinaryOp "+"
750750 (-) = unsafeBinaryOp "-"
751751 (*) = unsafeBinaryOp "*"
@@ -757,7 +757,7 @@ instance ty `In` PGNum
757757 . show
758758
759759instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
760− (Expression outer grp commons schemas params from (null ty)) where
760+ (Expression outer commons grp schemas params from (null ty)) where
761761 (/) = unsafeBinaryOp "/"
762762 fromRational
763763 = UnsafeExpression
@@ -767,7 +767,7 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
767767 . fromRat @Double
768768
769769instance (ty `In` PGNum, ty `In` PGFloating) => Floating
770− (Expression outer grp commons schemas params from (null ty)) where
770+ (Expression outer commons grp schemas params from (null ty)) where
771771 pi = UnsafeExpression "pi()"
772772 exp = unsafeFunction "exp"
773773 log = unsafeFunction "ln"
@@ -809,9 +809,9 @@ atan2_ = unsafeFunctionHet "atan2"
809809cast
810810 :: TypeExpression schemas ty1
811811 -- ^ type to cast as
812− -> Expression outer grp commons schemas params from ty0
812+ -> Expression outer commons grp schemas params from ty0
813813 -- ^ value to convert
814− -> Expression outer grp commons schemas params from ty1
814+ -> Expression outer commons grp schemas params from ty1
815815cast ty x = UnsafeExpression $ parenthesized $
816816 renderSQL x <+> "::" <+> renderSQL ty
817817
@@ -819,7 +819,7 @@ cast ty x = UnsafeExpression $ parenthesized $
819819--
820820-- >>> :{
821821-- let
822−-- expression :: Expression outer grp commons schemas params from (null 'PGint2)
822+-- expression :: Expression outer commons grp schemas params from (null 'PGint2)
823823-- expression = 5 `quot_` 2
824824-- in printSQL expression
825825-- :}
@@ -833,7 +833,7 @@ quot_ = unsafeBinaryOp "/"
833833--
834834-- >>> :{
835835-- let
836−-- expression :: Expression outer grp commons schemas params from (null 'PGint2)
836+-- expression :: Expression outer commons grp schemas params from (null 'PGint2)
837837-- expression = 5 `rem_` 2
838838-- in printSQL expression
839839-- :}
@@ -845,7 +845,7 @@ rem_ = unsafeBinaryOp "%"
845845
846846-- | >>> :{
847847-- let
848−-- expression :: Expression outer grp commons schemas params from (null 'PGfloat4)
848+-- expression :: Expression outer commons grp schemas params from (null 'PGfloat4)
849849-- expression = trunc pi
850850-- in printSQL expression
851851-- :}
@@ -855,7 +855,7 @@ trunc = unsafeFunction "trunc"
855855
856856-- | >>> :{
857857-- let
858−-- expression :: Expression outer grp commons schemas params from (null 'PGfloat4)
858+-- expression :: Expression outer commons grp schemas params from (null 'PGfloat4)
859859-- expression = round_ pi
860860-- in printSQL expression
861861-- :}
@@ -865,7 +865,7 @@ round_ = unsafeFunction "round"
865865
866866-- | >>> :{
867867-- let
868−-- expression :: Expression outer grp commons schemas params from (null 'PGfloat4)
868+-- expression :: Expression outer commons grp schemas params from (null 'PGfloat4)
869869-- expression = ceiling_ pi
870870-- in printSQL expression
871871-- :}
@@ -876,8 +876,8 @@ ceiling_ = unsafeFunction "ceiling"
876876-- | A `Condition` is an `Expression`, which can evaluate
877877-- to `true`, `false` or `null_`. This is because SQL uses
878878-- a three valued logic.
879−type Condition outer grp commons schemas params from =
880− Expression outer grp commons schemas params from ('Null 'PGbool)
879+type Condition outer commons grp schemas params from =
880+ Expression outer commons grp schemas params from ('Null 'PGbool)
881881
882882-- | >>> printSQL true
883883-- TRUE
@@ -908,19 +908,19 @@ infixr 2 .||
908908
909909-- | >>> :{
910910-- let
911−-- expression :: Expression outer grp commons schemas params from (null 'PGint2)
911+-- expression :: Expression outer commons grp schemas params from (null 'PGint2)
912912-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
913913-- in printSQL expression
914914-- :}
915915-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
916916caseWhenThenElse
917− :: [ ( Condition outer grp commons schemas params from
918− , Expression outer grp commons schemas params from ty
917+ :: [ ( Condition outer commons grp schemas params from
918+ , Expression outer commons grp schemas params from ty
919919 ) ]
920920 -- ^ whens and thens
921− -> Expression outer grp commons schemas params from ty
921+ -> Expression outer commons grp schemas params from ty
922922 -- ^ else
923− -> Expression outer grp commons schemas params from ty
923+ -> Expression outer commons grp schemas params from ty
924924caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
925925 [ "CASE"
926926 , mconcat
@@ -936,16 +936,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
936936
937937-- | >>> :{
938938-- let
939−-- expression :: Expression outer grp commons schemas params from (null 'PGint2)
939+-- expression :: Expression outer commons grp schemas params from (null 'PGint2)
940940-- expression = ifThenElse true 1 0
941941-- in printSQL expression
942942-- :}
943943-- CASE WHEN TRUE THEN 1 ELSE 0 END
944944ifThenElse
945− :: Condition outer grp commons schemas params from
946− -> Expression outer grp commons schemas params from ty -- ^ then
947− -> Expression outer grp commons schemas params from ty -- ^ else
948− -> Expression outer grp commons schemas params from ty
945+ :: Condition outer commons grp schemas params from
946+ -> Expression outer commons grp schemas params from ty -- ^ then
947+ -> Expression outer commons grp schemas params from ty -- ^ else
948+ -> Expression outer commons grp schemas params from ty
949949ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
950950
951951-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -991,10 +991,10 @@ infix 4 .>
991991TRUE BETWEEN NULL AND FALSE
992992-}
993993between
994− :: Expression outer grp commons schemas params from (null ty)
995− -> ( Expression outer grp commons schemas params from (null ty)
996− , Expression outer grp commons schemas params from (null ty) ) -- ^ bounds
997− -> Condition outer grp commons schemas params from
994+ :: Expression outer commons grp schemas params from (null ty)
995+ -> ( Expression outer commons grp schemas params from (null ty)
996+ , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
997+ -> Condition outer commons grp schemas params from
998998between a (x,y) = UnsafeExpression $ renderSQL a <+> "BETWEEN"
999999 <+> renderSQL x <+> "AND" <+> renderSQL y
10001000
@@ -1002,10 +1002,10 @@ between a (x,y) = UnsafeExpression $ renderSQL a <+> "BETWEEN"
10021002TRUE NOT BETWEEN NULL AND FALSE
10031003-}
10041004notBetween
1005− :: Expression outer grp commons schemas params from (null ty)
1006− -> ( Expression outer grp commons schemas params from (null ty)
1007− , Expression outer grp commons schemas params from (null ty) ) -- ^ bounds
1008− -> Condition outer grp commons schemas params from
1005+ :: Expression outer commons grp schemas params from (null ty)
1006+ -> ( Expression outer commons grp schemas params from (null ty)
1007+ , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
1008+ -> Condition outer commons grp schemas params from
10091009notBetween a (x,y) = UnsafeExpression $ renderSQL a <+> "NOT BETWEEN"
10101010 <+> renderSQL x <+> "AND" <+> renderSQL y
10111011
@@ -1015,10 +1015,10 @@ notBetween a (x,y) = UnsafeExpression $ renderSQL a <+> "NOT BETWEEN"
10151015TRUE BETWEEN SYMMETRIC NULL AND FALSE
10161016-}
10171017betweenSymmetric
1018− :: Expression outer grp commons schemas params from (null ty)
1019− -> ( Expression outer grp commons schemas params from (null ty)
1020− , Expression outer grp commons schemas params from (null ty) ) -- ^ bounds
1021− -> Condition outer grp commons schemas params from
1018+ :: Expression outer commons grp schemas params from (null ty)
1019+ -> ( Expression outer commons grp schemas params from (null ty)
1020+ , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
1021+ -> Condition outer commons grp schemas params from
10221022betweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
10231023 <+> "BETWEEN SYMMETRIC" <+> renderSQL x <+> "AND" <+> renderSQL y
10241024
@@ -1028,10 +1028,10 @@ betweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
10281028TRUE NOT BETWEEN SYMMETRIC NULL AND FALSE
10291029-}
10301030notBetweenSymmetric
1031− :: Expression outer grp commons schemas params from (null ty)
1032− -> ( Expression outer grp commons schemas params from (null ty)
1033− , Expression outer grp commons schemas params from (null ty) ) -- ^ bounds
1034− -> Condition outer grp commons schemas params from
1031+ :: Expression outer commons grp schemas params from (null ty)
1032+ -> ( Expression outer commons grp schemas params from (null ty)
1033+ , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
1034+ -> Condition outer commons grp schemas params from
10351035notBetweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
10361036 <+> "NOT BETWEEN SYMMETRIC" <+> renderSQL x <+> "AND" <+> renderSQL y
10371037
@@ -1148,31 +1148,31 @@ escape = \case
11481148 c -> [c]
11491149
11501150instance IsString
1151− (Expression outer grp commons schemas params from (null 'PGtext)) where
1151+ (Expression outer commons grp schemas params from (null 'PGtext)) where
11521152 fromString str = UnsafeExpression $
11531153 "E\'" <> fromString (escape =<< str) <> "\'"
11541154instance IsString
1155− (Expression outer grp commons schemas params from (null 'PGtsvector)) where
1155+ (Expression outer commons grp schemas params from (null 'PGtsvector)) where
11561156 fromString str = cast tsvector . UnsafeExpression $
11571157 "E\'" <> fromString (escape =<< str) <> "\'"
11581158instance IsString
1159− (Expression outer grp commons schemas params from (null 'PGtsquery)) where
1159+ (Expression outer commons grp schemas params from (null 'PGtsquery)) where
11601160 fromString str = cast tsquery . UnsafeExpression $
11611161 "E\'" <> fromString (escape =<< str) <> "\'"
11621162
11631163instance Semigroup
1164− (Expression outer grp commons schemas params from (null 'PGtext)) where
1164+ (Expression outer commons grp schemas params from (null 'PGtext)) where
11651165 (<>) = unsafeBinaryOp "||"
11661166instance Semigroup
1167− (Expression outer grp commons schemas params from (null 'PGtsvector)) where
1167+ (Expression outer commons grp schemas params from (null 'PGtsvector)) where
11681168 (<>) = unsafeBinaryOp "||"
11691169
11701170instance Monoid
1171− (Expression outer grp commons schemas params from (null 'PGtext)) where
1171+ (Expression outer commons grp schemas params from (null 'PGtext)) where
11721172 mempty = fromString ""
11731173 mappend = (<>)
11741174instance Monoid
1175− (Expression outer grp commons schemas params from (null 'PGtsvector)) where
1175+ (Expression outer commons grp schemas params from (null 'PGtsvector)) where
11761176 mempty = fromString ""
11771177 mappend = (<>)
11781178
@@ -1282,7 +1282,7 @@ infixl 9 .?&
12821282
12831283-- | Concatenate two jsonb values into a new jsonb value.
12841284instance Semigroup
1285− (Expression outer grp commons schemas params from (null 'PGjsonb)) where
1285+ (Expression outer commons grp schemas params from (null 'PGjsonb)) where
12861286 (<>) = unsafeBinaryOp "||"
12871287
12881288-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1432,9 +1432,9 @@ jsonbArrayLength = unsafeFunction "jsonb_array_length"
14321432-- operator).
14331433jsonExtractPath
14341434 :: SListI elems
1435− => Expression outer grp commons schemas params from (null 'PGjson)
1436− -> NP (Expression outer grp commons schemas params from) elems
1437− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1435+ => Expression outer commons grp schemas params from (null 'PGjson)
1436+ -> NP (Expression outer commons grp schemas params from) elems
1437+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
14381438jsonExtractPath x xs =
14391439 unsafeFunctionHet "json_extract_path" (x :* xs)
14401440
@@ -1442,9 +1442,9 @@ jsonExtractPath x xs =
14421442-- operator).
14431443jsonbExtractPath
14441444 :: SListI elems
1445− => Expression outer grp commons schemas params from (null 'PGjsonb)
1446− -> NP (Expression outer grp commons schemas params from) elems
1447− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1445+ => Expression outer commons grp schemas params from (null 'PGjsonb)
1446+ -> NP (Expression outer commons grp schemas params from) elems
1447+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
14481448jsonbExtractPath x xs =
14491449 unsafeFunctionHet "jsonb_extract_path" (x :* xs)
14501450
@@ -1452,9 +1452,9 @@ jsonbExtractPath x xs =
14521452-- operator), as text.
14531453jsonExtractPathAsText
14541454 :: SListI elems
1455− => Expression outer grp commons schemas params from (null 'PGjson)
1456− -> NP (Expression outer grp commons schemas params from) elems
1457− -> Expression outer grp commons schemas params from (null 'PGjson)
1455+ => Expression outer commons grp schemas params from (null 'PGjson)
1456+ -> NP (Expression outer commons grp schemas params from) elems
1457+ -> Expression outer commons grp schemas params from (null 'PGjson)
14581458jsonExtractPathAsText x xs =
14591459 unsafeFunctionHet "json_extract_path_text" (x :* xs)
14601460
@@ -1462,9 +1462,9 @@ jsonExtractPathAsText x xs =
14621462-- operator), as text.
14631463jsonbExtractPathAsText
14641464 :: SListI elems
1465− => Expression outer grp commons schemas params from (null 'PGjsonb)
1466− -> NP (Expression outer grp commons schemas params from) elems
1467− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1465+ => Expression outer commons grp schemas params from (null 'PGjsonb)
1466+ -> NP (Expression outer commons grp schemas params from) elems
1467+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
14681468jsonbExtractPathAsText x xs =
14691469 unsafeFunctionHet "jsonb_extract_path_text" (x :* xs)
14701470
@@ -1496,11 +1496,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
14961496-- operators, negative integers that appear in path count from the end of JSON
14971497-- arrays.
14981498jsonbSet
1499− :: Expression outer grp commons schemas params from (null 'PGjsonb)
1500− -> Expression outer grp commons schemas params from (null ('PGvararray ('NotNull 'PGtext)))
1501− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1502− -> Maybe (Expression outer grp commons schemas params from (null 'PGbool))
1503− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1499+ :: Expression outer commons grp schemas params from (null 'PGjsonb)
1500+ -> Expression outer commons grp schemas params from (null ('PGvararray ('NotNull 'PGtext)))
1501+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
1502+ -> Maybe (Expression outer commons grp schemas params from (null 'PGbool))
1503+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
15041504jsonbSet tgt path val createMissing = case createMissing of
15051505 Just m -> unsafeFunctionHet "jsonb_set" (tgt :* path :* val :* m :* Nil)
15061506 Nothing -> unsafeFunctionHet "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1514,11 +1514,11 @@ jsonbSet tgt path val createMissing = case createMissing of
15141514-- exist. As with the path orientated operators, negative integers that appear
15151515-- in path count from the end of JSON arrays.
15161516jsonbInsert
1517− :: Expression outer grp commons schemas params from (null 'PGjsonb)
1518− -> Expression outer grp commons schemas params from (null ('PGvararray ('NotNull 'PGtext)))
1519− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1520− -> Maybe (Expression outer grp commons schemas params from (null 'PGbool))
1521− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1517+ :: Expression outer commons grp schemas params from (null 'PGjsonb)
1518+ -> Expression outer commons grp schemas params from (null ('PGvararray ('NotNull 'PGtext)))
1519+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
1520+ -> Maybe (Expression outer commons grp schemas params from (null 'PGbool))
1521+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
15221522jsonbInsert tgt path val insertAfter = case insertAfter of
15231523 Just i -> unsafeFunctionHet "jsonb_insert" (tgt :* path :* val :* i :* Nil)
15241524 Nothing -> unsafeFunctionHet "jsonb_insert" (tgt :* path :* val :* Nil)
@@ -1610,16 +1610,16 @@ aggregation
16101610
16111611type AggrFun x y
16121612 = forall outer bys commons schemas params from
1613− . Distinction (Expression outer 'Ungrouped commons schemas params from) x
1613+ . Distinction (Expression outer commons 'Ungrouped schemas params from) x
16141614 -- ^ input
1615− -> Expression outer ('Grouped bys) commons schemas params from y
1615+ -> Expression outer commons ('Grouped bys) schemas params from y
16161616 -- ^ output
16171617
16181618type AggrHet xs y
16191619 = forall outer bys commons schemas params from
1620− . Distinction (NP (Expression outer 'Ungrouped commons schemas params from)) xs
1620+ . Distinction (NP (Expression outer commons 'Ungrouped schemas params from)) xs
16211621 -- ^ inputs
1622− -> Expression outer ('Grouped bys) commons schemas params from y
1622+ -> Expression outer commons ('Grouped bys) schemas params from y
16231623 -- ^ output
16241624
16251625unsafeAggregateHet :: SOP.SListI xs => ByteString -> AggrHet xs y
@@ -1638,7 +1638,7 @@ class Aggregate expr1 exprHet aggr
16381638 --
16391639 -- >>> :{
16401640 -- let
1641− -- expression :: Expression '[] ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
1641+ -- expression :: Expression '[] commons ('Grouped bys) schemas params from ('NotNull 'PGint8)
16421642 -- expression = countStar
16431643 -- in printSQL expression
16441644 -- :}
@@ -1647,7 +1647,7 @@ class Aggregate expr1 exprHet aggr
16471647
16481648 -- | >>> :{
16491649 -- let
1650− -- expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: null ty]] ('NotNull 'PGint8)
1650+ -- expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null ty]] ('NotNull 'PGint8)
16511651 -- expression = count (All #col)
16521652 -- in printSQL expression
16531653 -- :}
@@ -1659,7 +1659,7 @@ class Aggregate expr1 exprHet aggr
16591659
16601660 -- | >>> :{
16611661 -- let
1662− -- expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('NotNull 'PGnumeric)
1662+ -- expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('NotNull 'PGnumeric)
16631663 -- expression = sum_ (Distinct #col)
16641664 -- in printSQL expression
16651665 -- :}
@@ -1688,7 +1688,7 @@ class Aggregate expr1 exprHet aggr
16881688 the bitwise AND of all non-null input values, or null if none
16891689 >>> :{
16901690 let
1691− expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4)
1691+ expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4)
16921692 expression = bitAnd (Distinct #col)
16931693 in printSQL expression
16941694 :}
@@ -1705,7 +1705,7 @@ class Aggregate expr1 exprHet aggr
17051705
17061706 >>> :{
17071707 let
1708− expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4)
1708+ expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4)
17091709 expression = bitOr (All #col)
17101710 in printSQL expression
17111711 :}
@@ -1722,7 +1722,7 @@ class Aggregate expr1 exprHet aggr
17221722
17231723 >>> :{
17241724 let
1725− winFun :: WindowFunction '[] 'Ungrouped commons schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
1725+ winFun :: WindowFunction '[] commons 'Ungrouped schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
17261726 winFun = boolAnd #col
17271727 in printSQL winFun
17281728 :}
@@ -1738,7 +1738,7 @@ class Aggregate expr1 exprHet aggr
17381738
17391739 >>> :{
17401740 let
1741− expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
1741+ expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
17421742 expression = boolOr (All #col)
17431743 in printSQL expression
17441744 :}
@@ -1754,7 +1754,7 @@ class Aggregate expr1 exprHet aggr
17541754
17551755 >>> :{
17561756 let
1757− expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
1757+ expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
17581758 expression = every (Distinct #col)
17591759 in printSQL expression
17601760 :}
@@ -1786,7 +1786,7 @@ class Aggregate expr1 exprHet aggr
17861786 {- | correlation coefficient
17871787 >>> :{
17881788 let
1789− expression :: Expression '[] ('Grouped g) c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1789+ expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
17901790 expression = corr (All (#y *: #x))
17911791 in printSQL expression
17921792 :}
@@ -1799,7 +1799,7 @@ class Aggregate expr1 exprHet aggr
17991799 {- | population covariance
18001800 >>> :{
18011801 let
1802− expression :: Expression '[] ('Grouped g) c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1802+ expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
18031803 expression = covarPop (All (#y *: #x))
18041804 in printSQL expression
18051805 :}
@@ -1812,7 +1812,7 @@ class Aggregate expr1 exprHet aggr
18121812 {- | sample covariance
18131813 >>> :{
18141814 let
1815− winFun :: WindowFunction '[] 'Ungrouped c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1815+ winFun :: WindowFunction '[] c 'Ungrouped s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
18161816 winFun = covarSamp (#y *: #x)
18171817 in printSQL winFun
18181818 :}
@@ -1825,7 +1825,7 @@ class Aggregate expr1 exprHet aggr
18251825 {- | average of the independent variable (sum(X)/N)
18261826 >>> :{
18271827 let
1828− expression :: Expression '[] ('Grouped g) c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1828+ expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
18291829 expression = regrAvgX (All (#y *: #x))
18301830 in printSQL expression
18311831 :}
@@ -1838,7 +1838,7 @@ class Aggregate expr1 exprHet aggr
18381838 {- | average of the dependent variable (sum(Y)/N)
18391839 >>> :{
18401840 let
1841− winFun :: WindowFunction '[] 'Ungrouped c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1841+ winFun :: WindowFunction '[] c 'Ungrouped s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
18421842 winFun = regrAvgY (#y *: #x)
18431843 in printSQL winFun
18441844 :}
@@ -1851,7 +1851,7 @@ class Aggregate expr1 exprHet aggr
18511851 {- | number of input rows in which both expressions are nonnull
18521852 >>> :{
18531853 let
1854− winFun :: WindowFunction '[] 'Ungrouped c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGint8)
1854+ winFun :: WindowFunction '[] c 'Ungrouped s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGint8)
18551855 winFun = regrCount (#y *: #x)
18561856 in printSQL winFun
18571857 :}
@@ -1864,7 +1864,7 @@ class Aggregate expr1 exprHet aggr
18641864 {- | y-intercept of the least-squares-fit linear equation determined by the (X, Y) pairs
18651865 >>> :{
18661866 let
1867− expression :: Expression '[] ('Grouped g) c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1867+ expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
18681868 expression = regrIntercept (All (#y *: #x))
18691869 in printSQL expression
18701870 :}
@@ -1945,21 +1945,21 @@ data Distinction (expr :: kind -> Type) (ty :: kind)
19451945 = All (expr ty)
19461946 | Distinct (expr ty)
19471947 deriving (GHC.Generic,Show,Eq,Ord)
1948−instance NFData (Distinction (Expression outer grp commons schemas params from) ty)
1949−instance RenderSQL (Distinction (Expression outer grp commons schemas params from) ty) where
1948+instance NFData (Distinction (Expression outer commons grp schemas params from) ty)
1949+instance RenderSQL (Distinction (Expression outer commons grp schemas params from) ty) where
19501950 renderSQL = \case
19511951 All x -> "ALL" <+> renderSQL x
19521952 Distinct x -> "DISTINCT" <+> renderSQL x
19531953instance SOP.SListI tys => RenderSQL
1954− (Distinction (NP (Expression outer grp commons schemas params from)) tys) where
1954+ (Distinction (NP (Expression outer commons grp schemas params from)) tys) where
19551955 renderSQL = \case
19561956 All xs -> "ALL" <+> renderCommaSeparated renderSQL xs
19571957 Distinct xs -> "DISTINCT" <+> renderCommaSeparated renderSQL xs
19581958
19591959instance Aggregate
1960− (Distinction (Expression outer 'Ungrouped commons schemas params from))
1961− (Distinction (NP (Expression outer 'Ungrouped commons schemas params from)))
1962− (Expression outer ('Grouped bys) commons schemas params from) where
1960+ (Distinction (Expression outer commons 'Ungrouped schemas params from))
1961+ (Distinction (NP (Expression outer commons 'Ungrouped schemas params from)))
1962+ (Expression outer commons ('Grouped bys) schemas params from) where
19631963 countStar = UnsafeExpression "count(*)"
19641964 count = unsafeAggregate1 "count"
19651965 sum_ = unsafeAggregate1 "sum"
@@ -1993,9 +1993,9 @@ instance Aggregate
19931993 varPop = unsafeAggregate1 "var_pop"
19941994 varSamp = unsafeAggregate1 "var_samp"
19951995instance Aggregate
1996− (Expression outer grp commons schemas params from)
1997− (NP (Expression outer grp commons schemas params from))
1998− (WindowFunction outer grp commons schemas params from) where
1996+ (Expression outer commons grp schemas params from)
1997+ (NP (Expression outer commons grp schemas params from))
1998+ (WindowFunction outer commons grp schemas params from) where
19991999 countStar = UnsafeWindowFunction "count(*)"
20002000 count = unsafeWindowFunction1 "count"
20012001 sum_ = unsafeWindowFunction1 "sum"
@@ -2240,26 +2240,26 @@ Sorting
22402240-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
22412241-- determine whether nulls appear before or after non-null values in the sort
22422242-- ordering of a `Null` result column.
2243−data SortExpression outer grp commons schemas params from where
2243+data SortExpression outer commons grp schemas params from where
22442244 Asc
2245− :: Expression outer grp commons schemas params from ('NotNull ty)
2246− -> SortExpression outer grp commons schemas params from
2245+ :: Expression outer commons grp schemas params from ('NotNull ty)
2246+ -> SortExpression outer commons grp schemas params from
22472247 Desc
2248− :: Expression outer grp commons schemas params from ('NotNull ty)
2249− -> SortExpression outer grp commons schemas params from
2248+ :: Expression outer commons grp schemas params from ('NotNull ty)
2249+ -> SortExpression outer commons grp schemas params from
22502250 AscNullsFirst
2251− :: Expression outer grp commons schemas params from ('Null ty)
2252− -> SortExpression outer grp commons schemas params from
2251+ :: Expression outer commons grp schemas params from ('Null ty)
2252+ -> SortExpression outer commons grp schemas params from
22532253 AscNullsLast
2254− :: Expression outer grp commons schemas params from ('Null ty)
2255− -> SortExpression outer grp commons schemas params from
2254+ :: Expression outer commons grp schemas params from ('Null ty)
2255+ -> SortExpression outer commons grp schemas params from
22562256 DescNullsFirst
2257− :: Expression outer grp commons schemas params from ('Null ty)
2258− -> SortExpression outer grp commons schemas params from
2257+ :: Expression outer commons grp schemas params from ('Null ty)
2258+ -> SortExpression outer commons grp schemas params from
22592259 DescNullsLast
2260− :: Expression outer grp commons schemas params from ('Null ty)
2261− -> SortExpression outer grp commons schemas params from
2262−deriving instance Show (SortExpression outer grp commons schemas params from)
2260+ :: Expression outer commons grp schemas params from ('Null ty)
2261+ -> SortExpression outer commons grp schemas params from
2262+deriving instance Show (SortExpression outer commons grp schemas params from)
22632263
22642264{- |
22652265The `orderBy` clause causes the result rows of a `Squeal.PostgreSQL.Query.TableExpression`
@@ -2274,12 +2274,12 @@ using `orderBy` within `Squeal.PostgreSQL.Query.Over`.
22742274-}
22752275class OrderBy expr where
22762276 orderBy
2277− :: [SortExpression outer grp commons schemas params from]
2278− -> expr outer grp commons schemas params from
2279− -> expr outer grp commons schemas params from
2277+ :: [SortExpression outer commons grp schemas params from]
2278+ -> expr outer commons grp schemas params from
2279+ -> expr outer commons grp schemas params from
22802280
22812281-- | Render a `SortExpression`.
2282−instance RenderSQL (SortExpression outer grp commons schemas params from) where
2282+instance RenderSQL (SortExpression outer commons grp schemas params from) where
22832283 renderSQL = \case
22842284 Asc expression -> renderSQL expression <+> "ASC"
22852285 Desc expression -> renderSQL expression <+> "DESC"
@@ -2292,12 +2292,12 @@ instance RenderSQL (SortExpression outer grp commons schemas params from) where
22922292
22932293-- | A `WindowDefinition` is a set of table rows that are somehow related
22942294-- to the current row
2295−data WindowDefinition outer grp commons schemas params from where
2295+data WindowDefinition outer commons grp schemas params from where
22962296 WindowDefinition
22972297 :: SListI bys
2298− => NP (Expression outer grp commons schemas params from) bys
2299− -> [SortExpression outer grp commons schemas params from]
2300− -> WindowDefinition outer grp commons schemas params from
2298+ => NP (Expression outer commons grp schemas params from) bys
2299+ -> [SortExpression outer commons grp schemas params from]
2300+ -> WindowDefinition outer commons grp schemas params from
23012301
23022302instance OrderBy WindowDefinition where
23032303 orderBy sortsR (WindowDefinition parts sortsL)
@@ -2323,8 +2323,8 @@ the same partition as the current row.
23232323-}
23242324partitionBy
23252325 :: SListI bys
2326− => NP (Expression outer grp commons schemas params from) bys
2327− -> WindowDefinition outer grp commons schemas params from
2326+ => NP (Expression outer commons grp schemas params from) bys
2327+ -> WindowDefinition outer commons grp schemas params from
23282328partitionBy bys = WindowDefinition bys []
23292329
23302330{- |
@@ -2339,8 +2339,8 @@ just the current row of the query result.
23392339-}
23402340newtype WindowFunction
23412341 (outer :: FromType)
2342− (grp :: Grouping)
23432342 (commons :: FromType)
2343+ (grp :: Grouping)
23442344 (schemas :: SchemasType)
23452345 (params :: [NullityType])
23462346 (from :: FromType)
@@ -2348,26 +2348,26 @@ newtype WindowFunction
23482348 = UnsafeWindowFunction { renderWindowFunction :: ByteString }
23492349 deriving (GHC.Generic,Show,Eq,Ord,NFData)
23502350
2351−instance RenderSQL (WindowFunction outer grp commons schemas params from ty) where
2351+instance RenderSQL (WindowFunction outer commons grp schemas params from ty) where
23522352 renderSQL = renderWindowFunction
23532353
23542354type WinFun0 x
2355− = forall outer grp commons schemas params from
2356− . WindowFunction outer grp commons schemas params from x
2355+ = forall outer commons grp schemas params from
2356+ . WindowFunction outer commons grp schemas params from x
23572357 -- ^ cannot reference aliases
23582358
23592359type WinFun1 x y
2360− = forall outer grp commons schemas params from
2361− . Expression outer grp commons schemas params from x
2360+ = forall outer commons grp schemas params from
2361+ . Expression outer commons grp schemas params from x
23622362 -- ^ input
2363− -> WindowFunction outer grp commons schemas params from y
2363+ -> WindowFunction outer commons grp schemas params from y
23642364 -- ^ output
23652365
23662366type WinFunHet xs y
2367− = forall outer grp commons schemas params from
2368− . NP (Expression outer grp commons schemas params from) xs
2367+ = forall outer commons grp schemas params from
2368+ . NP (Expression outer commons grp schemas params from) xs
23692369 -- ^ inputs
2370− -> WindowFunction outer grp commons schemas params from y
2370+ -> WindowFunction outer commons grp schemas params from y
23712371 -- ^ output
23722372
23732373unsafeWindowFunction1 :: ByteString -> WinFun1 x y