@@ -41,9 +41,6 @@ module Squeal.PostgreSQL.Expression
4141 , Column (Column)
4242 , renderColumn
4343 , GroupedBy (getGroup1, getGroup2)
44− -- ** Default
45− , def
46− , unDef
4744 -- ** Null
4845 , null_
4946 , unNull
@@ -105,8 +102,6 @@ module Squeal.PostgreSQL.Expression
105102 -- * Tables
106103 , Table (UnsafeTable, renderTable)
107104 , HasTable (getTable)
108− , SchemaHasTable
109− -- * TypeExpression
110105 , TypeExpression (UnsafeTypeExpression, renderTypeExpression)
111106 , PGTyped (pgtype)
112107 , bool
@@ -182,10 +177,10 @@ values from primitive expression using arithmetic, logical,
182177and other operations.
183178-}
184179newtype Expression
185− (tables :: RelationType)
180+ (relation :: RelationsType)
186181 (grouping :: Grouping)
187− (params :: [ColumnType])
188− (ty :: ColumnType)
182+ (params :: [NullityType])
183+ (ty :: NullityType)
189184 = UnsafeExpression { renderExpression :: ByteString }
190185 deriving (GHC.Generic,Show,Eq,Ord,NFData)
191186
@@ -197,8 +192,11 @@ supplied externally to a SQL statement.
197192separately from the SQL command string, in which case `param`s are used to
198193refer to the out-of-line data values.
199194-}
200−class (PGTyped (PGTypeOf ty), KnownNat n)
201− => HasParameter (n :: Nat) params ty | n params -> ty where
195+class (PGTyped (PGTypeOf ty), KnownNat n) => HasParameter
196+ (n :: Nat)
197+ (params :: [NullityType])
198+ (ty :: NullityType)
199+ | n params -> ty where
202200 param :: Expression tables grouping params ty
203201 param = UnsafeExpression $ parenthesized $
204202 "$" <> renderNat (Proxy @n) <+> "::"
@@ -214,7 +212,10 @@ references is unique, in which case the column may be referenced using
214212@-XOverloadedLabels@. Otherwise, combined with a `HasTable` constraint, the
215213qualified column reference operator `!` may be used.
216214-}
217−class KnownSymbol column => HasColumn column columns ty
215+class KnownSymbol column => HasColumn
216+ (column :: Symbol)
217+ (columns :: RelationType)
218+ (ty :: NullityType)
218219 | column columns -> ty where
219220 getColumn
220221 :: HasUnique table tables columns
@@ -222,7 +223,7 @@ class KnownSymbol column => HasColumn column columns ty
222223 -> Expression tables 'Ungrouped params ty
223224 getColumn column = UnsafeExpression $ renderAlias column
224225instance {-# OVERLAPPING #-} KnownSymbol column
225− => HasColumn column ((column ::: optionality ty) ': tys) ( '[] :=> ty)
226+ => HasColumn column (column ::: ty ': tys) ty
226227instance {-# OVERLAPPABLE #-} (KnownSymbol column, HasColumn column table ty)
227228 => HasColumn column (ty' ': table) ty
228229
@@ -240,8 +241,8 @@ instance (HasTable table tables columns, HasColumn column columns ty)
240241-- `Squeel.PostgreSQL.Definition.TableConstraint`s to witness a
241242-- subcolumns relationship.
242243data Column
243− (columns :: ColumnsType)
244− (columnty :: (Symbol,ColumnType))
244+ (columns :: RelationType)
245+ (columnty :: (Symbol,NullityType))
245246 where
246247 Column
247248 :: HasColumn column columns ty
@@ -296,27 +297,11 @@ instance
296297 ) => IsTableColumn table column
297298 (Expression tables ('Grouped bys) params ty) where (!) = getGroup2
298299
299−-- | >>> renderExpression def
300−-- "DEFAULT"
301−def
302− :: 'Default `In` constraints
303− => Expression '[] 'Ungrouped params (constraints :=> nullity ty)
304−def = UnsafeExpression "DEFAULT"
305−
306−-- | >>> renderExpression $ unDef false
307−-- "FALSE"
308−unDef
309− :: 'Default `In` constraints
310− => Expression '[] 'Ungrouped params ( '[] :=> nullity ty)
311− -- ^ not @DEFAULT@
312− -> Expression '[] 'Ungrouped params (constraints :=> nullity ty)
313−unDef = UnsafeExpression . renderExpression
314−
315300-- | analagous to `Nothing`
316301--
317302-- >>> renderExpression $ null_
318303-- "NULL"
319−null_ :: Expression tables grouping params (constraints :=> 'Null ty)
304+null_ :: Expression tables grouping params ('Null ty)
320305null_ = UnsafeExpression "NULL"
321306
322307-- | analagous to `Just`
@@ -324,9 +309,9 @@ null_ = UnsafeExpression "NULL"
324309-- >>> renderExpression $ unNull true
325310-- "TRUE"
326311unNull
327− :: Expression tables grouping params (constraints :=> 'NotNull ty)
312+ :: Expression tables grouping params ('NotNull ty)
328313 -- ^ not @NULL@
329− -> Expression tables grouping params (constraints :=> 'Null ty)
314+ -> Expression tables grouping params ('Null ty)
330315unNull = UnsafeExpression . renderExpression
331316
332317-- | return the leftmost value which is not NULL
@@ -334,11 +319,11 @@ unNull = UnsafeExpression . renderExpression
334319-- >>> renderExpression $ coalesce [null_, unNull true] false
335320-- "COALESCE(NULL, TRUE, FALSE)"
336321coalesce
337− :: [Expression tables grouping params ( '[] :=> 'Null ty)]
322+ :: [Expression tables grouping params ('Null ty)]
338323 -- ^ @NULL@s may be present
339− -> Expression tables grouping params ( '[] :=> 'NotNull ty)
324+ -> Expression tables grouping params ('NotNull ty)
340325 -- ^ @NULL@ is absent
341− -> Expression tables grouping params ( '[] :=> 'NotNull ty)
326+ -> Expression tables grouping params ('NotNull ty)
342327coalesce nullxs notNullx = UnsafeExpression $
343328 "COALESCE" <> parenthesized (commaSeparated
344329 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
@@ -348,16 +333,16 @@ coalesce nullxs notNullx = UnsafeExpression $
348333-- >>> renderExpression $ fromNull true null_
349334-- "COALESCE(NULL, TRUE)"
350335fromNull
351− :: Expression tables grouping params ( '[] :=> 'NotNull ty)
336+ :: Expression tables grouping params ('NotNull ty)
352337 -- ^ what to convert @NULL@ to
353− -> Expression tables grouping params ( '[] :=> 'Null ty)
354− -> Expression tables grouping params ( '[] :=> 'NotNull ty)
338+ -> Expression tables grouping params ('Null ty)
339+ -> Expression tables grouping params ('NotNull ty)
355340fromNull notNullx nullx = coalesce [nullx] notNullx
356341
357342-- | >>> renderExpression $ null_ & isNull
358343-- "NULL IS NULL"
359344isNull
360− :: Expression tables grouping params ( '[] :=> 'Null ty)
345+ :: Expression tables grouping params ('Null ty)
361346 -- ^ possibly @NULL@
362347 -> Condition tables grouping params
363348isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
@@ -365,7 +350,7 @@ isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
365350-- | >>> renderExpression $ null_ & isn'tNull
366351-- "NULL IS NOT NULL"
367352isn'tNull
368− :: Expression tables grouping params ( '[] :=> 'Null ty)
353+ :: Expression tables grouping params ('Null ty)
369354 -- ^ possibly @NULL@
370355 -> Condition tables grouping params
371356isn'tNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
@@ -375,13 +360,13 @@ isn'tNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
375360-- >>> renderExpression $ matchNull true not_ null_
376361-- "CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END"
377362matchNull
378− :: Expression tables grouping params ( '[] :=> nullty)
363+ :: Expression tables grouping params (nullty)
379364 -- ^ what to convert @NULL@ to
380− -> ( Expression tables grouping params ( '[] :=> 'NotNull ty)
381− -> Expression tables grouping params ( '[] :=> nullty) )
365+ -> ( Expression tables grouping params ('NotNull ty)
366+ -> Expression tables grouping params (nullty) )
382367 -- ^ function to perform when @NULL@ is absent
383− -> Expression tables grouping params ( '[] :=> 'Null ty)
384− -> Expression tables grouping params ( '[] :=> nullty)
368+ -> Expression tables grouping params ('Null ty)
369+ -> Expression tables grouping params (nullty)
385370matchNull y f x = ifThenElse (isNull x) y
386371 (f (UnsafeExpression (renderExpression x)))
387372
@@ -392,33 +377,33 @@ matchNull y f x = ifThenElse (isNull x) y
392377-- >>> renderExpression @_ @_ @'[_] $ fromNull false (nullIf false (param @1))
393378-- "COALESCE(NULL IF (FALSE, ($1 :: bool)), FALSE)"
394379nullIf
395− :: Expression tables grouping params ( '[] :=> 'NotNull ty)
380+ :: Expression tables grouping params ('NotNull ty)
396381 -- ^ @NULL@ is absent
397− -> Expression tables grouping params ( '[] :=> 'NotNull ty)
382+ -> Expression tables grouping params ('NotNull ty)
398383 -- ^ @NULL@ is absent
399− -> Expression tables grouping params ( '[] :=> 'Null ty)
384+ -> Expression tables grouping params ('Null ty)
400385nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
401386 (renderExpression x <> ", " <> renderExpression y)
402387
403388-- | >>> renderExpression @_ @_ @'[_] $ greatest currentTimestamp [param @1]
404389-- "GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))"
405390greatest
406− :: Expression tables grouping params ( '[] :=> nullty)
391+ :: Expression tables grouping params (nullty)
407392 -- ^ needs at least 1 argument
408− -> [Expression tables grouping params ( '[] :=> nullty)]
393+ -> [Expression tables grouping params (nullty)]
409394 -- ^ or more
410− -> Expression tables grouping params ( '[] :=> nullty)
395+ -> Expression tables grouping params (nullty)
411396greatest x xs = UnsafeExpression $ "GREATEST("
412397 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
413398
414399-- | >>> renderExpression $ least currentTimestamp [null_]
415400-- "LEAST(CURRENT_TIMESTAMP, NULL)"
416401least
417− :: Expression tables grouping params ( '[] :=> nullty)
402+ :: Expression tables grouping params (nullty)
418403 -- ^ needs at least 1 argument
419− -> [Expression tables grouping params ( '[] :=> nullty)]
404+ -> [Expression tables grouping params (nullty)]
420405 -- ^ or more
421− -> Expression tables grouping params ( '[] :=> nullty)
406+ -> Expression tables grouping params (nullty)
422407least x xs = UnsafeExpression $ "LEAST("
423408 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
424409
@@ -427,9 +412,9 @@ least x xs = UnsafeExpression $ "LEAST("
427412unsafeBinaryOp
428413 :: ByteString
429414 -- ^ operator
430− -> Expression tables grouping params ( '[] :=> ty0)
431− -> Expression tables grouping params ( '[] :=> ty1)
432− -> Expression tables grouping params ( '[] :=> ty2)
415+ -> Expression tables grouping params (ty0)
416+ -> Expression tables grouping params (ty1)
417+ -> Expression tables grouping params (ty2)
433418unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
434419 renderExpression x <+> op <+> renderExpression y
435420
@@ -438,8 +423,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
438423unsafeUnaryOp
439424 :: ByteString
440425 -- ^ operator
441− -> Expression tables grouping params ( '[] :=> ty0)
442− -> Expression tables grouping params ( '[] :=> ty1)
426+ -> Expression tables grouping params (ty0)
427+ -> Expression tables grouping params (ty1)
443428unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
444429 op <+> renderExpression x
445430
@@ -448,13 +433,13 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
448433unsafeFunction
449434 :: ByteString
450435 -- ^ function
451− -> Expression tables grouping params ( '[] :=> xty)
452− -> Expression tables grouping params ( '[] :=> yty)
436+ -> Expression tables grouping params (xty)
437+ -> Expression tables grouping params (yty)
453438unsafeFunction fun x = UnsafeExpression $
454439 fun <> parenthesized (renderExpression x)
455440
456441instance PGNum ty
457− => Num (Expression tables grouping params ( '[] :=> nullity ty)) where
442+ => Num (Expression tables grouping params (nullity ty)) where
458443 (+) = unsafeBinaryOp "+"
459444 (-) = unsafeBinaryOp "-"
460445 (*) = unsafeBinaryOp "*"
@@ -466,12 +451,12 @@ instance PGNum ty
466451 . show
467452
468453instance (PGNum ty, PGFloating ty) => Fractional
469− (Expression tables grouping params ( '[] :=> nullity ty)) where
454+ (Expression tables grouping params (nullity ty)) where
470455 (/) = unsafeBinaryOp "/"
471456 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
472457
473458instance (PGNum ty, PGFloating ty) => Floating
474− (Expression tables grouping params ( '[] :=> nullity ty)) where
459+ (Expression tables grouping params (nullity ty)) where
475460 pi = UnsafeExpression "pi()"
476461 exp = unsafeFunction "exp"
477462 log = unsafeFunction "ln"
@@ -496,11 +481,11 @@ instance (PGNum ty, PGFloating ty) => Floating
496481-- "atan2(pi(), 2)"
497482atan2_
498483 :: PGFloating float
499− => Expression tables grouping params ( '[] :=> nullity float)
484+ => Expression tables grouping params (nullity float)
500485 -- ^ numerator
501− -> Expression tables grouping params ( '[] :=> nullity float)
486+ -> Expression tables grouping params (nullity float)
502487 -- ^ denominator
503− -> Expression tables grouping params ( '[] :=> nullity float)
488+ -> Expression tables grouping params (nullity float)
504489atan2_ y x = UnsafeExpression $
505490 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
506491
@@ -511,11 +496,11 @@ atan2_ y x = UnsafeExpression $
511496-- | >>> renderExpression $ true & cast int4
512497-- "(TRUE :: int4)"
513498cast
514− :: TypeExpression ( '[] :=> 'Null ty1)
499+ :: TypeExpression ('[] :=> 'Null ty1)
515500 -- ^ type to cast as
516− -> Expression tables grouping params ( '[] :=> nullity ty0)
501+ -> Expression tables grouping params (nullity ty0)
517502 -- ^ value to convert
518− -> Expression tables grouping params ( '[] :=> nullity ty1)
503+ -> Expression tables grouping params (nullity ty1)
519504cast ty x = UnsafeExpression $ parenthesized $
520505 renderExpression x <+> "::" <+> renderTypeExpression ty
521506
@@ -525,11 +510,11 @@ cast ty x = UnsafeExpression $ parenthesized $
525510-- "(5 / 2)"
526511quot_
527512 :: PGIntegral int
528− => Expression tables grouping params ( '[] :=> nullity int)
513+ => Expression tables grouping params (nullity int)
529514 -- ^ numerator
530− -> Expression tables grouping params ( '[] :=> nullity int)
515+ -> Expression tables grouping params (nullity int)
531516 -- ^ denominator
532− -> Expression tables grouping params ( '[] :=> nullity int)
517+ -> Expression tables grouping params (nullity int)
533518quot_ = unsafeBinaryOp "/"
534519
535520-- | remainder upon integer division
@@ -538,38 +523,38 @@ quot_ = unsafeBinaryOp "/"
538523-- "(5 % 2)"
539524rem_
540525 :: PGIntegral int
541− => Expression tables grouping params ( '[] :=> nullity int)
526+ => Expression tables grouping params (nullity int)
542527 -- ^ numerator
543− -> Expression tables grouping params ( '[] :=> nullity int)
528+ -> Expression tables grouping params (nullity int)
544529 -- ^ denominator
545− -> Expression tables grouping params ( '[] :=> nullity int)
530+ -> Expression tables grouping params (nullity int)
546531rem_ = unsafeBinaryOp "%"
547532
548533-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGfloat4)) $ trunc pi
549534-- "trunc(pi())"
550535trunc
551536 :: PGFloating frac
552− => Expression tables grouping params ( '[] :=> nullity frac)
537+ => Expression tables grouping params (nullity frac)
553538 -- ^ fractional number
554− -> Expression tables grouping params ( '[] :=> nullity frac)
539+ -> Expression tables grouping params (nullity frac)
555540trunc = unsafeFunction "trunc"
556541
557542-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGfloat4)) $ round_ pi
558543-- "round(pi())"
559544round_
560545 :: PGFloating frac
561− => Expression tables grouping params ( '[] :=> nullity frac)
546+ => Expression tables grouping params (nullity frac)
562547 -- ^ fractional number
563− -> Expression tables grouping params ( '[] :=> nullity frac)
548+ -> Expression tables grouping params (nullity frac)
564549round_ = unsafeFunction "round"
565550
566551-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGfloat4)) $ ceiling_ pi
567552-- "ceiling(pi())"
568553ceiling_
569554 :: PGFloating frac
570− => Expression tables grouping params ( '[] :=> nullity frac)
555+ => Expression tables grouping params (nullity frac)
571556 -- ^ fractional number
572− -> Expression tables grouping params ( '[] :=> nullity frac)
557+ -> Expression tables grouping params (nullity frac)
573558ceiling_ = unsafeFunction "ceiling"
574559
575560-- | A `Condition` is a boolean valued `Expression`. While SQL allows
@@ -577,7 +562,7 @@ ceiling_ = unsafeFunction "ceiling"
577562-- forcing one to handle the case of @NULL@ explicitly to produce
578563-- a `Condition`.
579564type Condition tables grouping params =
580− Expression tables grouping params ( '[] :=> 'NotNull 'PGbool)
565+ Expression tables grouping params ('NotNull 'PGbool)
581566
582567-- | >>> renderExpression true
583568-- "TRUE"
@@ -616,10 +601,10 @@ not_ = unsafeUnaryOp "NOT"
616601-- "CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END"
617602caseWhenThenElse
618603 :: [ ( Condition tables grouping params
619− , Expression tables grouping params ( '[] :=> ty)
604+ , Expression tables grouping params (ty)
620605 ) ]
621− -> Expression tables grouping params ( '[] :=> ty)
622− -> Expression tables grouping params ( '[] :=> ty)
606+ -> Expression tables grouping params (ty)
607+ -> Expression tables grouping params (ty)
623608caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
624609 [ "CASE"
625610 , mconcat
@@ -637,9 +622,9 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
637622-- "CASE WHEN TRUE THEN 1 ELSE 0 END"
638623ifThenElse
639624 :: Condition tables grouping params
640− -> Expression tables grouping params ( '[] :=> ty)
641− -> Expression tables grouping params ( '[] :=> ty)
642− -> Expression tables grouping params ( '[] :=> ty)
625+ -> Expression tables grouping params (ty)
626+ -> Expression tables grouping params (ty)
627+ -> Expression tables grouping params (ty)
643628ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
644629
645630-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -648,85 +633,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
648633-- >>> renderExpression $ unNull true .== null_
649634-- "(TRUE = NULL)"
650635(.==)
651− :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
652− -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
653− -> Expression tables grouping params '( '[], (nullity 'PGbool))
636+ :: Expression tables grouping params (nullity ty) -- ^ lhs
637+ -> Expression tables grouping params (nullity ty) -- ^ rhs
638+ -> Expression tables grouping params (nullity 'PGbool)
654639(.==) = unsafeBinaryOp "="
655640infix 4 .==
656641
657642-- | >>> renderExpression $ unNull true ./= null_
658643-- "(TRUE <> NULL)"
659644(./=)
660− :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
661− -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
662− -> Expression tables grouping params '( '[], (nullity 'PGbool))
645+ :: Expression tables grouping params (nullity ty) -- ^ lhs
646+ -> Expression tables grouping params (nullity ty) -- ^ rhs
647+ -> Expression tables grouping params (nullity 'PGbool)
663648(./=) = unsafeBinaryOp "<>"
664649infix 4 ./=
665650
666651-- | >>> renderExpression $ unNull true .>= null_
667652-- "(TRUE >= NULL)"
668653(.>=)
669− :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
670− -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
671− -> Expression tables grouping params '( '[], (nullity 'PGbool))
654+ :: Expression tables grouping params (nullity ty) -- ^ lhs
655+ -> Expression tables grouping params (nullity ty) -- ^ rhs
656+ -> Expression tables grouping params (nullity 'PGbool)
672657(.>=) = unsafeBinaryOp ">="
673658infix 4 .>=
674659
675660-- | >>> renderExpression $ unNull true .< null_
676661-- "(TRUE < NULL)"
677662(.<)
678− :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
679− -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
680− -> Expression tables grouping params '( '[], (nullity 'PGbool))
663+ :: Expression tables grouping params (nullity ty) -- ^ lhs
664+ -> Expression tables grouping params (nullity ty) -- ^ rhs
665+ -> Expression tables grouping params (nullity 'PGbool)
681666(.<) = unsafeBinaryOp "<"
682667infix 4 .<
683668
684669-- | >>> renderExpression $ unNull true .<= null_
685670-- "(TRUE <= NULL)"
686671(.<=)
687− :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
688− -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
689− -> Expression tables grouping params '( '[], (nullity 'PGbool))
672+ :: Expression tables grouping params (nullity ty) -- ^ lhs
673+ -> Expression tables grouping params (nullity ty) -- ^ rhs
674+ -> Expression tables grouping params (nullity 'PGbool)
690675(.<=) = unsafeBinaryOp "<="
691676infix 4 .<=
692677
693678-- | >>> renderExpression $ unNull true .> null_
694679-- "(TRUE > NULL)"
695680(.>)
696− :: Expression tables grouping params ( '[] :=> nullity ty) -- ^ lhs
697− -> Expression tables grouping params ( '[] :=> nullity ty) -- ^ rhs
698− -> Expression tables grouping params '( '[], (nullity 'PGbool))
681+ :: Expression tables grouping params (nullity ty) -- ^ lhs
682+ -> Expression tables grouping params (nullity ty) -- ^ rhs
683+ -> Expression tables grouping params (nullity 'PGbool)
699684(.>) = unsafeBinaryOp ">"
700685infix 4 .>
701686
702687-- | >>> renderExpression $ currentDate
703688-- "CURRENT_DATE"
704689currentDate
705− :: Expression tables grouping params '( '[], (nullity 'PGdate))
690+ :: Expression tables grouping params (nullity 'PGdate)
706691currentDate = UnsafeExpression "CURRENT_DATE"
707692
708693-- | >>> renderExpression $ currentTime
709694-- "CURRENT_TIME"
710695currentTime
711− :: Expression tables grouping params '( '[], (nullity 'PGtimetz))
696+ :: Expression tables grouping params (nullity 'PGtimetz)
712697currentTime = UnsafeExpression "CURRENT_TIME"
713698
714699-- | >>> renderExpression $ currentTimestamp
715700-- "CURRENT_TIMESTAMP"
716701currentTimestamp
717− :: Expression tables grouping params '( '[], (nullity 'PGtimestamptz))
702+ :: Expression tables grouping params (nullity 'PGtimestamptz)
718703currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
719704
720705-- | >>> renderExpression $ localTime
721706-- "LOCALTIME"
722707localTime
723− :: Expression tables grouping params '( '[], (nullity 'PGtime))
708+ :: Expression tables grouping params (nullity 'PGtime)
724709localTime = UnsafeExpression "LOCALTIME"
725710
726711-- | >>> renderExpression $ localTimestamp
727712-- "LOCALTIMESTAMP"
728713localTimestamp
729− :: Expression tables grouping params '( '[], (nullity 'PGtimestamp))
714+ :: Expression tables grouping params (nullity 'PGtimestamp)
730715localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
731716
732717{-----------------------------------------
@@ -734,7 +719,7 @@ text
734719-----------------------------------------}
735720
736721instance IsString
737− (Expression tables grouping params '( '[], (nullity 'PGtext))) where
722+ (Expression tables grouping params (nullity 'PGtext)) where
738723 fromString str = UnsafeExpression $
739724 "E\'" <> fromString (escape =<< str) <> "\'"
740725 where
@@ -750,32 +735,32 @@ instance IsString
750735 c -> [c]
751736
752737instance Monoid
753− (Expression tables grouping params '( '[], (nullity 'PGtext))) where
738+ (Expression tables grouping params (nullity 'PGtext)) where
754739 mempty = fromString ""
755740 mappend = unsafeBinaryOp "||"
756741
757742-- | >>> renderExpression $ lower "ARRRGGG"
758743-- "lower(E'ARRRGGG')"
759744lower
760− :: Expression tables grouping params '( '[], (nullity 'PGtext))
745+ :: Expression tables grouping params (nullity 'PGtext)
761746 -- ^ string to lower case
762− -> Expression tables grouping params '( '[], (nullity 'PGtext))
747+ -> Expression tables grouping params (nullity 'PGtext)
763748lower = unsafeFunction "lower"
764749
765750-- | >>> renderExpression $ upper "eeee"
766751-- "upper(E'eeee')"
767752upper
768− :: Expression tables grouping params '( '[], (nullity 'PGtext))
753+ :: Expression tables grouping params (nullity 'PGtext)
769754 -- ^ string to upper case
770− -> Expression tables grouping params '( '[], (nullity 'PGtext))
755+ -> Expression tables grouping params (nullity 'PGtext)
771756upper = unsafeFunction "upper"
772757
773758-- | >>> renderExpression $ charLength "four"
774759-- "char_length(E'four')"
775760charLength
776− :: Expression tables grouping params '( '[], (nullity 'PGtext))
761+ :: Expression tables grouping params (nullity 'PGtext)
777762 -- ^ string to measure
778− -> Expression tables grouping params '( '[], (nullity 'PGint4))
763+ -> Expression tables grouping params (nullity 'PGint4)
779764charLength = unsafeFunction "char_length"
780765
781766-- | The `like` expression returns true if the @string@ matches
@@ -788,11 +773,11 @@ charLength = unsafeFunction "char_length"
788773-- >>> renderExpression $ "abc" `like` "a%"
789774-- "(E'abc' LIKE E'a%')"
790775like
791− :: Expression tables grouping params '( '[], (nullity 'PGtext))
776+ :: Expression tables grouping params (nullity 'PGtext)
792777 -- ^ string
793− -> Expression tables grouping params '( '[], (nullity 'PGtext))
778+ -> Expression tables grouping params (nullity 'PGtext)
794779 -- ^ pattern
795− -> Expression tables grouping params '( '[], (nullity 'PGbool))
780+ -> Expression tables grouping params (nullity 'PGbool)
796781like = unsafeBinaryOp "LIKE"
797782
798783{-----------------------------------------
@@ -802,16 +787,16 @@ aggregation
802787-- | escape hatch to define aggregate functions
803788unsafeAggregate
804789 :: ByteString -- ^ aggregate function
805− -> Expression tables 'Ungrouped params ( '[] :=> xty)
806− -> Expression tables ('Grouped bys) params ( '[] :=> yty)
790+ -> Expression tables 'Ungrouped params (xty)
791+ -> Expression tables ('Grouped bys) params (yty)
807792unsafeAggregate fun x = UnsafeExpression $ mconcat
808793 [fun, "(", renderExpression x, ")"]
809794
810795-- | escape hatch to define aggregate functions over distinct values
811796unsafeAggregateDistinct
812797 :: ByteString -- ^ aggregate function
813− -> Expression tables 'Ungrouped params ( '[] :=> xty)
814− -> Expression tables ('Grouped bys) params ( '[] :=> yty)
798+ -> Expression tables 'Ungrouped params (xty)
799+ -> Expression tables ('Grouped bys) params (yty)
815800unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
816801 [fun, "(DISTINCT ", renderExpression x, ")"]
817802
@@ -819,27 +804,27 @@ unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
819804-- "sum(col)"
820805sum_
821806 :: PGNum ty
822− => Expression tables 'Ungrouped params ( '[] :=> nullity ty)
807+ => Expression tables 'Ungrouped params (nullity ty)
823808 -- ^ what to sum
824− -> Expression tables ('Grouped bys) params ( '[] :=> nullity ty)
809+ -> Expression tables ('Grouped bys) params (nullity ty)
825810sum_ = unsafeAggregate "sum"
826811
827812-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGnumeric)]] $ sumDistinct #col
828813-- "sum(DISTINCT col)"
829814sumDistinct
830815 :: PGNum ty
831− => Expression tables 'Ungrouped params ( '[] :=> nullity ty)
816+ => Expression tables 'Ungrouped params (nullity ty)
832817 -- ^ what to sum
833− -> Expression tables ('Grouped bys) params ( '[] :=> nullity ty)
818+ -> Expression tables ('Grouped bys) params (nullity ty)
834819sumDistinct = unsafeAggregateDistinct "sum"
835820
836821-- | A constraint for `PGType`s that you can take averages of and the resulting
837822-- `PGType`.
838823class PGAvg ty avg | ty -> avg where
839824 avg, avgDistinct
840− :: Expression tables 'Ungrouped params ( '[] :=> nullity ty)
825+ :: Expression tables 'Ungrouped params (nullity ty)
841826 -- ^ what to average
842− -> Expression tables ('Grouped bys) params '( '[], (nullity avg))
827+ -> Expression tables ('Grouped bys) params (nullity avg)
843828 avg = unsafeAggregate "avg"
844829 avgDistinct = unsafeAggregateDistinct "avg"
845830instance PGAvg 'PGint2 'PGnumeric
@@ -854,68 +839,68 @@ instance PGAvg 'PGinterval 'PGinterval
854839-- "bit_and(col)"
855840bitAnd
856841 :: PGIntegral int
857− => Expression tables 'Ungrouped params ( '[] :=> nullity int)
842+ => Expression tables 'Ungrouped params (nullity int)
858843 -- ^ what to aggregate
859− -> Expression tables ('Grouped bys) params ( '[] :=> nullity int)
844+ -> Expression tables ('Grouped bys) params (nullity int)
860845bitAnd = unsafeAggregate "bit_and"
861846
862847-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGint4)]] $ bitOr #col
863848-- "bit_or(col)"
864849bitOr
865850 :: PGIntegral int
866− => Expression tables 'Ungrouped params ( '[] :=> nullity int)
851+ => Expression tables 'Ungrouped params (nullity int)
867852 -- ^ what to aggregate
868− -> Expression tables ('Grouped bys) params ( '[] :=> nullity int)
853+ -> Expression tables ('Grouped bys) params (nullity int)
869854bitOr = unsafeAggregate "bit_or"
870855
871856-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGint4)]] $ bitAndDistinct #col
872857-- "bit_and(DISTINCT col)"
873858bitAndDistinct
874859 :: PGIntegral int
875− => Expression tables 'Ungrouped params ( '[] :=> nullity int)
860+ => Expression tables 'Ungrouped params (nullity int)
876861 -- ^ what to aggregate
877− -> Expression tables ('Grouped bys) params ( '[] :=> nullity int)
862+ -> Expression tables ('Grouped bys) params (nullity int)
878863bitAndDistinct = unsafeAggregateDistinct "bit_and"
879864
880865-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGint4)]] $ bitOrDistinct #col
881866-- "bit_or(DISTINCT col)"
882867bitOrDistinct
883868 :: PGIntegral int
884− => Expression tables 'Ungrouped params ( '[] :=> nullity int)
869+ => Expression tables 'Ungrouped params (nullity int)
885870 -- ^ what to aggregate
886− -> Expression tables ('Grouped bys) params ( '[] :=> nullity int)
871+ -> Expression tables ('Grouped bys) params (nullity int)
887872bitOrDistinct = unsafeAggregateDistinct "bit_or"
888873
889874-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ boolAnd #col
890875-- "bool_and(col)"
891876boolAnd
892− :: Expression tables 'Ungrouped params '( '[], (nullity 'PGbool))
877+ :: Expression tables 'Ungrouped params (nullity 'PGbool)
893878 -- ^ what to aggregate
894− -> Expression tables ('Grouped bys) params '( '[], (nullity 'PGbool))
879+ -> Expression tables ('Grouped bys) params (nullity 'PGbool)
895880boolAnd = unsafeAggregate "bool_and"
896881
897882-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ boolOr #col
898883-- "bool_or(col)"
899884boolOr
900− :: Expression tables 'Ungrouped params '( '[], (nullity 'PGbool))
885+ :: Expression tables 'Ungrouped params (nullity 'PGbool)
901886 -- ^ what to aggregate
902− -> Expression tables ('Grouped bys) params '( '[], (nullity 'PGbool))
887+ -> Expression tables ('Grouped bys) params (nullity 'PGbool)
903888boolOr = unsafeAggregate "bool_or"
904889
905890-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ boolAndDistinct #col
906891-- "bool_and(DISTINCT col)"
907892boolAndDistinct
908− :: Expression tables 'Ungrouped params '( '[], (nullity 'PGbool))
893+ :: Expression tables 'Ungrouped params (nullity 'PGbool)
909894 -- ^ what to aggregate
910− -> Expression tables ('Grouped bys) params '( '[], (nullity 'PGbool))
895+ -> Expression tables ('Grouped bys) params (nullity 'PGbool)
911896boolAndDistinct = unsafeAggregateDistinct "bool_and"
912897
913898-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ boolOrDistinct #col
914899-- "bool_or(DISTINCT col)"
915900boolOrDistinct
916− :: Expression tables 'Ungrouped params '( '[], (nullity 'PGbool))
901+ :: Expression tables 'Ungrouped params (nullity 'PGbool)
917902 -- ^ what to aggregate
918− -> Expression tables ('Grouped bys) params '( '[], (nullity 'PGbool))
903+ -> Expression tables ('Grouped bys) params (nullity 'PGbool)
919904boolOrDistinct = unsafeAggregateDistinct "bool_or"
920905
921906-- | A special aggregation that does not require an input
@@ -923,23 +908,23 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
923908-- >>> renderExpression countStar
924909-- "count(*)"
925910countStar
926− :: Expression tables ('Grouped bys) params '( '[], ('NotNull 'PGint8))
911+ :: Expression tables ('Grouped bys) params ('NotNull 'PGint8)
927912countStar = UnsafeExpression $ "count(*)"
928913
929914-- | >>> renderExpression @'[_ ::: '["col" ::: 'Optional _]] $ count #col
930915-- "count(col)"
931916count
932− :: Expression tables 'Ungrouped params ( '[] :=> ty)
917+ :: Expression tables 'Ungrouped params (ty)
933918 -- ^ what to count
934− -> Expression tables ('Grouped bys) params '( '[], ('NotNull 'PGint8))
919+ -> Expression tables ('Grouped bys) params ('NotNull 'PGint8)
935920count = unsafeAggregate "count"
936921
937922-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required _]] $ countDistinct #col
938923-- "count(DISTINCT col)"
939924countDistinct
940− :: Expression tables 'Ungrouped params ( '[] :=> ty)
925+ :: Expression tables 'Ungrouped params (ty)
941926 -- ^ what to count
942− -> Expression tables ('Grouped bys) params '( '[], ('NotNull 'PGint8))
927+ -> Expression tables ('Grouped bys) params ('NotNull 'PGint8)
943928countDistinct = unsafeAggregateDistinct "count"
944929
945930-- | synonym for `boolAnd`
@@ -947,9 +932,9 @@ countDistinct = unsafeAggregateDistinct "count"
947932-- >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ every #col
948933-- "every(col)"
949934every
950− :: Expression tables 'Ungrouped params '( '[], (nullity 'PGbool))
935+ :: Expression tables 'Ungrouped params (nullity 'PGbool)
951936 -- ^ what to aggregate
952− -> Expression tables ('Grouped bys) params '( '[], (nullity 'PGbool))
937+ -> Expression tables ('Grouped bys) params (nullity 'PGbool)
953938every = unsafeAggregate "every"
954939
955940-- | synonym for `boolAndDistinct`
@@ -957,16 +942,16 @@ every = unsafeAggregate "every"
957942-- >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ everyDistinct #col
958943-- "every(DISTINCT col)"
959944everyDistinct
960− :: Expression tables 'Ungrouped params '( '[], (nullity 'PGbool))
945+ :: Expression tables 'Ungrouped params (nullity 'PGbool)
961946 -- ^ what to aggregate
962− -> Expression tables ('Grouped bys) params '( '[], (nullity 'PGbool))
947+ -> Expression tables ('Grouped bys) params (nullity 'PGbool)
963948everyDistinct = unsafeAggregateDistinct "every"
964949
965950-- | minimum and maximum aggregation
966951max_, min_, maxDistinct, minDistinct
967− :: Expression tables 'Ungrouped params ( '[] :=> nullity ty)
952+ :: Expression tables 'Ungrouped params (nullity ty)
968953 -- ^ what to aggregate
969− -> Expression tables ('Grouped bys) params ( '[] :=> nullity ty)
954+ -> Expression tables ('Grouped bys) params (nullity ty)
970955max_ = unsafeAggregate "max"
971956min_ = unsafeAggregate "min"
972957maxDistinct = unsafeAggregateDistinct "max"
@@ -979,13 +964,16 @@ tables
979964-- | A `Table` from a schema without its alias with an `IsLabel` instance
980965-- to call a table reference by its alias.
981966newtype Table
982− (schema :: RelationType)
983− (columns :: ColumnsType)
967+ (schema :: RelationsType)
968+ (columns :: RelationType)
984969 = UnsafeTable { renderTable :: ByteString }
985970 deriving (GHC.Generic,Show,Eq,Ord,NFData)
986971
987972-- | A `HasTable` constraint indicates a table reference.
988−class KnownSymbol table => HasTable table tables columns
973+class KnownSymbol table => HasTable
974+ (table :: Symbol)
975+ (tables :: RelationsType)
976+ (columns :: RelationType)
989977 | table tables -> columns where
990978 getTable :: Alias table -> Table tables columns
991979 getTable table = UnsafeTable $ renderAlias table
@@ -999,14 +987,6 @@ instance HasTable table schema columns
999987 => IsLabel table (Table schema columns) where
1000988 fromLabel = getTable (Alias @table)
1001989
1002−type family SchemaHasTable
1003− (table :: Symbol)
1004− (schema :: SchemaType)
1005− (columns :: ColumnsType)
1006− where
1007− SchemaHasTable table schema columns =
1008− HasTable table (UnconstrainOver schema) columns
1009−
1010990{-----------------------------------------
1011991type expressions
1012992-----------------------------------------}
@@ -1017,30 +997,30 @@ newtype TypeExpression (ty :: ColumnType)
1017997 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1018998
1019999-- | logical Boolean (true/false)
1020−bool :: TypeExpression ( '[] :=> 'Null 'PGbool)
1000+bool :: TypeExpression ('[] :=> 'Null 'PGbool)
10211001bool = UnsafeTypeExpression "bool"
10221002-- | signed two-byte integer
1023−int2, smallint :: TypeExpression ( '[] :=> 'Null 'PGint2)
1003+int2, smallint :: TypeExpression ('[] :=> 'Null 'PGint2)
10241004int2 = UnsafeTypeExpression "int2"
10251005smallint = UnsafeTypeExpression "smallint"
10261006-- | signed four-byte integer
1027−int4, int, integer :: TypeExpression ( '[] :=> 'Null 'PGint4)
1007+int4, int, integer :: TypeExpression ('[] :=> 'Null 'PGint4)
10281008int4 = UnsafeTypeExpression "int4"
10291009int = UnsafeTypeExpression "int"
10301010integer = UnsafeTypeExpression "integer"
10311011-- | signed eight-byte integer
1032−int8, bigint :: TypeExpression ( '[] :=> 'Null 'PGint8)
1012+int8, bigint :: TypeExpression ('[] :=> 'Null 'PGint8)
10331013int8 = UnsafeTypeExpression "int8"
10341014bigint = UnsafeTypeExpression "bigint"
10351015-- | arbitrary precision numeric type
1036−numeric :: TypeExpression ( '[] :=> 'Null 'PGnumeric)
1016+numeric :: TypeExpression ('[] :=> 'Null 'PGnumeric)
10371017numeric = UnsafeTypeExpression "numeric"
10381018-- | single precision floating-point number (4 bytes)
1039−float4, real :: TypeExpression ( '[] :=> 'Null 'PGfloat4)
1019+float4, real :: TypeExpression ('[] :=> 'Null 'PGfloat4)
10401020float4 = UnsafeTypeExpression "float4"
10411021real = UnsafeTypeExpression "real"
10421022-- | double precision floating-point number (8 bytes)
1043−float8, doublePrecision :: TypeExpression ( '[] :=> 'Null 'PGfloat8)
1023+float8, doublePrecision :: TypeExpression ('[] :=> 'Null 'PGfloat8)
10441024float8 = UnsafeTypeExpression "float8"
10451025doublePrecision = UnsafeTypeExpression "double precision"
10461026-- | not a true type, but merely a notational convenience for creating
@@ -1062,55 +1042,55 @@ serial8, bigserial
10621042serial8 = UnsafeTypeExpression "serial8"
10631043bigserial = UnsafeTypeExpression "bigserial"
10641044-- | variable-length character string
1065−text :: TypeExpression '( '[], ('Null 'PGtext))
1045+text :: TypeExpression ('[] :=> 'Null 'PGtext)
10661046text = UnsafeTypeExpression "text"
10671047-- | fixed-length character string
10681048char, character
10691049 :: (KnownNat n, 1 <= n)
10701050 => proxy n
1071− -> TypeExpression '( '[], ('Null ('PGchar n)))
1051+ -> TypeExpression ('[] :=> 'Null ('PGchar n))
10721052char p = UnsafeTypeExpression $ "char(" <> renderNat p <> ")"
10731053character p = UnsafeTypeExpression $ "character(" <> renderNat p <> ")"
10741054-- | variable-length character string
10751055varchar, characterVarying
10761056 :: (KnownNat n, 1 <= n)
10771057 => proxy n
1078− -> TypeExpression '( '[], ('Null ('PGvarchar n)))
1058+ -> TypeExpression ('[] :=> 'Null ('PGvarchar n))
10791059varchar p = UnsafeTypeExpression $ "varchar(" <> renderNat p <> ")"
10801060characterVarying p = UnsafeTypeExpression $
10811061 "character varying(" <> renderNat p <> ")"
10821062-- | binary data ("byte array")
1083−bytea :: TypeExpression ( '[] :=> 'Null 'PGbytea)
1063+bytea :: TypeExpression ('[] :=> 'Null 'PGbytea)
10841064bytea = UnsafeTypeExpression "bytea"
10851065-- | date and time (no time zone)
1086−timestamp :: TypeExpression ( '[] :=> 'Null 'PGtimestamp)
1066+timestamp :: TypeExpression ('[] :=> 'Null 'PGtimestamp)
10871067timestamp = UnsafeTypeExpression "timestamp"
10881068-- | date and time, including time zone
1089−timestampWithTimeZone :: TypeExpression ( '[] :=> 'Null 'PGtimestamptz)
1069+timestampWithTimeZone :: TypeExpression ('[] :=> 'Null 'PGtimestamptz)
10901070timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
10911071-- | calendar date (year, month, day)
1092−date :: TypeExpression ( '[] :=> 'Null 'PGdate)
1072+date :: TypeExpression ('[] :=> 'Null 'PGdate)
10931073date = UnsafeTypeExpression "date"
10941074-- | time of day (no time zone)
1095−time :: TypeExpression ( '[] :=> 'Null 'PGtime)
1075+time :: TypeExpression ('[] :=> 'Null 'PGtime)
10961076time = UnsafeTypeExpression "time"
10971077-- | time of day, including time zone
1098−timeWithTimeZone :: TypeExpression ( '[] :=> 'Null 'PGtimetz)
1078+timeWithTimeZone :: TypeExpression ('[] :=> 'Null 'PGtimetz)
10991079timeWithTimeZone = UnsafeTypeExpression "time with time zone"
11001080-- | time span
1101−interval :: TypeExpression ( '[] :=> 'Null 'PGinterval)
1081+interval :: TypeExpression ('[] :=> 'Null 'PGinterval)
11021082interval = UnsafeTypeExpression "interval"
11031083-- | universally unique identifier
1104−uuid :: TypeExpression ( '[] :=> 'Null 'PGuuid)
1084+uuid :: TypeExpression ('[] :=> 'Null 'PGuuid)
11051085uuid = UnsafeTypeExpression "uuid"
11061086-- | IPv4 or IPv6 host address
1107−inet :: TypeExpression ( '[] :=> 'Null 'PGinet)
1087+inet :: TypeExpression ('[] :=> 'Null 'PGinet)
11081088inet = UnsafeTypeExpression "inet"
11091089-- | textual JSON data
1110−json :: TypeExpression ( '[] :=> 'Null 'PGjson)
1090+json :: TypeExpression ('[] :=> 'Null 'PGjson)
11111091json = UnsafeTypeExpression "json"
11121092-- | binary JSON data, decomposed
1113−jsonb :: TypeExpression ( '[] :=> 'Null 'PGjsonb)
1093+jsonb :: TypeExpression ('[] :=> 'Null 'PGjsonb)
11141094jsonb = UnsafeTypeExpression "jsonb"
11151095
11161096-- | used in `createTable` commands as a column constraint to ensure
@@ -1122,15 +1102,15 @@ notNull ty = UnsafeTypeExpression $ renderTypeExpression ty <+> "NOT NULL"
11221102
11231103-- | used in `createTable` commands as a column constraint to give a default
11241104default_
1125− :: Expression '[] 'Ungrouped '[] ( '[] :=> ty)
1126− -> TypeExpression ( '[] :=> ty)
1127− -> TypeExpression '(constraints, ty)
1105+ :: Expression '[] 'Ungrouped '[] ty
1106+ -> TypeExpression (constraints :=> ty)
1107+ -> TypeExpression (AsSet ('Default ': constraints) :=> ty)
11281108default_ x ty = UnsafeTypeExpression $
11291109 renderTypeExpression ty <+> "DEFAULT" <+> renderExpression x
11301110
11311111-- | `pgtype` is a demoted version of a `PGType`
11321112class PGTyped (ty :: PGType) where
1133− pgtype :: TypeExpression ( '[] :=> 'Null ty)
1113+ pgtype :: TypeExpression ('[] :=> 'Null ty)
11341114instance PGTyped 'PGbool where pgtype = bool
11351115instance PGTyped 'PGint2 where pgtype = int2
11361116instance PGTyped 'PGint4 where pgtype = int4