@@ -66,7 +66,6 @@ module Squeal.PostgreSQL.Schema
66 , IsNotElem
66 , IsNotElem
67 , AllUnique
67 , AllUnique
68 -- * Type Classifications
68 -- * Type Classifications
71 , PGIntegral
70 , PGIntegral
72 , PGFloating
71 , PGFloating
@@ -90,12 +89,12 @@ import Control.Category
90import Data.Kind
89import Data.Kind
91import Data.Monoid hiding (All)
90import Data.Monoid hiding (All)
92import Data.Type.Bool
91import Data.Type.Bool
93−import Data.Word (Word32)
94import Generics.SOP
92import Generics.SOP
95import GHC.TypeLits
93import GHC.TypeLits
96import Prelude hiding (id, (.))
94import Prelude hiding (id, (.))
98import Squeal.PostgreSQL.Alias
96import Squeal.PostgreSQL.Alias
97+import Squeal.PostgreSQL.List
99import Squeal.PostgreSQL.Render
98import Squeal.PostgreSQL.Render
101-- | `PGType` is the promoted datakind of PostgreSQL types.
100-- | `PGType` is the promoted datakind of PostgreSQL types.
@@ -134,34 +133,6 @@ data PGType
134 | PGtsquery -- ^ A tsquery value stores lexemes that are to be searched for
133 | PGtsquery -- ^ A tsquery value stores lexemes that are to be searched for
135 | UnsafePGType Symbol -- ^ an escape hatch for unsupported PostgreSQL types
134 | UnsafePGType Symbol -- ^ an escape hatch for unsupported PostgreSQL types
137−-- | The object identifier of a `PGType`.
139−-- >>> :set -XTypeApplications
142−class HasOid (ty :: PGType) where oid :: Word32
143−instance HasOid 'PGbool where oid = 16
144−instance HasOid 'PGint2 where oid = 21
145−instance HasOid 'PGint4 where oid = 23
146−instance HasOid 'PGint8 where oid = 20
147−instance HasOid 'PGnumeric where oid = 1700
148−instance HasOid 'PGfloat4 where oid = 700
149−instance HasOid 'PGfloat8 where oid = 701
150−instance HasOid ('PGchar n) where oid = 18
151−instance HasOid ('PGvarchar n) where oid = 1043
152−instance HasOid 'PGtext where oid = 25
153−instance HasOid 'PGbytea where oid = 17
154−instance HasOid 'PGtimestamp where oid = 1114
155−instance HasOid 'PGtimestamptz where oid = 1184
156−instance HasOid 'PGdate where oid = 1082
157−instance HasOid 'PGtime where oid = 1083
158−instance HasOid 'PGtimetz where oid = 1266
159−instance HasOid 'PGinterval where oid = 1186
160−instance HasOid 'PGuuid where oid = 2950
161−instance HasOid 'PGinet where oid = 869
162−instance HasOid 'PGjson where oid = 114
163−instance HasOid 'PGjsonb where oid = 3802
165-- | `NullityType` encodes the potential presence or definite absence of a
136-- | `NullityType` encodes the potential presence or definite absence of a
166-- @NULL@ allowing operations which are sensitive to such to be well typed.
137-- @NULL@ allowing operations which are sensitive to such to be well typed.
@@ -286,15 +257,6 @@ type family TableToColumns (table :: TableType) :: ColumnsType where
286type family TableToRow (table :: TableType) :: RowType where
257type family TableToRow (table :: TableType) :: RowType where
287 TableToRow tab = ColumnsToRow (TableToColumns tab)
258 TableToRow tab = ColumnsToRow (TableToColumns tab)
289−-- | @Elem@ is a promoted `Data.List.elem`.
290−type family Elem x xs where
292− Elem x (x ': xs) = 'True
293− Elem x (_ ': xs) = Elem x xs
295−-- | @In x xs@ is a constraint that proves that @x@ is in @xs@.
296−type family In x xs :: Constraint where In x xs = Elem x xs ~ 'True
298-- | Numeric Postgres types.
260-- | Numeric Postgres types.
299type PGNum =
261type PGNum =
300 '[ 'PGint2, 'PGint4, 'PGint8, 'PGnumeric, 'PGfloat4, 'PGfloat8]
262 '[ 'PGint2, 'PGint4, 'PGint8, 'PGnumeric, 'PGfloat4, 'PGfloat8]
@@ -394,16 +356,6 @@ type family DropIfConstraintsInvolve column constraints where
394 (DropIfConstraintsInvolve column constraints)
356 (DropIfConstraintsInvolve column constraints)
395 (alias ::: constraint ': DropIfConstraintsInvolve column constraints)
357 (alias ::: constraint ': DropIfConstraintsInvolve column constraints)
397−{- | Calculate the `Length` of a type level list
399−>>> :kind! Length '[Char,String,Bool,Double]
400−Length '[Char,String,Bool,Double] :: Nat
403−type family Length (xs :: [k]) :: Nat where
404− Length (x : xs) = 1 + Length xs
407-- | A `SchemumType` is a user-defined type, either a `Table`,
359-- | A `SchemumType` is a user-defined type, either a `Table`,
408-- `View` or `Typedef`.
360-- `View` or `Typedef`.
409data SchemumType
361data SchemumType