@@ -7,6 +7,7 @@
77 , LambdaCase
88 , MagicHash
99 , OverloadedStrings
10+ , ScopedTypeVariables
1011 , TypeFamilies
1112 , TypeOperators
1213 , UndecidableInstances
@@ -568,16 +569,93 @@ newtype TypeExpression (ty :: ColumnType)
568569 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
569570 deriving (Show,Eq)
570571
572+bool :: TypeExpression ('Required ('Null 'PGBool))
573+bool = UnsafeTypeExpression "bool"
571574int2 :: TypeExpression ('Required ('Null 'PGInt2))
572575int2 = UnsafeTypeExpression "int2"
576+smallint :: TypeExpression ('Required ('Null 'PGInt2))
577+smallint = UnsafeTypeExpression "smallint"
573578int4 :: TypeExpression ('Required ('Null 'PGInt4))
574579int4 = UnsafeTypeExpression "int4"
580+int :: TypeExpression ('Required ('Null 'PGInt4))
581+int = UnsafeTypeExpression "int"
582+integer :: TypeExpression ('Required ('Null 'PGInt4))
583+integer = UnsafeTypeExpression "integer"
575584int8 :: TypeExpression ('Required ('Null 'PGInt8))
576585int8 = UnsafeTypeExpression "int8"
577−bool :: TypeExpression ('Required ('Null 'PGBool))
578−bool = UnsafeTypeExpression "bool"
586+bigint :: TypeExpression ('Required ('Null 'PGInt8))
587+bigint = UnsafeTypeExpression "bigint"
588+numeric :: TypeExpression ('Required ('Null 'PGNumeric))
589+numeric = UnsafeTypeExpression "numeric"
590+float4 :: TypeExpression ('Required ('Null 'PGFloat4))
591+float4 = UnsafeTypeExpression "float4"
592+real :: TypeExpression ('Required ('Null 'PGFloat4))
593+real = UnsafeTypeExpression "real"
594+float8 :: TypeExpression ('Required ('Null 'PGFloat8))
595+float8 = UnsafeTypeExpression "float8"
596+doublePrecision :: TypeExpression ('Required ('Null 'PGFloat8))
597+doublePrecision = UnsafeTypeExpression "double precision"
598+serial2 :: TypeExpression ('Optional ('NotNull 'PGInt2))
599+serial2 = UnsafeTypeExpression "serial2"
600+smallserial :: TypeExpression ('Optional ('NotNull 'PGInt2))
601+smallserial = UnsafeTypeExpression "smallserial"
602+serial4 :: TypeExpression ('Optional ('NotNull 'PGInt4))
603+serial4 = UnsafeTypeExpression "serial4"
604+serial :: TypeExpression ('Optional ('NotNull 'PGInt4))
605+serial = UnsafeTypeExpression "serial"
606+serial8 :: TypeExpression ('Optional ('NotNull 'PGInt8))
607+serial8 = UnsafeTypeExpression "serial8"
608+bigserial :: TypeExpression ('Optional ('NotNull 'PGInt8))
609+bigserial = UnsafeTypeExpression "bigserial"
610+money :: TypeExpression ('Optional ('NotNull 'PGMoney))
611+money = UnsafeTypeExpression "money"
579612text :: TypeExpression ('Required ('Null 'PGText))
580613text = UnsafeTypeExpression "text"
614+char
615+ :: KnownNat n
616+ => proxy n
617+ -> TypeExpression ('Optional ('NotNull ('PGChar n)))
618+char (_ :: proxy n) = UnsafeTypeExpression $
619+ "char(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
620+character
621+ :: KnownNat n
622+ => proxy n
623+ -> TypeExpression ('Optional ('NotNull ('PGChar n)))
624+character (_ :: proxy n) = UnsafeTypeExpression $
625+ "character(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
626+varchar
627+ :: KnownNat n
628+ => proxy n
629+ -> TypeExpression ('Optional ('NotNull ('PGVarChar n)))
630+varchar (_ :: proxy n) = UnsafeTypeExpression $
631+ "varchar(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
632+characterVarying
633+ :: KnownNat n
634+ => proxy n
635+ -> TypeExpression ('Optional ('NotNull ('PGVarChar n)))
636+characterVarying (_ :: proxy n) = UnsafeTypeExpression $
637+ "character varying(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
638+bytea :: TypeExpression ('Optional ('NotNull ('PGBytea)))
639+bytea = UnsafeTypeExpression "bytea"
640+timestamp :: TypeExpression ('Optional ('NotNull ('PGTimestamp)))
641+timestamp = UnsafeTypeExpression "timestamp"
642+timestampWithTimeZone :: TypeExpression ('Optional ('NotNull ('PGTimestampTZ)))
643+timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
644+date :: TypeExpression ('Optional ('NotNull ('PGDate)))
645+date = UnsafeTypeExpression "date"
646+time :: TypeExpression ('Optional ('NotNull ('PGTime)))
647+time = UnsafeTypeExpression "time"
648+timeWithTimeZone :: TypeExpression ('Optional ('NotNull ('PGTimeTZ)))
649+timeWithTimeZone = UnsafeTypeExpression "time with time zone"
650+interval :: TypeExpression ('Optional ('NotNull ('PGInterval)))
651+interval = UnsafeTypeExpression "interval"
652+uuid :: TypeExpression ('Optional ('NotNull ('PGUuid)))
653+uuid = UnsafeTypeExpression "uuid"
654+json :: TypeExpression ('Optional ('NotNull ('PGJson)))
655+json = UnsafeTypeExpression "json"
656+jsonb :: TypeExpression ('Optional ('NotNull ('PGJsonb)))
657+jsonb = UnsafeTypeExpression "jsonb"
658+
581659notNull
582660 :: TypeExpression ('Required ('Null ty))
583661 -> TypeExpression ('Required ('NotNull ty))
@@ -588,8 +666,6 @@ default_
588666 -> TypeExpression ('Optional ty)
589667default_ x ty = UnsafeTypeExpression $
590668 renderTypeExpression ty <> " DEFAULT " <> renderExpression x
591−serial :: TypeExpression ('Optional ('NotNull 'PGInt4))
592−serial = UnsafeTypeExpression "serial"
593669
594670class PGTyped (ty :: PGType) where
595671 pgtype :: TypeExpression ('Required ('Null ty))