on dev help sign in
types for
7053d25Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+1−1
@@ -1581,7 +1581,7 @@ newtype TypeExpression (schema :: SchemaType) (ty :: NullityType)
1581 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
1581 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
1582 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1582 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1583
1583
1584−instance (Has alias schema ('Typedef ty))
1584+instance (Has alias schema schemum, SchemumToType schemum ~ ty)
1585 => IsLabel alias (TypeExpression schema (nullity ty)) where
1585 => IsLabel alias (TypeExpression schema (nullity ty)) where
1586 fromLabel = UnsafeTypeExpression (renderAlias (fromLabel @alias))
1586 fromLabel = UnsafeTypeExpression (renderAlias (fromLabel @alias))
1587
1587
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+6
@@ -46,6 +46,7 @@ module Squeal.PostgreSQL.Schema
46 , TableType
46 , TableType
47 -- * Schema
47 -- * Schema
48 , SchemumType (..)
48 , SchemumType (..)
49+ , SchemumToType
49 , SchemaType
50 , SchemaType
50 -- * Constraints
51 -- * Constraints
51 , (:=>)
52 , (:=>)
@@ -651,6 +652,11 @@ data SchemumType
651 | View RowType
652 | View RowType
652 | Typedef PGType
653 | Typedef PGType
653
654
655+type family SchemumToType (schemum :: SchemumType) :: PGType where
656+ SchemumToType ('Typedef ty) = ty
657+ SchemumToType ('Table table) = 'PGcomposite (TableToRow table)
658+ SchemumToType ('View view) = 'PGcomposite view
659+
654-- | The schema of a database consists of a list of aliased,
660-- | The schema of a database consists of a list of aliased,
655-- user-defined `SchemumType`s.
661-- user-defined `SchemumType`s.
656type SchemaType = [(Symbol,SchemumType)]
662type SchemaType = [(Symbol,SchemumType)]