{-# language FlexibleContexts #-}
{-# language MonoLocalBinds #-}
module Rel8.Query.Each
( each
)
where
import Prelude
import qualified Opaleye.Table as Opaleye
import Rel8.Query ( Query )
import Rel8.Query.Opaleye ( fromOpaleye )
import Rel8.Schema.Name ( Selects )
import Rel8.Schema.Table ( TableSchema )
import Rel8.Table ( fromColumns, toColumns )
import Rel8.Table.Opaleye ( table, unpackspec )
each :: Selects names exprs => TableSchema names -> Query exprs
each :: TableSchema names -> Query exprs
each =
(Columns exprs (Col Expr) -> exprs)
-> Query (Columns exprs (Col Expr)) -> Query exprs
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Columns exprs (Col Expr) -> exprs
forall (context :: Context) a.
Table context a =>
Columns a (Col context) -> a
fromColumns (Query (Columns exprs (Col Expr)) -> Query exprs)
-> (TableSchema names -> Query (Columns exprs (Col Expr)))
-> TableSchema names
-> Query exprs
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Select (Columns exprs (Col Expr))
-> Query (Columns exprs (Col Expr))
forall a. Select a -> Query a
fromOpaleye (Select (Columns exprs (Col Expr))
-> Query (Columns exprs (Col Expr)))
-> (TableSchema names -> Select (Columns exprs (Col Expr)))
-> TableSchema names
-> Query (Columns exprs (Col Expr))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
Unpackspec (Columns exprs (Col Expr)) (Columns exprs (Col Expr))
-> Table (Columns exprs (Col Insert)) (Columns exprs (Col Expr))
-> Select (Columns exprs (Col Expr))
forall tablefields fields a.
Unpackspec tablefields fields
-> Table a tablefields -> Select fields
Opaleye.selectTableExplicit Unpackspec (Columns exprs (Col Expr)) (Columns exprs (Col Expr))
forall a. Table Expr a => Unpackspec a a
unpackspec (Table (Columns exprs (Col Insert)) (Columns exprs (Col Expr))
-> Select (Columns exprs (Col Expr)))
-> (TableSchema names
-> Table (Columns exprs (Col Insert)) (Columns exprs (Col Expr)))
-> TableSchema names
-> Select (Columns exprs (Col Expr))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
TableSchema (Columns exprs (Col Name))
-> Table (Columns exprs (Col Insert)) (Columns exprs (Col Expr))
forall names exprs inserts.
(Selects names exprs, Inserts exprs inserts) =>
TableSchema names -> Table inserts exprs
table (TableSchema (Columns exprs (Col Name))
-> Table (Columns exprs (Col Insert)) (Columns exprs (Col Expr)))
-> (TableSchema names -> TableSchema (Columns exprs (Col Name)))
-> TableSchema names
-> Table (Columns exprs (Col Insert)) (Columns exprs (Col Expr))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
(names -> Columns exprs (Col Name))
-> TableSchema names -> TableSchema (Columns exprs (Col Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap names -> Columns exprs (Col Name)
forall (context :: Context) a.
Table context a =>
a -> Columns a (Col context)
toColumns