on dev help sign in
trying stuff
28cc574Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+5
@@ -16,6 +16,7 @@ Squeal queries.
16 , LambdaCase
16 , LambdaCase
17 , OverloadedStrings
17 , OverloadedStrings
18 , StandaloneDeriving
18 , StandaloneDeriving
19+ , TypeFamilies
19 , TypeInType
20 , TypeInType
20 , TypeOperators
21 , TypeOperators
21#-}
22#-}
@@ -23,6 +24,7 @@ Squeal queries.
23module Squeal.PostgreSQL.Query
24module Squeal.PostgreSQL.Query
24 ( -- * Queries
25 ( -- * Queries
25 Query (UnsafeQuery, renderQuery)
26 Query (UnsafeQuery, renderQuery)
27+ , Query'
26 , union
28 , union
27 , unionAll
29 , unionAll
28 , intersect
30 , intersect
@@ -283,6 +285,9 @@ newtype Query
283 deriving (GHC.Generic,Show,Eq,Ord,NFData)
285 deriving (GHC.Generic,Show,Eq,Ord,NFData)
284instance RenderSQL (Query schema params columns) where renderSQL = renderQuery
286instance RenderSQL (Query schema params columns) where renderSQL = renderQuery
285
287
288+type family Query' schema x y where
289+ Query' schema x y = Query schema (ParamsFrom x) (ResultFrom y)
290+
286-- | The results of two queries can be combined using the set operation
291-- | The results of two queries can be combined using the set operation
287-- `union`. Duplicate rows are eliminated.
292-- `union`. Duplicate rows are eliminated.
288union
293union
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+5
@@ -119,6 +119,8 @@ module Squeal.PostgreSQL.Schema
119 , RecordCodeOf
119 , RecordCodeOf
120 , MapMaybes (..)
120 , MapMaybes (..)
121 , Nulls
121 , Nulls
122+ , ParamsFrom
123+ , ResultFrom
122 ) where
124 ) where
123
125
124import Control.DeepSeq
126import Control.DeepSeq
@@ -837,3 +839,6 @@ type family RecordCodeOf (hask :: Type) (code ::[[Type]]) :: [Type] where
837 RecordCodeOf _hask '[tys] = tys
839 RecordCodeOf _hask '[tys] = tys
838 RecordCodeOf hask _tys = TypeError
840 RecordCodeOf hask _tys = TypeError
839 ('Text "RecordCodeOf error: non-Record type " ':<>: 'ShowType hask)
841 ('Text "RecordCodeOf error: non-Record type " ':<>: 'ShowType hask)
842+
843+type family ParamsFrom (hask :: Type) :: [NullityType]
844+type family ResultFrom (hask :: Type) :: RelationType