on dev help sign in
types for

schemum Typedef, Table & View

commit7053d25913978c51b68b0af6543a5f679da6052b authorEitan Chatav <eitan.chatav@gmail.com> dateThu 16 Aug 2018, 10:27 (8 years ago) parent6a21abf
2 files changed+7−1
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+1−1 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+6
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+1−1
@@ -1581,7 +1581,7 @@ newtype TypeExpression (schema :: SchemaType) (ty :: NullityType)
15811581 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
15821582 deriving (GHC.Generic,Show,Eq,Ord,NFData)
15831583
1584−instance (Has alias schema ('Typedef ty))
1584+instance (Has alias schema schemum, SchemumToType schemum ~ ty)
15851585 => IsLabel alias (TypeExpression schema (nullity ty)) where
15861586 fromLabel = UnsafeTypeExpression (renderAlias (fromLabel @alias))
15871587
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+6
@@ -46,6 +46,7 @@ module Squeal.PostgreSQL.Schema
4646 , TableType
4747 -- * Schema
4848 , SchemumType (..)
49+ , SchemumToType
4950 , SchemaType
5051 -- * Constraints
5152 , (:=>)
@@ -651,6 +652,11 @@ data SchemumType
651652 | View RowType
652653 | Typedef PGType
653654
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+
654660-- | The schema of a database consists of a list of aliased,
655661-- user-defined `SchemumType`s.
656662type SchemaType = [(Symbol,SchemumType)]