on dev help sign in
open PG type family
7d9c133Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+2−2
@@ -908,14 +908,14 @@ createTypeComposite ty fields = UnsafeDefinition $
908-- CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
908-- CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
909createTypeCompositeFrom
909createTypeCompositeFrom
910 :: forall hask ty schema.
910 :: forall hask ty schema.
911− ( SOP.All (FieldTyped schema) (PGFieldsFrom hask)
911+ ( SOP.All (FieldTyped schema) (RowPG hask)
912 , KnownSymbol ty )
912 , KnownSymbol ty )
913 => Alias ty
913 => Alias ty
914 -- ^ name of the user defined composite type
914 -- ^ name of the user defined composite type
915 -> Definition schema (Create ty ( 'Typedef (PG (Composite hask))) schema)
915 -> Definition schema (Create ty ( 'Typedef (PG (Composite hask))) schema)
916createTypeCompositeFrom ty = createTypeComposite ty
916createTypeCompositeFrom ty = createTypeComposite ty
917 (SOP.hcpure (SOP.Proxy :: SOP.Proxy (FieldTyped schema)) fieldtype
917 (SOP.hcpure (SOP.Proxy :: SOP.Proxy (FieldTyped schema)) fieldtype
918− :: NP (Aliased (TypeExpression schema)) (PGFieldsFrom hask))
918+ :: NP (Aliased (TypeExpression schema)) (RowPG hask))
919
919
920class FieldTyped schema ty where
920class FieldTyped schema ty where
921 fieldtype :: Aliased (TypeExpression schema) ty
921 fieldtype :: Aliased (TypeExpression schema) ty
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+56−56
@@ -119,9 +119,9 @@ module Squeal.PostgreSQL.Schema
119 , EnumFrom
119 , EnumFrom
120 , LabelsFrom
120 , LabelsFrom
121 , CompositeFrom
121 , CompositeFrom
122− , PGFieldsFrom
122+ , RowPG
123 , RowOf
123 , RowOf
124− , PGFieldOf
124+ , FieldPG
125 , ConstructorsOf
125 , ConstructorsOf
126 , ConstructorNameOf
126 , ConstructorNameOf
127 , ConstructorNamesOf
127 , ConstructorNamesOf
@@ -692,50 +692,50 @@ renderLabels = hcollapse
692-- >>> :kind! PG LocalTime
692-- >>> :kind! PG LocalTime
693-- PG LocalTime :: PGType
693-- PG LocalTime :: PGType
694-- = 'PGtimestamp
694-- = 'PGtimestamp
695−type family PG (hask :: Type) :: PGType where
695+type family PG (hask :: Type) :: PGType
696− PG Bool = 'PGbool
696+type instance PG Bool = 'PGbool
697− PG Int16 = 'PGint2
697+type instance PG Int16 = 'PGint2
698− PG Int32 = 'PGint4
698+type instance PG Int32 = 'PGint4
699− PG Int64 = 'PGint8
699+type instance PG Int64 = 'PGint8
700− PG Word16 = 'PGint2
700+type instance PG Word16 = 'PGint2
701− PG Word32 = 'PGint4
701+type instance PG Word32 = 'PGint4
702− PG Word64 = 'PGint8
702+type instance PG Word64 = 'PGint8
703− PG Scientific = 'PGnumeric
703+type instance PG Scientific = 'PGnumeric
704− PG Float = 'PGfloat4
704+type instance PG Float = 'PGfloat4
705− PG Double = 'PGfloat8
705+type instance PG Double = 'PGfloat8
706− PG Char = 'PGchar 1
706+type instance PG Char = 'PGchar 1
707− PG Text = 'PGtext
707+type instance PG Text = 'PGtext
708− PG Lazy.Text = 'PGtext
708+type instance PG Lazy.Text = 'PGtext
709− PG ByteString = 'PGbytea
709+type instance PG ByteString = 'PGbytea
710− PG Lazy.ByteString = 'PGbytea
710+type instance PG Lazy.ByteString = 'PGbytea
711− PG LocalTime = 'PGtimestamp
711+type instance PG LocalTime = 'PGtimestamp
712− PG UTCTime = 'PGtimestamptz
712+type instance PG UTCTime = 'PGtimestamptz
713− PG Day = 'PGdate
713+type instance PG Day = 'PGdate
714− PG TimeOfDay = 'PGtime
714+type instance PG TimeOfDay = 'PGtime
715− PG (TimeOfDay, TimeZone) = 'PGtimetz
715+type instance PG (TimeOfDay, TimeZone) = 'PGtimetz
716− PG DiffTime = 'PGinterval
716+type instance PG DiffTime = 'PGinterval
717− PG UUID = 'PGuuid
717+type instance PG UUID = 'PGuuid
718− PG (NetAddr IP) = 'PGinet
718+type instance PG (NetAddr IP) = 'PGinet
719− PG Value = 'PGjson
719+type instance PG Value = 'PGjson
720− PG Jsonb = 'PGjsonb
720+type instance PG Jsonb = 'PGjsonb
721− PG (Vector hask) = 'PGvararray (NullPG hask)
721+type instance PG (Vector hask) = 'PGvararray (NullPG hask)
722− PG (hask, hask) = 'PGfixarray 2 (NullPG hask)
722+type instance PG (hask, hask) = 'PGfixarray 2 (NullPG hask)
723− PG (hask, hask, hask) = 'PGfixarray 3 (NullPG hask)
723+type instance PG (hask, hask, hask) = 'PGfixarray 3 (NullPG hask)
724− PG (hask, hask, hask, hask) = 'PGfixarray 4 (NullPG hask)
724+type instance PG (hask, hask, hask, hask) = 'PGfixarray 4 (NullPG hask)
725− PG (hask, hask, hask, hask, hask) = 'PGfixarray 5 (NullPG hask)
725+type instance PG (hask, hask, hask, hask, hask) = 'PGfixarray 5 (NullPG hask)
726− PG (hask, hask, hask, hask, hask, hask) = 'PGfixarray 6 (NullPG hask)
726+type instance PG (hask, hask, hask, hask, hask, hask)
727+ = 'PGfixarray 6 (NullPG hask)
727− PG (hask, hask, hask, hask, hask, hask, hask) = 'PGfixarray 7 (NullPG hask)
728+type instance PG (hask, hask, hask, hask, hask, hask, hask)
729+ = 'PGfixarray 7 (NullPG hask)
728− PG (hask, hask, hask, hask, hask, hask, hask, hask)
730+type instance PG (hask, hask, hask, hask, hask, hask, hask, hask)
729− = 'PGfixarray 8 (NullPG hask)
731+ = 'PGfixarray 8 (NullPG hask)
730− PG (hask, hask, hask, hask, hask, hask, hask, hask, hask)
732+type instance PG (hask, hask, hask, hask, hask, hask, hask, hask, hask)
731− = 'PGfixarray 9 (NullPG hask)
733+ = 'PGfixarray 9 (NullPG hask)
732− PG (hask, hask, hask, hask, hask, hask, hask, hask, hask, hask)
734+type instance PG (hask, hask, hask, hask, hask, hask, hask, hask, hask, hask)
733− = 'PGfixarray 10 (NullPG hask)
735+ = 'PGfixarray 10 (NullPG hask)
734− PG (Composite hask) = 'PGcomposite (RowOf (RecordCodeOf hask))
736+type instance PG (Composite hask) = 'PGcomposite (RowOf (RecordCodeOf hask))
735− PG (Enumerated hask)
737+type instance PG (Enumerated hask)
736− = 'PGenum (ConstructorNamesOf (ConstructorsOf (DatatypeInfoOf hask)))
738+ = 'PGenum (ConstructorNamesOf (ConstructorsOf (DatatypeInfoOf hask)))
737− PG ty = TypeError
738− ('Text "There is no Postgres type for " ':<>: 'ShowType ty)
739
739
740newtype Jsonb = Jsonb {getJsonb :: Value}
740newtype Jsonb = Jsonb {getJsonb :: Value}
741newtype Composite record = Composite {getComposite :: record}
741newtype Composite record = Composite {getComposite :: record}
@@ -780,26 +780,26 @@ type family LabelsFrom (hask :: Type) :: [Type.ConstructorName] where
780type family CompositeFrom (hask :: Type) :: PGType where
780type family CompositeFrom (hask :: Type) :: PGType where
781 CompositeFrom hask = PG (Composite hask)
781 CompositeFrom hask = PG (Composite hask)
782
782
783−type family PGFieldsFrom (hask :: Type) :: RowType where
783+type family RowPG (hask :: Type) :: RowType where
784− PGFieldsFrom hask = RowOf (RecordCodeOf hask)
784+ RowPG hask = RowOf (RecordCodeOf hask)
785
785
786type family RowOf (fields :: [(Symbol, Type)]) :: RowType where
786type family RowOf (fields :: [(Symbol, Type)]) :: RowType where
787 RowOf '[] = '[]
787 RowOf '[] = '[]
788− RowOf (field ': fields) = PGFieldOf field ': RowOf fields
788+ RowOf (field ': fields) = FieldPG field ': RowOf fields
789
789
790−type family PGFieldOf (field :: (Symbol, Type)) :: (Symbol, NullityType) where
790+type family FieldPG (field :: (Symbol, Type)) :: (Symbol, NullityType) where
791− PGFieldOf (field ::: hask) = field ::: NullPG hask
791+ FieldPG (field ::: hask) = field ::: NullPG hask
792
792
793type family NullPG (hask :: Type) :: NullityType where
793type family NullPG (hask :: Type) :: NullityType where
794 NullPG (Maybe hask) = 'Null (PG hask)
794 NullPG (Maybe hask) = 'Null (PG hask)
795 NullPG hask = 'NotNull (PG hask)
795 NullPG hask = 'NotNull (PG hask)
796
796
797−type family ParamsOf (hask :: Type) :: [NullityType] where
797+type family TuplePG (hask :: Type) :: [NullityType] where
798− ParamsOf hask = NullPGs (TupleCodeOf hask (Code hask))
798+ TuplePG hask = TupleOf (TupleCodeOf hask (Code hask))
799
799
800−type family NullPGs (tuple :: [Type]) :: [NullityType] where
800+type family TupleOf (tuple :: [Type]) :: [NullityType] where
801− NullPGs '[] = '[]
801+ TupleOf '[] = '[]
802− NullPGs (hask ': tuple) = NullPG hask ': NullPGs tuple
802+ TupleOf (hask ': tuple) = NullPG hask ': TupleOf tuple
803
803
804type family TupleCodeOf (hask :: Type) (code :: [[Type]]) :: [Type] where
804type family TupleCodeOf (hask :: Type) (code :: [[Type]]) :: [Type] where
805 TupleCodeOf hask '[tuple] = tuple
805 TupleCodeOf hask '[tuple] = tuple