@@ -115,9 +115,7 @@ module Squeal.PostgreSQL.Schema
115 , Composite (..)
115 , Composite (..)
116 , Enumerated (..)
116 , Enumerated (..)
119 , LabelsFrom
118 , LabelsFrom
123 , FieldPG
121 , FieldPG
@@ -722,26 +720,13 @@ type instance PG (hask, hask, hask, hask, hask, hask, hask, hask, hask)
722type instance PG (hask, hask, hask, hask, hask, hask, hask, hask, hask, hask)
720type instance PG (hask, hask, hask, hask, hask, hask, hask, hask, hask, hask)
723 = 'PGfixarray 10 (NullPG hask)
721 = 'PGfixarray 10 (NullPG hask)
724type instance PG (Composite hask) = 'PGcomposite (RowOf (RecordCodeOf hask))
722type instance PG (Composite hask) = 'PGcomposite (RowOf (RecordCodeOf hask))
725−type instance PG (Enumerated hask)
723+type instance PG (Enumerated hask) = 'PGenum (LabelsFrom hask)
726− = 'PGenum (ConstructorNamesOf (ConstructorsOf (DatatypeInfoOf hask)))
728newtype Json hask = Json {getJson :: hask}
725newtype Json hask = Json {getJson :: hask}
729newtype Jsonb hask = Jsonb {getJsonb :: hask}
726newtype Jsonb hask = Jsonb {getJsonb :: hask}
730newtype Composite record = Composite {getComposite :: record}
727newtype Composite record = Composite {getComposite :: record}
731newtype Enumerated enum = Enumerated {getEnumerated :: enum}
728newtype Enumerated enum = Enumerated {getEnumerated :: enum}
733−-- | The `EnumFrom` type family embeds Haskell enum types, ADTs with
734−-- nullary constructors, as Postgres enum types
736−-- >>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
737−-- >>> instance Generic Schwarma
738−-- >>> instance HasDatatypeInfo Schwarma
739−-- >>> :kind! EnumFrom Schwarma
740−-- EnumFrom Schwarma :: PGType
741−-- = 'PGenum '["Beef", "Lamb", "Chicken"]
742−type family EnumFrom (hask :: Type) :: PGType where
743− EnumFrom hask = PG (Enumerated hask)
745-- | The `LabelsFrom` type family calculates the constructors of a
730-- | The `LabelsFrom` type family calculates the constructors of a
746-- Haskell enum type.
731-- Haskell enum type.
@@ -755,20 +740,6 @@ type family LabelsFrom (hask :: Type) :: [Type.ConstructorName] where
755 LabelsFrom hask =
740 LabelsFrom hask =
756 ConstructorNamesOf (ConstructorsOf (DatatypeInfoOf hask))
741 ConstructorNamesOf (ConstructorsOf (DatatypeInfoOf hask))
758−-- | The `CompositeFrom` type family embeds Haskell record types as
759−-- Postgres composite types, as long as the record fields
760−-- are `Maybe`s of Haskell types that can be embedded as basic types
761−-- with the `PG` type family.
763−-- >>> data Row = Row { a :: Maybe Int16, b :: Maybe LocalTime } deriving GHC.Generic
764−-- >>> instance Generic Row
765−-- >>> instance HasDatatypeInfo Row
766−-- >>> :kind! CompositeFrom Row
767−-- CompositeFrom Row :: PGType
768−-- = 'PGcomposite '["a" ::: 'Null 'PGint2, "b" ::: 'Null 'PGtimestamp]
769−type family CompositeFrom (hask :: Type) :: PGType where
770− CompositeFrom hask = PG (Composite hask)
772type family RowPG (hask :: Type) :: RowType where
743type family RowPG (hask :: Type) :: RowType where
773 RowPG hask = RowOf (RecordCodeOf hask)
744 RowPG hask = RowOf (RecordCodeOf hask)