on dev help sign in
remove non nil scrapping experimental code
commit3b15f1095fc1c06c38148b36921342bfe03d985d authorEitan Chatav <eitan.chatav@gmail.com> dateSat 7 Jul 2018, 10:28 (8 years ago) parent3700762
2 files changed+2−37
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs−28 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+2−9
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs−28
@@ -27,9 +27,6 @@ Squeal queries.
2727module Squeal.PostgreSQL.Query
2828 ( -- * Queries
2929 Query (UnsafeQuery, renderQuery)
30− , Query'
31− , QueryFrom (..)
32− , queryFrom
3330 , union
3431 , unionAll
3532 , intersect
@@ -79,9 +76,7 @@ module Squeal.PostgreSQL.Query
7976
8077import Control.DeepSeq
8178import Data.ByteString (ByteString)
82−import Data.Kind
8379import Data.Monoid hiding (All)
84−import Data.Profunctor
8580import Data.String
8681import Data.Word
8782import Generics.SOP hiding (from)
@@ -89,7 +84,6 @@ import GHC.TypeLits
8984
9085import qualified GHC.Generics as GHC
9186
92−import Squeal.PostgreSQL.Binary
9387import Squeal.PostgreSQL.Expression
9488import Squeal.PostgreSQL.Render
9589import Squeal.PostgreSQL.Schema
@@ -293,28 +287,6 @@ newtype Query
293287 deriving (GHC.Generic,Show,Eq,Ord,NFData)
294288instance RenderSQL (Query schema params columns) where renderSQL = renderQuery
295289
296−data QueryFrom
297− (schema :: SchemaType)
298− (x :: Type)
299− (y :: Type)
300− where
301− QueryFrom
302− :: (x -> NP (K (Maybe ByteString)) params)
303− -> Query schema params result
304− -> (NP (K (Maybe ByteString)) result -> y)
305− -> QueryFrom schema x y
306−instance Profunctor (QueryFrom schema) where
307− dimap f g (QueryFrom params q result) = QueryFrom (params.f) q (g.result)
308−
309−queryFrom
310− :: (ToParams x (ParamsFrom x), FromRow (ResultFrom y) y)
311− => Query schema (ParamsFrom x) (ResultFrom y)
312− -> QueryFrom schema x y
313−queryFrom q = QueryFrom toParams q fromRow
314−
315−type family Query' schema x y where
316− Query' schema x y = Query schema (ParamsFrom x) (ResultFrom y)
317−
318290-- | The results of two queries can be combined using the set operation
319291-- `union`. Duplicate rows are eliminated.
320292union
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+2−9
@@ -120,8 +120,6 @@ module Squeal.PostgreSQL.Schema
120120 , RecordCodeOf
121121 , MapMaybes (..)
122122 , Nulls
123− , ParamsFrom
124− , ResultFrom
125123 ) where
126124
127125import Control.DeepSeq
@@ -402,11 +400,12 @@ instance (alias0 ~ alias1, alias0 ~ alias2, KnownSymbol alias2)
402400 => IsLabel alias0 (Aliased Alias (alias1 ::: alias2)) where
403401 fromLabel = fromLabel @alias2 `As` fromLabel @alias1
404402
403+-- | The `Aliasable` class provides a way to scrap your `Nil`s
404+-- in an `NP` list of `Aliased` expressions.
405405class KnownSymbol alias => Aliasable alias expression aliased
406406 | aliased -> expression
407407 , aliased -> alias
408408 where as :: expression -> Alias alias -> aliased
409−
410409instance (alias ~ alias1, KnownSymbol alias) => Aliasable alias
411410 (expression ty)
412411 (Aliased expression (alias1 ::: ty))
@@ -866,9 +865,3 @@ type family RecordCodeOf (hask :: Type) (code ::[[Type]]) :: [Type] where
866865 RecordCodeOf _hask '[tys] = tys
867866 RecordCodeOf hask _tys = TypeError
868867 ('Text "RecordCodeOf error: non-Record type " ':<>: 'ShowType hask)
869−
870−type family ParamsFrom (hask :: Type) :: [NullityType] where
871− ParamsFrom hask = NullityTypesOf (RecordCodeOf hask (Code hask))
872−
873−type family ResultFrom (hask :: Type) :: RelationType where
874− ResultFrom hask = ZipAs (FieldNamesFrom hask) (ParamsFrom hask)