on dev help sign in
open PG type family

and rename PGFieldsFrom ~> RowPG and PGFieldOf ~> FieldPG

commit7d9c13330d1eefd44cd38a794b15b60042828fc5 authorEitan Chatav <eitan.chatav@gmail.com> dateWed 29 Aug 2018, 10:51 (8 years ago) parentea81c69
2 files changed+58−58
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+2−2 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+56−56
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+2−2
@@ -908,14 +908,14 @@ createTypeComposite ty fields = UnsafeDefinition $
908908-- CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
909909createTypeCompositeFrom
910910 :: forall hask ty schema.
911− ( SOP.All (FieldTyped schema) (PGFieldsFrom hask)
911+ ( SOP.All (FieldTyped schema) (RowPG hask)
912912 , KnownSymbol ty )
913913 => Alias ty
914914 -- ^ name of the user defined composite type
915915 -> Definition schema (Create ty ( 'Typedef (PG (Composite hask))) schema)
916916createTypeCompositeFrom ty = createTypeComposite ty
917917 (SOP.hcpure (SOP.Proxy :: SOP.Proxy (FieldTyped schema)) fieldtype
918− :: NP (Aliased (TypeExpression schema)) (PGFieldsFrom hask))
918+ :: NP (Aliased (TypeExpression schema)) (RowPG hask))
919919
920920class FieldTyped schema ty where
921921 fieldtype :: Aliased (TypeExpression schema) ty
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+56−56
@@ -119,9 +119,9 @@ module Squeal.PostgreSQL.Schema
119119 , EnumFrom
120120 , LabelsFrom
121121 , CompositeFrom
122− , PGFieldsFrom
122+ , RowPG
123123 , RowOf
124− , PGFieldOf
124+ , FieldPG
125125 , ConstructorsOf
126126 , ConstructorNameOf
127127 , ConstructorNamesOf
@@ -692,50 +692,50 @@ renderLabels = hcollapse
692692-- >>> :kind! PG LocalTime
693693-- PG LocalTime :: PGType
694694-- = 'PGtimestamp
695−type family PG (hask :: Type) :: PGType where
696− PG Bool = 'PGbool
697− PG Int16 = 'PGint2
698− PG Int32 = 'PGint4
699− PG Int64 = 'PGint8
700− PG Word16 = 'PGint2
701− PG Word32 = 'PGint4
702− PG Word64 = 'PGint8
703− PG Scientific = 'PGnumeric
704− PG Float = 'PGfloat4
705− PG Double = 'PGfloat8
706− PG Char = 'PGchar 1
707− PG Text = 'PGtext
708− PG Lazy.Text = 'PGtext
709− PG ByteString = 'PGbytea
710− PG Lazy.ByteString = 'PGbytea
711− PG LocalTime = 'PGtimestamp
712− PG UTCTime = 'PGtimestamptz
713− PG Day = 'PGdate
714− PG TimeOfDay = 'PGtime
715− PG (TimeOfDay, TimeZone) = 'PGtimetz
716− PG DiffTime = 'PGinterval
717− PG UUID = 'PGuuid
718− PG (NetAddr IP) = 'PGinet
719− PG Value = 'PGjson
720− PG Jsonb = 'PGjsonb
721− PG (Vector hask) = 'PGvararray (NullPG hask)
722− PG (hask, hask) = 'PGfixarray 2 (NullPG hask)
723− PG (hask, hask, hask) = 'PGfixarray 3 (NullPG hask)
724− PG (hask, hask, hask, hask) = 'PGfixarray 4 (NullPG hask)
725− PG (hask, hask, hask, hask, hask) = 'PGfixarray 5 (NullPG hask)
726− PG (hask, hask, hask, hask, hask, hask) = 'PGfixarray 6 (NullPG hask)
727− PG (hask, hask, hask, hask, hask, hask, hask) = 'PGfixarray 7 (NullPG hask)
728− PG (hask, hask, hask, hask, hask, hask, hask, hask)
729− = 'PGfixarray 8 (NullPG hask)
730− PG (hask, hask, hask, hask, hask, hask, hask, hask, hask)
731− = 'PGfixarray 9 (NullPG hask)
732− PG (hask, hask, hask, hask, hask, hask, hask, hask, hask, hask)
733− = 'PGfixarray 10 (NullPG hask)
734− PG (Composite hask) = 'PGcomposite (RowOf (RecordCodeOf hask))
735− PG (Enumerated hask)
736− = 'PGenum (ConstructorNamesOf (ConstructorsOf (DatatypeInfoOf hask)))
737− PG ty = TypeError
738− ('Text "There is no Postgres type for " ':<>: 'ShowType ty)
695+type family PG (hask :: Type) :: PGType
696+type instance PG Bool = 'PGbool
697+type instance PG Int16 = 'PGint2
698+type instance PG Int32 = 'PGint4
699+type instance PG Int64 = 'PGint8
700+type instance PG Word16 = 'PGint2
701+type instance PG Word32 = 'PGint4
702+type instance PG Word64 = 'PGint8
703+type instance PG Scientific = 'PGnumeric
704+type instance PG Float = 'PGfloat4
705+type instance PG Double = 'PGfloat8
706+type instance PG Char = 'PGchar 1
707+type instance PG Text = 'PGtext
708+type instance PG Lazy.Text = 'PGtext
709+type instance PG ByteString = 'PGbytea
710+type instance PG Lazy.ByteString = 'PGbytea
711+type instance PG LocalTime = 'PGtimestamp
712+type instance PG UTCTime = 'PGtimestamptz
713+type instance PG Day = 'PGdate
714+type instance PG TimeOfDay = 'PGtime
715+type instance PG (TimeOfDay, TimeZone) = 'PGtimetz
716+type instance PG DiffTime = 'PGinterval
717+type instance PG UUID = 'PGuuid
718+type instance PG (NetAddr IP) = 'PGinet
719+type instance PG Value = 'PGjson
720+type instance PG Jsonb = 'PGjsonb
721+type instance PG (Vector hask) = 'PGvararray (NullPG hask)
722+type instance PG (hask, hask) = 'PGfixarray 2 (NullPG hask)
723+type instance PG (hask, hask, hask) = 'PGfixarray 3 (NullPG hask)
724+type instance PG (hask, hask, hask, hask) = 'PGfixarray 4 (NullPG hask)
725+type instance PG (hask, hask, hask, hask, hask) = 'PGfixarray 5 (NullPG hask)
726+type instance PG (hask, hask, hask, hask, hask, hask)
727+ = 'PGfixarray 6 (NullPG hask)
728+type instance PG (hask, hask, hask, hask, hask, hask, hask)
729+ = 'PGfixarray 7 (NullPG hask)
730+type instance PG (hask, hask, hask, hask, hask, hask, hask, hask)
731+ = 'PGfixarray 8 (NullPG hask)
732+type instance PG (hask, hask, hask, hask, hask, hask, hask, hask, hask)
733+ = 'PGfixarray 9 (NullPG hask)
734+type instance PG (hask, hask, hask, hask, hask, hask, hask, hask, hask, hask)
735+ = 'PGfixarray 10 (NullPG hask)
736+type instance PG (Composite hask) = 'PGcomposite (RowOf (RecordCodeOf hask))
737+type instance PG (Enumerated hask)
738+ = 'PGenum (ConstructorNamesOf (ConstructorsOf (DatatypeInfoOf hask)))
739739
740740newtype Jsonb = Jsonb {getJsonb :: Value}
741741newtype Composite record = Composite {getComposite :: record}
@@ -780,26 +780,26 @@ type family LabelsFrom (hask :: Type) :: [Type.ConstructorName] where
780780type family CompositeFrom (hask :: Type) :: PGType where
781781 CompositeFrom hask = PG (Composite hask)
782782
783−type family PGFieldsFrom (hask :: Type) :: RowType where
784− PGFieldsFrom hask = RowOf (RecordCodeOf hask)
783+type family RowPG (hask :: Type) :: RowType where
784+ RowPG hask = RowOf (RecordCodeOf hask)
785785
786786type family RowOf (fields :: [(Symbol, Type)]) :: RowType where
787787 RowOf '[] = '[]
788− RowOf (field ': fields) = PGFieldOf field ': RowOf fields
788+ RowOf (field ': fields) = FieldPG field ': RowOf fields
789789
790−type family PGFieldOf (field :: (Symbol, Type)) :: (Symbol, NullityType) where
791− PGFieldOf (field ::: hask) = field ::: NullPG hask
790+type family FieldPG (field :: (Symbol, Type)) :: (Symbol, NullityType) where
791+ FieldPG (field ::: hask) = field ::: NullPG hask
792792
793793type family NullPG (hask :: Type) :: NullityType where
794794 NullPG (Maybe hask) = 'Null (PG hask)
795795 NullPG hask = 'NotNull (PG hask)
796796
797−type family ParamsOf (hask :: Type) :: [NullityType] where
798− ParamsOf hask = NullPGs (TupleCodeOf hask (Code hask))
797+type family TuplePG (hask :: Type) :: [NullityType] where
798+ TuplePG hask = TupleOf (TupleCodeOf hask (Code hask))
799799
800−type family NullPGs (tuple :: [Type]) :: [NullityType] where
801− NullPGs '[] = '[]
802− NullPGs (hask ': tuple) = NullPG hask ': NullPGs tuple
800+type family TupleOf (tuple :: [Type]) :: [NullityType] where
801+ TupleOf '[] = '[]
802+ TupleOf (hask ': tuple) = NullPG hask ': TupleOf tuple
803803
804804type family TupleCodeOf (hask :: Type) (code :: [[Type]]) :: [Type] where
805805 TupleCodeOf hask '[tuple] = tuple