on dev help sign in
frompg
9d2c665Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+18−5
@@ -208,6 +208,7 @@ module Squeal.PostgreSQL.Binary
208 , TuplePG
208 , TuplePG
209 , RowPG
209 , RowPG
210 , LabelsPG
210 , LabelsPG
211+ , FromPG
211 -- * Storage newtypes
212 -- * Storage newtypes
212 , Money (..)
213 , Money (..)
213 , Json (..)
214 , Json (..)
@@ -884,12 +885,9 @@ type family RowPG (hask :: Type) :: RowType where
884 RowPG (P (col ::: head)) = '[col ::: NullPG head]
885 RowPG (P (col ::: head)) = '[col ::: NullPG head]
885 RowPG hask = RowOf (RecordCodeOf hask)
886 RowPG hask = RowOf (RecordCodeOf hask)
886
887
887−type family RowOf (fields :: [(Symbol, Type)]) :: RowType where
888+type family RowOf (record :: [(Symbol, Type)]) :: RowType where
888 RowOf '[] = '[]
889 RowOf '[] = '[]
889− RowOf (field ': fields) = FieldPG field ': RowOf fields
890+ RowOf (col ::: ty ': record) = col ::: NullPG ty ': RowOf record
890−
891−type family FieldPG (field :: (Symbol, Type)) :: (Symbol, NullityType) where
892− FieldPG (field ::: hask) = field ::: NullPG hask
893
891
894{- | `NullPG` turns a Haskell type into a `NullityType`.
892{- | `NullPG` turns a Haskell type into a `NullityType`.
895
893
@@ -957,3 +955,18 @@ type family ConstructorNamesOf (constructors :: [Type.ConstructorInfo])
957 ConstructorNamesOf '[] = '[]
955 ConstructorNamesOf '[] = '[]
958 ConstructorNamesOf (constructor ': constructors) =
956 ConstructorNamesOf (constructor ': constructors) =
959 ConstructorNameOf constructor ': ConstructorNamesOf constructors
957 ConstructorNameOf constructor ': ConstructorNamesOf constructors
958+
959+type family FromPG (hask :: Type) :: FromType where
960+ FromPG (hask1, hask2) = Join (FromPG hask1) (FromPG hask2)
961+ FromPG (hask1, hask2, hask3) =
962+ Join (FromPG hask1) (FromPG (hask2, hask3))
963+ FromPG (hask1, hask2, hask3, hask4) =
964+ Join (FromPG hask1) (FromPG (hask2, hask3, hask4))
965+ FromPG (hask1, hask2, hask3, hask4, hask5) =
966+ Join (FromPG hask1) (FromPG (hask2, hask3, hask4, hask5))
967+ FromPG (P (col ::: hask)) = '[col ::: RowPG hask]
968+ FromPG hask = FromOf (RecordCodeOf hask)
969+
970+type family FromOf (record :: [(Symbol, Type)]) :: FromType where
971+ FromOf '[] = '[]
972+ FromOf (tab ::: ty ': record) = tab ::: RowPG ty ': FromOf record
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+4
@@ -879,6 +879,10 @@ jsonbToRecordSet = unsafeRecordFunction "jsonb_to_record_set"
879FROM clauses
879FROM clauses
880-----------------------------------------}
880-----------------------------------------}
881
881
882+type family FromClause_ schemas params from where
883+ FromClause_ schemas params from =
884+ FromClause schemas (TuplePG params) (FromPG from)
885+
882{- |
886{- |
883A `FromClause` can be a table name, or a derived table such
887A `FromClause` can be a table name, or a derived table such
884as a subquery, a @JOIN@ construct, or complex combinations of these.
888as a subquery, a @JOIN@ construct, or complex combinations of these.