on dev help sign in
trying stuff
commit28cc574f035a14a186c707b18274a018990f3378 authorEitan Chatav <eitan.chatav@gmail.com> dateThu 28 Jun 2018, 15:07 (8 years ago) parent3cf3dc3
2 files changed+10
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+5 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+5
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+5
@@ -16,6 +16,7 @@ Squeal queries.
1616 , LambdaCase
1717 , OverloadedStrings
1818 , StandaloneDeriving
19+ , TypeFamilies
1920 , TypeInType
2021 , TypeOperators
2122#-}
@@ -23,6 +24,7 @@ Squeal queries.
2324module Squeal.PostgreSQL.Query
2425 ( -- * Queries
2526 Query (UnsafeQuery, renderQuery)
27+ , Query'
2628 , union
2729 , unionAll
2830 , intersect
@@ -283,6 +285,9 @@ newtype Query
283285 deriving (GHC.Generic,Show,Eq,Ord,NFData)
284286instance RenderSQL (Query schema params columns) where renderSQL = renderQuery
285287
288+type family Query' schema x y where
289+ Query' schema x y = Query schema (ParamsFrom x) (ResultFrom y)
290+
286291-- | The results of two queries can be combined using the set operation
287292-- `union`. Duplicate rows are eliminated.
288293union
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+5
@@ -119,6 +119,8 @@ module Squeal.PostgreSQL.Schema
119119 , RecordCodeOf
120120 , MapMaybes (..)
121121 , Nulls
122+ , ParamsFrom
123+ , ResultFrom
122124 ) where
123125
124126import Control.DeepSeq
@@ -837,3 +839,6 @@ type family RecordCodeOf (hask :: Type) (code ::[[Type]]) :: [Type] where
837839 RecordCodeOf _hask '[tys] = tys
838840 RecordCodeOf hask _tys = TypeError
839841 ('Text "RecordCodeOf error: non-Record type " ':<>: 'ShowType hask)
842+
843+type family ParamsFrom (hask :: Type) :: [NullityType]
844+type family ResultFrom (hask :: Type) :: RelationType