{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors#-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE CPP #-}

module Database.Beam.Query.Internal where

import           Database.Beam.Backend.Types
import           Database.Beam.Backend.SQL
import           Database.Beam.Schema.Tables

import qualified Data.DList as DList
import           Data.Functor.Const
import           Data.String
import qualified Data.Text as T
import           Data.Typeable
import           Data.Vector.Sized (Vector)
import qualified Data.Vector.Sized as VS
#if !MIN_VERSION_base(4, 11, 0)
import           Data.Semigroup
#endif

import           Control.Monad.Free.Church
import           Control.Monad.State
import           Control.Monad.Writer

import           GHC.TypeLits
import           GHC.Types

import           Unsafe.Coerce

type ProjectibleInBackend be a =
  ( Projectible be a
  , ProjectibleValue be a )

type TablePrefix = T.Text

data QF be (db :: (Type -> Type) -> Type) s next where
  QDistinct :: Projectible be r
            => (r -> WithExprContext (BeamSqlBackendSetQuantifierSyntax be))
            -> QM be db s r -> (r -> next) -> QF be db s next

  QAll :: Projectible be r
       => (TablePrefix -> T.Text -> BeamSqlBackendFromSyntax be)
       -> (T.Text -> r)
       -> (r -> Maybe (WithExprContext (BeamSqlBackendExpressionSyntax be)))
       -> ((T.Text, r) -> next) -> QF be db s next

  QArbitraryJoin :: Projectible be r
                 => QM be db (QNested s) r
                 -> T.Text -- Table namespace
                 -> (BeamSqlBackendFromSyntax be -> BeamSqlBackendFromSyntax be ->
                     Maybe (BeamSqlBackendExpressionSyntax be) ->
                     BeamSqlBackendFromSyntax be)
                 -> (r -> Maybe (WithExprContext (BeamSqlBackendExpressionSyntax be)))
                 -> (r -> next)
                 -> QF be db s next
  QTwoWayJoin :: ( Projectible be a
                 , Projectible be b )
              => QM be db (QNested s) a
              -> QM be db (QNested s) b
              -> (BeamSqlBackendFromSyntax be -> BeamSqlBackendFromSyntax be ->
                  Maybe (BeamSqlBackendExpressionSyntax be) ->
                  BeamSqlBackendFromSyntax be)
              -> ((a, b) -> Maybe (WithExprContext (BeamSqlBackendExpressionSyntax be)))
              -> ((a, b) -> next)
              -> QF be db s next

  QSubSelect :: Projectible be r
             => QM be db (QNested s) r -> (r -> next)
             -> QF be db s next

  QGuard :: WithExprContext (BeamSqlBackendExpressionSyntax be) -> next -> QF be db s next

  QLimit  :: Projectible be r => Integer -> QM be db (QNested s) r -> (r -> next) -> QF be db s next
  QOffset :: Projectible be r => Integer -> QM be db (QNested s) r -> (r -> next) -> QF be db s next

  QSetOp :: Projectible be r
         => (BeamSqlBackendSelectTableSyntax be -> BeamSqlBackendSelectTableSyntax be -> BeamSqlBackendSelectTableSyntax be)
         -> QM be db (QNested s) r
         -> QM be db (QNested s) r -> (r -> next)
         -> QF be db s next

  QOrderBy :: Projectible be r
           => (r -> WithExprContext [ BeamSqlBackendOrderingSyntax be ])
           -> QM be db (QNested s) r -> (r -> next) -> QF be db s next

  QWindowOver :: ( ProjectibleWithPredicate WindowFrameContext be (WithExprContext (BeamSqlBackendWindowFrameSyntax' be)) window
                 , Projectible be r
                 , Projectible be a )
              => (r -> window) -> (r -> window -> a)
              -> QM be db (QNested s) r -> (a -> next) -> QF be db s next

  QAggregate :: ( Projectible be grouping
                , Projectible be a )
             => (a -> TablePrefix -> (Maybe (BeamSqlBackendGroupingSyntax be), grouping))
             -> QM be db (QNested s) a
             -> (grouping -> next)
             -> QF be db s next

  -- Force the building of a select statement, using the given builder
  QForceSelect :: Projectible be r
               => (r -> BeamSqlBackendSelectTableSyntax be -> [ BeamSqlBackendOrderingSyntax be ] ->
                   Maybe Integer -> Maybe Integer -> BeamSqlBackendSelectSyntax be)
               -> QM be db (QNested s) r
               -> (r -> next)
               -> QF be db s next

deriving instance Functor (QF be db s)

type QM be db s = F (QF be db s)

-- | The type of queries over the database `db` returning results of type `a`.
-- The `s` argument is a threading argument meant to restrict cross-usage of
-- `QExpr`s. 'syntax' represents the SQL syntax that this query is building.
newtype Q be (db :: (Type -> Type) -> Type) s a
  = Q { forall be (db :: (* -> *) -> *) s a. Q be db s a -> QM be db s a
runQ :: QM be db s a }
    deriving (forall a. a -> Q be db s a
forall a b. Q be db s a -> Q be db s b -> Q be db s b
forall a b. Q be db s a -> (a -> Q be db s b) -> Q be db s b
forall {be} {db :: (* -> *) -> *} {s}. Applicative (Q be db s)
forall be (db :: (* -> *) -> *) s a. a -> Q be db s a
forall be (db :: (* -> *) -> *) s a b.
Q be db s a -> Q be db s b -> Q be db s b
forall be (db :: (* -> *) -> *) s a b.
Q be db s a -> (a -> Q be db s b) -> Q be db s b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: forall a. a -> Q be db s a
$creturn :: forall be (db :: (* -> *) -> *) s a. a -> Q be db s a
>> :: forall a b. Q be db s a -> Q be db s b -> Q be db s b
$c>> :: forall be (db :: (* -> *) -> *) s a b.
Q be db s a -> Q be db s b -> Q be db s b
>>= :: forall a b. Q be db s a -> (a -> Q be db s b) -> Q be db s b
$c>>= :: forall be (db :: (* -> *) -> *) s a b.
Q be db s a -> (a -> Q be db s b) -> Q be db s b
Monad, forall a. a -> Q be db s a
forall a b. Q be db s a -> Q be db s b -> Q be db s a
forall a b. Q be db s a -> Q be db s b -> Q be db s b
forall a b. Q be db s (a -> b) -> Q be db s a -> Q be db s b
forall a b c.
(a -> b -> c) -> Q be db s a -> Q be db s b -> Q be db s c
forall {be} {db :: (* -> *) -> *} {s}. Functor (Q be db s)
forall be (db :: (* -> *) -> *) s a. a -> Q be db s a
forall be (db :: (* -> *) -> *) s a b.
Q be db s a -> Q be db s b -> Q be db s a
forall be (db :: (* -> *) -> *) s a b.
Q be db s a -> Q be db s b -> Q be db s b
forall be (db :: (* -> *) -> *) s a b.
Q be db s (a -> b) -> Q be db s a -> Q be db s b
forall be (db :: (* -> *) -> *) s a b c.
(a -> b -> c) -> Q be db s a -> Q be db s b -> Q be db s c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: forall a b. Q be db s a -> Q be db s b -> Q be db s a
$c<* :: forall be (db :: (* -> *) -> *) s a b.
Q be db s a -> Q be db s b -> Q be db s a
*> :: forall a b. Q be db s a -> Q be db s b -> Q be db s b
$c*> :: forall be (db :: (* -> *) -> *) s a b.
Q be db s a -> Q be db s b -> Q be db s b
liftA2 :: forall a b c.
(a -> b -> c) -> Q be db s a -> Q be db s b -> Q be db s c
$cliftA2 :: forall be (db :: (* -> *) -> *) s a b c.
(a -> b -> c) -> Q be db s a -> Q be db s b -> Q be db s c
<*> :: forall a b. Q be db s (a -> b) -> Q be db s a -> Q be db s b
$c<*> :: forall be (db :: (* -> *) -> *) s a b.
Q be db s (a -> b) -> Q be db s a -> Q be db s b
pure :: forall a. a -> Q be db s a
$cpure :: forall be (db :: (* -> *) -> *) s a. a -> Q be db s a
Applicative, forall a b. a -> Q be db s b -> Q be db s a
forall a b. (a -> b) -> Q be db s a -> Q be db s b
forall be (db :: (* -> *) -> *) s a b.
a -> Q be db s b -> Q be db s a
forall be (db :: (* -> *) -> *) s a b.
(a -> b) -> Q be db s a -> Q be db s b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Q be db s b -> Q be db s a
$c<$ :: forall be (db :: (* -> *) -> *) s a b.
a -> Q be db s b -> Q be db s a
fmap :: forall a b. (a -> b) -> Q be db s a -> Q be db s b
$cfmap :: forall be (db :: (* -> *) -> *) s a b.
(a -> b) -> Q be db s a -> Q be db s b
Functor)

data QInternal
data QNested s

data QField s ty
  = QField
  { forall s ty. QField s ty -> Bool
qFieldShouldQualify :: !Bool
  , forall s ty. QField s ty -> Text
qFieldTblName       :: !T.Text
  , forall s ty. QField s ty -> Text
qFieldName          :: !T.Text }
  deriving (Int -> QField s ty -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall s ty. Int -> QField s ty -> ShowS
forall s ty. [QField s ty] -> ShowS
forall s ty. QField s ty -> String
showList :: [QField s ty] -> ShowS
$cshowList :: forall s ty. [QField s ty] -> ShowS
show :: QField s ty -> String
$cshow :: forall s ty. QField s ty -> String
showsPrec :: Int -> QField s ty -> ShowS
$cshowsPrec :: forall s ty. Int -> QField s ty -> ShowS
Show, QField s ty -> QField s ty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall s ty. QField s ty -> QField s ty -> Bool
/= :: QField s ty -> QField s ty -> Bool
$c/= :: forall s ty. QField s ty -> QField s ty -> Bool
== :: QField s ty -> QField s ty -> Bool
$c== :: forall s ty. QField s ty -> QField s ty -> Bool
Eq, QField s ty -> QField s ty -> Bool
QField s ty -> QField s ty -> Ordering
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall s ty. Eq (QField s ty)
forall s ty. QField s ty -> QField s ty -> Bool
forall s ty. QField s ty -> QField s ty -> Ordering
forall s ty. QField s ty -> QField s ty -> QField s ty
min :: QField s ty -> QField s ty -> QField s ty
$cmin :: forall s ty. QField s ty -> QField s ty -> QField s ty
max :: QField s ty -> QField s ty -> QField s ty
$cmax :: forall s ty. QField s ty -> QField s ty -> QField s ty
>= :: QField s ty -> QField s ty -> Bool
$c>= :: forall s ty. QField s ty -> QField s ty -> Bool
> :: QField s ty -> QField s ty -> Bool
$c> :: forall s ty. QField s ty -> QField s ty -> Bool
<= :: QField s ty -> QField s ty -> Bool
$c<= :: forall s ty. QField s ty -> QField s ty -> Bool
< :: QField s ty -> QField s ty -> Bool
$c< :: forall s ty. QField s ty -> QField s ty -> Bool
compare :: QField s ty -> QField s ty -> Ordering
$ccompare :: forall s ty. QField s ty -> QField s ty -> Ordering
Ord)

newtype QAssignment be s
  = QAssignment { forall be s.
QAssignment be s
-> [(BeamSqlBackendFieldNameSyntax be,
     BeamSqlBackendExpressionSyntax be)]
unQAssignment :: [(BeamSqlBackendFieldNameSyntax be, BeamSqlBackendExpressionSyntax be)] }
  deriving (QAssignment be s
[QAssignment be s] -> QAssignment be s
QAssignment be s -> QAssignment be s -> QAssignment be s
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall {be} {s}. Semigroup (QAssignment be s)
forall be s. QAssignment be s
forall be s. [QAssignment be s] -> QAssignment be s
forall be s.
QAssignment be s -> QAssignment be s -> QAssignment be s
mconcat :: [QAssignment be s] -> QAssignment be s
$cmconcat :: forall be s. [QAssignment be s] -> QAssignment be s
mappend :: QAssignment be s -> QAssignment be s -> QAssignment be s
$cmappend :: forall be s.
QAssignment be s -> QAssignment be s -> QAssignment be s
mempty :: QAssignment be s
$cmempty :: forall be s. QAssignment be s
Monoid, NonEmpty (QAssignment be s) -> QAssignment be s
QAssignment be s -> QAssignment be s -> QAssignment be s
forall b. Integral b => b -> QAssignment be s -> QAssignment be s
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall be s. NonEmpty (QAssignment be s) -> QAssignment be s
forall be s.
QAssignment be s -> QAssignment be s -> QAssignment be s
forall be s b.
Integral b =>
b -> QAssignment be s -> QAssignment be s
stimes :: forall b. Integral b => b -> QAssignment be s -> QAssignment be s
$cstimes :: forall be s b.
Integral b =>
b -> QAssignment be s -> QAssignment be s
sconcat :: NonEmpty (QAssignment be s) -> QAssignment be s
$csconcat :: forall be s. NonEmpty (QAssignment be s) -> QAssignment be s
<> :: QAssignment be s -> QAssignment be s -> QAssignment be s
$c<> :: forall be s.
QAssignment be s -> QAssignment be s -> QAssignment be s
Semigroup)

newtype QFieldAssignment be tbl a
  = QFieldAssignment (forall s. tbl (QExpr be s) -> Maybe (QExpr be s a))

-- * QGenExpr type

data QAggregateContext
data QGroupingContext
data QValueContext
data QWindowingContext
data QWindowFrameContext

-- | The type of lifted beam expressions that will yield the haskell type 't'.
--
--   'context' is a type-level representation of the types of expressions this
--   can contain. For example, 'QAggregateContext' represents expressions that
--   may contain aggregates, and 'QWindowingContext' represents expressions that
--   may contain @OVER@.
--
--   'syntax' is the expression syntax being built (usually a type that
--   implements 'IsSql92ExpressionSyntax' at least, but not always).
--
--   's' is a state threading parameter that prevents 'QExpr's from incompatible
--   sources to be combined. For example, this is used to prevent monadic joins
--   from depending on the result of previous joins (so-called @LATERAL@ joins).
newtype QGenExpr context be s t = QExpr (TablePrefix -> BeamSqlBackendExpressionSyntax be)
newtype QOrd be s t = QOrd (TablePrefix -> BeamSqlBackendOrderingSyntax be)

type WithExprContext a = TablePrefix -> a

-- | 'QExpr's represent expressions not containing aggregates.
type QExpr = QGenExpr QValueContext
type QAgg = QGenExpr QAggregateContext
type QWindowExpr = QGenExpr QWindowingContext
type QGroupExpr = QGenExpr QGroupingContext
--deriving instance Show syntax => Show (QGenExpr context syntax s t)
instance BeamSqlBackend be => Eq (QGenExpr context be s t) where
  QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a == :: QGenExpr context be s t -> QGenExpr context be s t -> Bool
== QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b = Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a Text
"" forall a. Eq a => a -> a -> Bool
== Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b Text
""

instance Retaggable (QGenExpr ctxt expr s) (QGenExpr ctxt expr s t) where
  type Retag tag (QGenExpr ctxt expr s t) = Columnar (tag (QGenExpr ctxt expr s)) t
  retag :: forall (tag :: (* -> *) -> * -> *).
(forall a.
 Columnar' (QGenExpr ctxt expr s) a
 -> Columnar' (tag (QGenExpr ctxt expr s)) a)
-> QGenExpr ctxt expr s t -> Retag tag (QGenExpr ctxt expr s t)
retag forall a.
Columnar' (QGenExpr ctxt expr s) a
-> Columnar' (tag (QGenExpr ctxt expr s)) a
f QGenExpr ctxt expr s t
e = case forall a.
Columnar' (QGenExpr ctxt expr s) a
-> Columnar' (tag (QGenExpr ctxt expr s)) a
f (forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' QGenExpr ctxt expr s t
e) of
                Columnar' Columnar (tag (QGenExpr ctxt expr s)) t
a -> Columnar (tag (QGenExpr ctxt expr s)) t
a

newtype QWindow be s = QWindow (WithExprContext (BeamSqlBackendWindowFrameSyntax be))
newtype QFrameBounds be = QFrameBounds (Maybe (BeamSqlBackendWindowFrameBoundsSyntax be))
newtype QFrameBound be = QFrameBound (BeamSqlBackendWindowFrameBoundSyntax be)

qBinOpE :: BeamSqlBackend be
        => (BeamSqlBackendExpressionSyntax be ->
            BeamSqlBackendExpressionSyntax be ->
            BeamSqlBackendExpressionSyntax be)
        -> QGenExpr context be s a -> QGenExpr context be s b
        -> QGenExpr context be s c
qBinOpE :: forall be context s a b c.
BeamSqlBackend be =>
(BeamSqlBackendExpressionSyntax be
 -> BeamSqlBackendExpressionSyntax be
 -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s a
-> QGenExpr context be s b
-> QGenExpr context be s c
qBinOpE Sql92SelectTableExpressionSyntax
  (Sql92SelectSelectTableSyntax
     (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
mkOpE (QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a) (QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b) = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (Sql92SelectTableExpressionSyntax
  (Sql92SelectSelectTableSyntax
     (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
mkOpE forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b)

unsafeRetype :: QGenExpr ctxt be s a -> QGenExpr ctxt be s a'
unsafeRetype :: forall ctxt be s a a'.
QGenExpr ctxt be s a -> QGenExpr ctxt be s a'
unsafeRetype (QExpr Text -> BeamSqlBackendExpressionSyntax be
v) = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr Text -> BeamSqlBackendExpressionSyntax be
v

instance ( BeamSqlBackend backend, BeamSqlBackendCanSerialize backend [Char] ) =>
    IsString (QGenExpr context backend s T.Text) where
    fromString :: String -> QGenExpr context backend s Text
fromString = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall expr.
IsSql92ExpressionSyntax expr =>
Sql92ExpressionValueSyntax expr -> expr
valueE forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall expr ty. HasSqlValueSyntax expr ty => ty -> expr
sqlValueSyntax
instance ( Num a, BeamSqlBackend be, BeamSqlBackendCanSerialize be a ) =>
    Num (QGenExpr context be s a) where
    fromInteger :: Integer -> QGenExpr context be s a
fromInteger Integer
x = let res :: QGenExpr context be s a
                        res :: QGenExpr context be s a
res = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall expr.
IsSql92ExpressionSyntax expr =>
Sql92ExpressionValueSyntax expr -> expr
valueE (forall expr ty. HasSqlValueSyntax expr ty => ty -> expr
sqlValueSyntax (forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
x :: a))))
                    in QGenExpr context be s a
res
    QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a + :: QGenExpr context be s a
-> QGenExpr context be s a -> QGenExpr context be s a
+ QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (forall expr. IsSql92ExpressionSyntax expr => expr -> expr -> expr
addE forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b)
    QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a - :: QGenExpr context be s a
-> QGenExpr context be s a -> QGenExpr context be s a
- QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (forall expr. IsSql92ExpressionSyntax expr => expr -> expr -> expr
subE forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b)
    QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a * :: QGenExpr context be s a
-> QGenExpr context be s a -> QGenExpr context be s a
* QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (forall expr. IsSql92ExpressionSyntax expr => expr -> expr -> expr
mulE forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b)
    negate :: QGenExpr context be s a -> QGenExpr context be s a
negate (QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a) = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (forall expr. IsSql92ExpressionSyntax expr => expr -> expr
negateE forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a)
    abs :: QGenExpr context be s a -> QGenExpr context be s a
abs (QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
x) = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (forall expr. IsSql92ExpressionSyntax expr => expr -> expr
absE forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
x)
    signum :: QGenExpr context be s a -> QGenExpr context be s a
signum QGenExpr context be s a
_ = forall a. HasCallStack => String -> a
error String
"signum: not defined for QExpr. Use CASE...WHEN"

instance ( Fractional a, BeamSqlBackend be, BeamSqlBackendCanSerialize be a ) =>
  Fractional (QGenExpr context be s a) where

  QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a / :: QGenExpr context be s a
-> QGenExpr context be s a -> QGenExpr context be s a
/ QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (forall expr. IsSql92ExpressionSyntax expr => expr -> expr -> expr
divE forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
b)
  recip :: QGenExpr context be s a -> QGenExpr context be s a
recip = (QGenExpr context be s a
1.0 forall a. Fractional a => a -> a -> a
/)

  fromRational :: Rational -> QGenExpr context be s a
fromRational = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall expr.
IsSql92ExpressionSyntax expr =>
Sql92ExpressionValueSyntax expr -> expr
valueE forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall expr ty. HasSqlValueSyntax expr ty => ty -> expr
sqlValueSyntax forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. a -> a
id :: a -> a) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Fractional a => Rational -> a
fromRational

-- * Sql Projections
--

-- | Typeclass for all haskell data types that can be used to create a projection in a SQL select
-- statement. This includes all tables as well as all tuple classes. Projections are only defined on
-- tuples up to size 5. If you need more, follow the implementations here.

class Typeable context => AggregateContext context
instance (IsAggregateContext a, Typeable a) => AggregateContext a

type family ContextName a :: Symbol
type instance ContextName QValueContext = "a value"
type instance ContextName QWindowingContext = "a window expression"
type instance ContextName QWindowFrameContext = "a window frame"
type instance ContextName QAggregateContext = "an aggregate"
type instance ContextName QGroupingContext = "an aggregate grouping"

type family IsAggregateContext a :: Constraint where
    IsAggregateContext QAggregateContext = ()
    IsAggregateContext QGroupingContext = ()
    IsAggregateContext a = TypeError ('Text "Non-aggregate expression where aggregate expected." :$$:
                                      ('Text "Got " :<>: 'Text (ContextName a) :<>: 'Text ". Expected an aggregate or a grouping") :$$:
                                      AggregateContextSuggestion a)

type family AggregateContextSuggestion a :: ErrorMessage where
    AggregateContextSuggestion QValueContext = 'Text "Perhaps you forgot to wrap a value expression with 'group_'"
    AggregateContextSuggestion QWindowingContext = 'Text "Perhaps you meant to use 'window_' instead of 'aggregate_'"
    AggregateContextSuggestion b = 'Text ""

class Typeable context => ValueContext context
instance (IsValueContext a, Typeable a, a ~ QValueContext) => ValueContext a

class Typeable context => WindowFrameContext context
instance (Typeable context, IsWindowFrameContext context, context ~ QWindowFrameContext) =>
  WindowFrameContext context

type family IsWindowFrameContext a :: Constraint where
  IsWindowFrameContext QWindowFrameContext = ()
  IsWindowFrameContext a = TypeError ('Text "Expected window frame." :$$:
                                      ('Text "Got " :<>: 'Text (ContextName a) :<>: 'Text ". Expected a window frame"))

class AnyType a
instance AnyType a

type family IsValueContext a :: Constraint where
    IsValueContext QValueContext = ()
    IsValueContext a = TypeError ('Text "Non-scalar context in projection" :$$:
                                  ('Text "Got " :<>: 'Text (ContextName a) :<>: 'Text ". Expected a value") :$$:
                                  ValueContextSuggestion a)

type family ValueContextSuggestion a :: ErrorMessage where
    ValueContextSuggestion QWindowingContext = 'Text "Use 'window_' to projecct aggregate expressions to the value level"
    ValueContextSuggestion QAggregateContext = ('Text "Aggregate functions and groupings cannot be contained in value expressions." :$$:
                                                'Text "Use 'aggregate_' to compute aggregations at the value level.")
    ValueContextSuggestion QGroupingContext = ValueContextSuggestion QAggregateContext
    ValueContextSuggestion _ = 'Text ""

type Projectible be = ProjectibleWithPredicate AnyType be (WithExprContext (BeamSqlBackendExpressionSyntax' be))
type ProjectibleValue be = ProjectibleWithPredicate ValueContext be (WithExprContext (BeamSqlBackendExpressionSyntax' be))

class ThreadRewritable (s :: Type) (a :: Type) | a -> s where
  type WithRewrittenThread s (s' :: Type) a :: Type

  rewriteThread :: Proxy s' -> a -> WithRewrittenThread s s' a
instance Beamable tbl => ThreadRewritable s (tbl (QGenExpr ctxt syntax s)) where
  type WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) = tbl (QGenExpr ctxt syntax s')
  rewriteThread :: forall s'.
Proxy s'
-> tbl (QGenExpr ctxt syntax s)
-> WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s))
rewriteThread Proxy s'
_ = forall (table :: (* -> *) -> *) (f :: * -> *) (g :: * -> *).
Beamable table =>
(forall a. Columnar' f a -> Columnar' g a) -> table f -> table g
changeBeamRep (\(Columnar' (QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a)) -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' (forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a))
instance Beamable tbl => ThreadRewritable s (tbl (Nullable (QGenExpr ctxt syntax s))) where
  type WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) = tbl (Nullable (QGenExpr ctxt syntax s'))
  rewriteThread :: forall s'.
Proxy s'
-> tbl (Nullable (QGenExpr ctxt syntax s))
-> WithRewrittenThread
     s s' (tbl (Nullable (QGenExpr ctxt syntax s)))
rewriteThread Proxy s'
_ = forall (table :: (* -> *) -> *) (f :: * -> *) (g :: * -> *).
Beamable table =>
(forall a. Columnar' f a -> Columnar' g a) -> table f -> table g
changeBeamRep (\(Columnar' (QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a)) -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' (forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a))
instance ThreadRewritable s (QGenExpr ctxt syntax s a) where
  type WithRewrittenThread s s' (QGenExpr ctxt syntax s a) = QGenExpr ctxt syntax s' a
  rewriteThread :: forall s'.
Proxy s'
-> QGenExpr ctxt syntax s a
-> WithRewrittenThread s s' (QGenExpr ctxt syntax s a)
rewriteThread Proxy s'
_ (QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a) = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a
instance ThreadRewritable s a => ThreadRewritable s [a] where
  type WithRewrittenThread s s' [a] = [WithRewrittenThread s s' a]
  rewriteThread :: forall s'. Proxy s' -> [a] -> WithRewrittenThread s s' [a]
rewriteThread Proxy s'
s' [a]
qs = forall a b. (a -> b) -> [a] -> [b]
map (forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s') [a]
qs
instance (ThreadRewritable s a, KnownNat n) => ThreadRewritable s (Vector n a) where
  type WithRewrittenThread s s' (Vector n a) = Vector n (WithRewrittenThread s s' a)
  rewriteThread :: forall s'.
Proxy s' -> Vector n a -> WithRewrittenThread s s' (Vector n a)
rewriteThread Proxy s'
s' Vector n a
qs = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s') Vector n a
qs
instance ( ThreadRewritable s a, ThreadRewritable s b ) =>
  ThreadRewritable s (a, b) where
  type WithRewrittenThread s s' (a, b) = (WithRewrittenThread s s' a, WithRewrittenThread s s' b)
  rewriteThread :: forall s'. Proxy s' -> (a, b) -> WithRewrittenThread s s' (a, b)
rewriteThread Proxy s'
s' (a
a, b
b) = (forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' a
a, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' b
b)
instance ( ThreadRewritable s a, ThreadRewritable s b, ThreadRewritable s c ) =>
  ThreadRewritable s (a, b, c) where
  type WithRewrittenThread s s' (a, b, c) =
    (WithRewrittenThread s s' a, WithRewrittenThread s s' b, WithRewrittenThread s s' c)
  rewriteThread :: forall s'.
Proxy s' -> (a, b, c) -> WithRewrittenThread s s' (a, b, c)
rewriteThread Proxy s'
s' (a
a, b
b, c
c) = (forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' a
a, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' b
b, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' c
c)
instance ( ThreadRewritable s a, ThreadRewritable s b, ThreadRewritable s c, ThreadRewritable s d ) =>
  ThreadRewritable s (a, b, c, d) where
  type WithRewrittenThread s s' (a, b, c, d) =
    (WithRewrittenThread s s' a, WithRewrittenThread s s' b, WithRewrittenThread s s' c, WithRewrittenThread s s' d)
  rewriteThread :: forall s'.
Proxy s' -> (a, b, c, d) -> WithRewrittenThread s s' (a, b, c, d)
rewriteThread Proxy s'
s' (a
a, b
b, c
c, d
d) =
    (forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' a
a, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' b
b, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' c
c, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' d
d)
instance ( ThreadRewritable s a, ThreadRewritable s b, ThreadRewritable s c, ThreadRewritable s d
         , ThreadRewritable s e ) =>
  ThreadRewritable s (a, b, c, d, e) where
  type WithRewrittenThread s s' (a, b, c, d, e) =
    ( WithRewrittenThread s s' a, WithRewrittenThread s s' b, WithRewrittenThread s s' c, WithRewrittenThread s s' d
    , WithRewrittenThread s s' e )
  rewriteThread :: forall s'.
Proxy s'
-> (a, b, c, d, e) -> WithRewrittenThread s s' (a, b, c, d, e)
rewriteThread Proxy s'
s' (a
a, b
b, c
c, d
d, e
e) =
    ( forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' a
a, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' b
b, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' c
c, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' d
d
    , forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' e
e)
instance ( ThreadRewritable s a, ThreadRewritable s b, ThreadRewritable s c, ThreadRewritable s d
         , ThreadRewritable s e, ThreadRewritable s f ) =>
  ThreadRewritable s (a, b, c, d, e, f) where
  type WithRewrittenThread s s' (a, b, c, d, e, f) =
    ( WithRewrittenThread s s' a, WithRewrittenThread s s' b, WithRewrittenThread s s' c, WithRewrittenThread s s' d
    , WithRewrittenThread s s' e, WithRewrittenThread s s' f )
  rewriteThread :: forall s'.
Proxy s'
-> (a, b, c, d, e, f)
-> WithRewrittenThread s s' (a, b, c, d, e, f)
rewriteThread Proxy s'
s' (a
a, b
b, c
c, d
d, e
e, f
f) =
    ( forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' a
a, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' b
b, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' c
c, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' d
d
    , forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' e
e, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' f
f)
instance ( ThreadRewritable s a, ThreadRewritable s b, ThreadRewritable s c, ThreadRewritable s d
         , ThreadRewritable s e, ThreadRewritable s f, ThreadRewritable s g ) =>
  ThreadRewritable s (a, b, c, d, e, f, g) where
  type WithRewrittenThread s s' (a, b, c, d, e, f, g) =
    ( WithRewrittenThread s s' a, WithRewrittenThread s s' b, WithRewrittenThread s s' c, WithRewrittenThread s s' d
    , WithRewrittenThread s s' e, WithRewrittenThread s s' f, WithRewrittenThread s s' g)
  rewriteThread :: forall s'.
Proxy s'
-> (a, b, c, d, e, f, g)
-> WithRewrittenThread s s' (a, b, c, d, e, f, g)
rewriteThread Proxy s'
s' (a
a, b
b, c
c, d
d, e
e, f
f, g
g) =
    ( forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' a
a, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' b
b, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' c
c, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' d
d
    , forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' e
e, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' f
f, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' g
g )
instance ( ThreadRewritable s a, ThreadRewritable s b, ThreadRewritable s c, ThreadRewritable s d
         , ThreadRewritable s e, ThreadRewritable s f, ThreadRewritable s g, ThreadRewritable s h ) =>
  ThreadRewritable s (a, b, c, d, e, f, g, h) where
  type WithRewrittenThread s s' (a, b, c, d, e, f, g, h) =
    ( WithRewrittenThread s s' a, WithRewrittenThread s s' b, WithRewrittenThread s s' c, WithRewrittenThread s s' d
    , WithRewrittenThread s s' e, WithRewrittenThread s s' f, WithRewrittenThread s s' g, WithRewrittenThread s s' h)
  rewriteThread :: forall s'.
Proxy s'
-> (a, b, c, d, e, f, g, h)
-> WithRewrittenThread s s' (a, b, c, d, e, f, g, h)
rewriteThread Proxy s'
s' (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h) =
    ( forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' a
a, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' b
b, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' c
c, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' d
d
    , forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' e
e, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' f
f, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' g
g, forall s a s'.
ThreadRewritable s a =>
Proxy s' -> a -> WithRewrittenThread s s' a
rewriteThread Proxy s'
s' h
h )

class ContextRewritable a where
  type WithRewrittenContext a ctxt :: Type

  rewriteContext :: Proxy ctxt -> a -> WithRewrittenContext a ctxt
instance Beamable tbl => ContextRewritable (tbl (QGenExpr old syntax s)) where
  type WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt = tbl (QGenExpr ctxt syntax s)

  rewriteContext :: forall ctxt.
Proxy ctxt
-> tbl (QGenExpr old syntax s)
-> WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt
rewriteContext Proxy ctxt
_ = forall (table :: (* -> *) -> *) (f :: * -> *) (g :: * -> *).
Beamable table =>
(forall a. Columnar' f a -> Columnar' g a) -> table f -> table g
changeBeamRep (\(Columnar' (QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a)) -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' (forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a))
instance Beamable tbl => ContextRewritable (tbl (Nullable (QGenExpr old syntax s))) where
  type WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt = tbl (Nullable (QGenExpr ctxt syntax s))

  rewriteContext :: forall ctxt.
Proxy ctxt
-> tbl (Nullable (QGenExpr old syntax s))
-> WithRewrittenContext
     (tbl (Nullable (QGenExpr old syntax s))) ctxt
rewriteContext Proxy ctxt
_ = forall (table :: (* -> *) -> *) (f :: * -> *) (g :: * -> *).
Beamable table =>
(forall a. Columnar' f a -> Columnar' g a) -> table f -> table g
changeBeamRep (\(Columnar' (QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a)) -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' (forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a))
instance ContextRewritable (QGenExpr old syntax s a) where
  type WithRewrittenContext (QGenExpr old syntax s a) ctxt = QGenExpr ctxt syntax s a
  rewriteContext :: forall ctxt.
Proxy ctxt
-> QGenExpr old syntax s a
-> WithRewrittenContext (QGenExpr old syntax s a) ctxt
rewriteContext Proxy ctxt
_ (QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a) = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr Text -> BeamSqlBackendExpressionSyntax syntax
a
instance ContextRewritable a => ContextRewritable [a] where
  type WithRewrittenContext [a] ctxt = [ WithRewrittenContext a ctxt ]
  rewriteContext :: forall ctxt. Proxy ctxt -> [a] -> WithRewrittenContext [a] ctxt
rewriteContext Proxy ctxt
p [a]
as = forall a b. (a -> b) -> [a] -> [b]
map (forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p) [a]
as
instance (ContextRewritable a, KnownNat n) => ContextRewritable (Vector n a) where
  type WithRewrittenContext (Vector n a) ctxt = Vector n (WithRewrittenContext a ctxt)
  rewriteContext :: forall ctxt.
Proxy ctxt -> Vector n a -> WithRewrittenContext (Vector n a) ctxt
rewriteContext Proxy ctxt
p Vector n a
as = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p) Vector n a
as
instance (ContextRewritable a, ContextRewritable b) => ContextRewritable (a, b) where
  type WithRewrittenContext (a, b) ctxt = (WithRewrittenContext a ctxt, WithRewrittenContext b ctxt)
  rewriteContext :: forall ctxt.
Proxy ctxt -> (a, b) -> WithRewrittenContext (a, b) ctxt
rewriteContext Proxy ctxt
p (a
a, b
b) = (forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p a
a, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p b
b)
instance (ContextRewritable a, ContextRewritable b, ContextRewritable c) => ContextRewritable (a, b, c) where
  type WithRewrittenContext (a, b, c) ctxt = (WithRewrittenContext a ctxt, WithRewrittenContext b ctxt, WithRewrittenContext c ctxt)
  rewriteContext :: forall ctxt.
Proxy ctxt -> (a, b, c) -> WithRewrittenContext (a, b, c) ctxt
rewriteContext Proxy ctxt
p (a
a, b
b, c
c) = (forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p a
a, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p b
b, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p c
c)
instance ( ContextRewritable a, ContextRewritable b, ContextRewritable c
         , ContextRewritable d ) => ContextRewritable (a, b, c, d) where
  type WithRewrittenContext (a, b, c, d) ctxt =
      ( WithRewrittenContext a ctxt, WithRewrittenContext b ctxt, WithRewrittenContext c ctxt
      , WithRewrittenContext d ctxt )
  rewriteContext :: forall ctxt.
Proxy ctxt
-> (a, b, c, d) -> WithRewrittenContext (a, b, c, d) ctxt
rewriteContext Proxy ctxt
p (a
a, b
b, c
c, d
d) = ( forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p a
a, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p b
b, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p c
c
                                  , forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p d
d )
instance ( ContextRewritable a, ContextRewritable b, ContextRewritable c
         , ContextRewritable d, ContextRewritable e ) =>
    ContextRewritable (a, b, c, d, e) where
  type WithRewrittenContext (a, b, c, d, e) ctxt =
      ( WithRewrittenContext a ctxt, WithRewrittenContext b ctxt, WithRewrittenContext c ctxt
      , WithRewrittenContext d ctxt, WithRewrittenContext e ctxt )
  rewriteContext :: forall ctxt.
Proxy ctxt
-> (a, b, c, d, e) -> WithRewrittenContext (a, b, c, d, e) ctxt
rewriteContext Proxy ctxt
p (a
a, b
b, c
c, d
d, e
e) = ( forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p a
a, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p b
b, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p c
c
                                     , forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p d
d, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p e
e )
instance ( ContextRewritable a, ContextRewritable b, ContextRewritable c
         , ContextRewritable d, ContextRewritable e, ContextRewritable f ) =>
    ContextRewritable (a, b, c, d, e, f) where
  type WithRewrittenContext (a, b, c, d, e, f) ctxt =
      ( WithRewrittenContext a ctxt, WithRewrittenContext b ctxt, WithRewrittenContext c ctxt
      , WithRewrittenContext d ctxt, WithRewrittenContext e ctxt, WithRewrittenContext f ctxt )
  rewriteContext :: forall ctxt.
Proxy ctxt
-> (a, b, c, d, e, f)
-> WithRewrittenContext (a, b, c, d, e, f) ctxt
rewriteContext Proxy ctxt
p (a
a, b
b, c
c, d
d, e
e, f
f) = ( forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p a
a, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p b
b, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p c
c
                                        , forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p d
d, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p e
e, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p f
f )
instance ( ContextRewritable a, ContextRewritable b, ContextRewritable c
         , ContextRewritable d, ContextRewritable e, ContextRewritable f
         , ContextRewritable g ) =>
    ContextRewritable (a, b, c, d, e, f, g) where
  type WithRewrittenContext (a, b, c, d, e, f, g) ctxt =
      ( WithRewrittenContext a ctxt, WithRewrittenContext b ctxt, WithRewrittenContext c ctxt
      , WithRewrittenContext d ctxt, WithRewrittenContext e ctxt, WithRewrittenContext f ctxt
      , WithRewrittenContext g ctxt )
  rewriteContext :: forall ctxt.
Proxy ctxt
-> (a, b, c, d, e, f, g)
-> WithRewrittenContext (a, b, c, d, e, f, g) ctxt
rewriteContext Proxy ctxt
p (a
a, b
b, c
c, d
d, e
e, f
f, g
g) =
    ( forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p a
a, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p b
b, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p c
c
    , forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p d
d, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p e
e, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p f
f
    , forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p g
g )
instance ( ContextRewritable a, ContextRewritable b, ContextRewritable c
         , ContextRewritable d, ContextRewritable e, ContextRewritable f
         , ContextRewritable g, ContextRewritable h ) =>
    ContextRewritable (a, b, c, d, e, f, g, h) where
  type WithRewrittenContext (a, b, c, d, e, f, g, h) ctxt =
      ( WithRewrittenContext a ctxt, WithRewrittenContext b ctxt, WithRewrittenContext c ctxt
      , WithRewrittenContext d ctxt, WithRewrittenContext e ctxt, WithRewrittenContext f ctxt
      , WithRewrittenContext g ctxt, WithRewrittenContext h ctxt )
  rewriteContext :: forall ctxt.
Proxy ctxt
-> (a, b, c, d, e, f, g, h)
-> WithRewrittenContext (a, b, c, d, e, f, g, h) ctxt
rewriteContext Proxy ctxt
p (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h) =
    ( forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p a
a, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p b
b, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p c
c
    , forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p d
d, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p e
e, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p f
f
    , forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p g
g, forall a ctxt.
ContextRewritable a =>
Proxy ctxt -> a -> WithRewrittenContext a ctxt
rewriteContext Proxy ctxt
p h
h )

newtype BeamSqlBackendExpressionSyntax' be
  = BeamSqlBackendExpressionSyntax'
  { forall be.
BeamSqlBackendExpressionSyntax' be
-> BeamSqlBackendExpressionSyntax be
fromBeamSqlBackendExpressionSyntax :: BeamSqlBackendExpressionSyntax be
  }

newtype BeamSqlBackendWindowFrameSyntax' be
  = BeamSqlBackendWindowFrameSyntax'
  { forall be.
BeamSqlBackendWindowFrameSyntax' be
-> BeamSqlBackendWindowFrameSyntax be
fromBeamSqlBackendWindowFrameSyntax :: BeamSqlBackendWindowFrameSyntax be
  }

class ProjectibleWithPredicate (contextPredicate :: Type -> Constraint) be res a | a -> be where
  project' :: Monad m => Proxy contextPredicate -> Proxy (be, res)
           -> (forall context. contextPredicate context =>
               Proxy context -> Proxy be -> res -> m res)
           -> a -> m a

  projectSkeleton' :: Monad m => Proxy contextPredicate -> Proxy (be, res)
                   -> (forall context. contextPredicate context =>
                       Proxy context -> Proxy be -> m res)
                   -> m a

instance (Beamable t, contextPredicate context) => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) (t (QGenExpr context be s)) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
-> (forall context.
    contextPredicate context =>
    Proxy context
    -> Proxy be
    -> WithExprContext (BeamSqlBackendExpressionSyntax' be)
    -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be)))
-> t (QGenExpr context be s)
-> m (t (QGenExpr context be s))
project' Proxy contextPredicate
_ Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
_ forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mutateM t (QGenExpr context be s)
a =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\(Columnar' (QExpr Text -> BeamSqlBackendExpressionSyntax be
e)) Columnar' (QGenExpr context be s) a
_ ->
                      forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall be.
BeamSqlBackendExpressionSyntax' be
-> BeamSqlBackendExpressionSyntax be
fromBeamSqlBackendExpressionSyntax forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mutateM (forall {k} (t :: k). Proxy t
Proxy @context) (forall {k} (t :: k). Proxy t
Proxy @be) (forall be.
BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax' be
BeamSqlBackendExpressionSyntax' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> BeamSqlBackendExpressionSyntax be
e)) t (QGenExpr context be s)
a t (QGenExpr context be s)
a

  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
-> (forall context.
    contextPredicate context =>
    Proxy context
    -> Proxy be
    -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be)))
-> m (t (QGenExpr context be s))
projectSkeleton' Proxy contextPredicate
_ Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
_ forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mkM =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\Columnar' Ignored a
_ Columnar' Ignored a
_ -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall be.
BeamSqlBackendExpressionSyntax' be
-> BeamSqlBackendExpressionSyntax be
fromBeamSqlBackendExpressionSyntax forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mkM (forall {k} (t :: k). Proxy t
Proxy @context)(forall {k} (t :: k). Proxy t
Proxy @be))
                   (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t)
                   (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t)

instance (Beamable t, contextPredicate context) => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) (t (Nullable (QGenExpr context be s))) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
-> (forall context.
    contextPredicate context =>
    Proxy context
    -> Proxy be
    -> WithExprContext (BeamSqlBackendExpressionSyntax' be)
    -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be)))
-> t (Nullable (QGenExpr context be s))
-> m (t (Nullable (QGenExpr context be s)))
project' Proxy contextPredicate
_ Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
_ forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mutateM t (Nullable (QGenExpr context be s))
a =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\(Columnar' (QExpr Text -> BeamSqlBackendExpressionSyntax be
e)) Columnar' (Nullable (QGenExpr context be s)) a
_ ->
                      forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall be.
BeamSqlBackendExpressionSyntax' be
-> BeamSqlBackendExpressionSyntax be
fromBeamSqlBackendExpressionSyntax forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mutateM (forall {k} (t :: k). Proxy t
Proxy @context) (forall {k} (t :: k). Proxy t
Proxy @be) (forall be.
BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax' be
BeamSqlBackendExpressionSyntax' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> BeamSqlBackendExpressionSyntax be
e)) t (Nullable (QGenExpr context be s))
a t (Nullable (QGenExpr context be s))
a

  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
-> (forall context.
    contextPredicate context =>
    Proxy context
    -> Proxy be
    -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be)))
-> m (t (Nullable (QGenExpr context be s)))
projectSkeleton' Proxy contextPredicate
_ Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
_ forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mkM =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\Columnar' Ignored a
_ Columnar' Ignored a
_ -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall be.
BeamSqlBackendExpressionSyntax' be
-> BeamSqlBackendExpressionSyntax be
fromBeamSqlBackendExpressionSyntax forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mkM (forall {k} (t :: k). Proxy t
Proxy @context)(forall {k} (t :: k). Proxy t
Proxy @be))
                   (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t)
                   (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t)

-- instance ProjectibleWithPredicate WindowFrameContext be (QWindow be s) where
--   project' _ be mutateM (QWindow a) =
--     QWindow <$> mutateM (Proxy @QWindowFrameContext) be a

instance contextPredicate context => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendExpressionSyntax' be)) (QGenExpr context be s a) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
-> (forall context.
    contextPredicate context =>
    Proxy context
    -> Proxy be
    -> WithExprContext (BeamSqlBackendExpressionSyntax' be)
    -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be)))
-> QGenExpr context be s a
-> m (QGenExpr context be s a)
project' Proxy contextPredicate
_ Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
_ forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mkE (QExpr Text -> BeamSqlBackendExpressionSyntax be
a) = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall be.
BeamSqlBackendExpressionSyntax' be
-> BeamSqlBackendExpressionSyntax be
fromBeamSqlBackendExpressionSyntax forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> WithExprContext (BeamSqlBackendExpressionSyntax' be)
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mkE (forall {k} (t :: k). Proxy t
Proxy @context) (forall {k} (t :: k). Proxy t
Proxy @be) (forall be.
BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax' be
BeamSqlBackendExpressionSyntax' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> BeamSqlBackendExpressionSyntax be
a)
  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
-> (forall context.
    contextPredicate context =>
    Proxy context
    -> Proxy be
    -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be)))
-> m (QGenExpr context be s a)
projectSkeleton' Proxy contextPredicate
_ Proxy (be, WithExprContext (BeamSqlBackendExpressionSyntax' be))
_ forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mkM = forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall be.
BeamSqlBackendExpressionSyntax' be
-> BeamSqlBackendExpressionSyntax be
fromBeamSqlBackendExpressionSyntax forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
mkM (forall {k} (t :: k). Proxy t
Proxy @context) (forall {k} (t :: k). Proxy t
Proxy @be)

instance contextPredicate QWindowFrameContext => ProjectibleWithPredicate contextPredicate be (WithExprContext (BeamSqlBackendWindowFrameSyntax' be)) (QWindow be s) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy
     (be, WithExprContext (BeamSqlBackendWindowFrameSyntax' be))
-> (forall context.
    contextPredicate context =>
    Proxy context
    -> Proxy be
    -> WithExprContext (BeamSqlBackendWindowFrameSyntax' be)
    -> m (WithExprContext (BeamSqlBackendWindowFrameSyntax' be)))
-> QWindow be s
-> m (QWindow be s)
project' Proxy contextPredicate
_ Proxy (be, WithExprContext (BeamSqlBackendWindowFrameSyntax' be))
_ forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> WithExprContext (BeamSqlBackendWindowFrameSyntax' be)
-> m (WithExprContext (BeamSqlBackendWindowFrameSyntax' be))
mkW (QWindow WithExprContext (BeamSqlBackendWindowFrameSyntax be)
w) = forall be s.
WithExprContext (BeamSqlBackendWindowFrameSyntax be)
-> QWindow be s
QWindow forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall be.
BeamSqlBackendWindowFrameSyntax' be
-> BeamSqlBackendWindowFrameSyntax be
fromBeamSqlBackendWindowFrameSyntax forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> WithExprContext (BeamSqlBackendWindowFrameSyntax' be)
-> m (WithExprContext (BeamSqlBackendWindowFrameSyntax' be))
mkW (forall {k} (t :: k). Proxy t
Proxy @QWindowFrameContext) (forall {k} (t :: k). Proxy t
Proxy @be) (forall be.
BeamSqlBackendWindowFrameSyntax be
-> BeamSqlBackendWindowFrameSyntax' be
BeamSqlBackendWindowFrameSyntax' forall b c a. (b -> c) -> (a -> b) -> a -> c
. WithExprContext (BeamSqlBackendWindowFrameSyntax be)
w)
  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy
     (be, WithExprContext (BeamSqlBackendWindowFrameSyntax' be))
-> (forall context.
    contextPredicate context =>
    Proxy context
    -> Proxy be
    -> m (WithExprContext (BeamSqlBackendWindowFrameSyntax' be)))
-> m (QWindow be s)
projectSkeleton' Proxy contextPredicate
_ Proxy (be, WithExprContext (BeamSqlBackendWindowFrameSyntax' be))
_ forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> m (WithExprContext (BeamSqlBackendWindowFrameSyntax' be))
mkM = forall be s.
WithExprContext (BeamSqlBackendWindowFrameSyntax be)
-> QWindow be s
QWindow forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall be.
BeamSqlBackendWindowFrameSyntax' be
-> BeamSqlBackendWindowFrameSyntax be
fromBeamSqlBackendWindowFrameSyntax forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
contextPredicate context =>
Proxy context
-> Proxy be
-> m (WithExprContext (BeamSqlBackendWindowFrameSyntax' be))
mkM (forall {k} (t :: k). Proxy t
Proxy @QWindowFrameContext) (forall {k} (t :: k). Proxy t
Proxy @be)

-- instance ProjectibleWithPredicate contextPredicate be res a => ProjectibleWithPredicate contextPredicate be res [a] where
--   project' context be mkE as = traverse (project' context be mkE) as

instance (ProjectibleWithPredicate contextPredicate be res a, KnownNat n) => ProjectibleWithPredicate contextPredicate be res (Vector n a) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> Vector n a
-> m (Vector n a)
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE Vector n a
as = forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE) Vector n a
as
  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m (Vector n a)
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM = forall (n :: Nat) (m :: * -> *) a.
(KnownNat n, Monad m) =>
m a -> m (Vector n a)
VS.replicateM (forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM)

instance ( ProjectibleWithPredicate contextPredicate be res a, ProjectibleWithPredicate contextPredicate be res b ) =>
  ProjectibleWithPredicate contextPredicate be res (a, b) where

  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> (a, b)
-> m (a, b)
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE (a
a, b
b) =
    (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE a
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE b
b
  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m (a, b)
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM =
    (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
        forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM

instance ( ProjectibleWithPredicate contextPredicate be res a, ProjectibleWithPredicate contextPredicate be res b, ProjectibleWithPredicate contextPredicate be res c ) =>
  ProjectibleWithPredicate contextPredicate be res (a, b, c) where

  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> (a, b, c)
-> m (a, b, c)
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE (a
a, b
b, c
c) =
    (,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE a
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE b
b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE c
c
  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m (a, b, c)
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM =
    (,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
         forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
         forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM

instance ( ProjectibleWithPredicate contextPredicate be res a, ProjectibleWithPredicate contextPredicate be res b, ProjectibleWithPredicate contextPredicate be res c
         , ProjectibleWithPredicate contextPredicate be res d ) =>
  ProjectibleWithPredicate contextPredicate be res (a, b, c, d) where

  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> (a, b, c, d)
-> m (a, b, c, d)
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE (a
a, b
b, c
c, d
d) =
    (,,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE a
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE b
b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE c
c
          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE d
d
  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m (a, b, c, d)
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM =
    (,,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
          forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM

instance ( ProjectibleWithPredicate contextPredicate be res a, ProjectibleWithPredicate contextPredicate be res b, ProjectibleWithPredicate contextPredicate be res c
         , ProjectibleWithPredicate contextPredicate be res d, ProjectibleWithPredicate contextPredicate be res e ) =>
  ProjectibleWithPredicate contextPredicate be res (a, b, c, d, e) where

  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> (a, b, c, d, e)
-> m (a, b, c, d, e)
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE (a
a, b
b, c
c, d
d, e
e) =
    (,,,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE a
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE b
b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE c
c
           forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE d
d forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE e
e
  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m (a, b, c, d, e)
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM =
    (,,,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
           forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
           forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
           forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
           forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM

instance ( ProjectibleWithPredicate contextPredicate be res a, ProjectibleWithPredicate contextPredicate be res b, ProjectibleWithPredicate contextPredicate be res c
         , ProjectibleWithPredicate contextPredicate be res d, ProjectibleWithPredicate contextPredicate be res e, ProjectibleWithPredicate contextPredicate be res f ) =>
  ProjectibleWithPredicate contextPredicate be res (a, b, c, d, e, f) where

  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> (a, b, c, d, e, f)
-> m (a, b, c, d, e, f)
project' Proxy contextPredicate
context Proxy (be, res)
be  forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE (a
a, b
b, c
c, d
d, e
e, f
f) =
    (,,,,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE a
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE b
b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE c
c
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE d
d forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE e
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE f
f
  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m (a, b, c, d, e, f)
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM =
    (,,,,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM

instance ( ProjectibleWithPredicate contextPredicate be res a, ProjectibleWithPredicate contextPredicate be res b, ProjectibleWithPredicate contextPredicate be res c
         , ProjectibleWithPredicate contextPredicate be res d, ProjectibleWithPredicate contextPredicate be res e, ProjectibleWithPredicate contextPredicate be res f
         , ProjectibleWithPredicate contextPredicate be res g ) =>
  ProjectibleWithPredicate contextPredicate be res (a, b, c, d, e, f, g) where

  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> (a, b, c, d, e, f, g)
-> m (a, b, c, d, e, f, g)
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE (a
a, b
b, c
c, d
d, e
e, f
f, g
g) =
    (,,,,,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE a
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE b
b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE c
c
             forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE d
d forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE e
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE f
f
             forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE g
g
  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m (a, b, c, d, e, f, g)
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM =
    (,,,,,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
             forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
             forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
             forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
             forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
             forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
             forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM

instance ( ProjectibleWithPredicate contextPredicate be res a, ProjectibleWithPredicate contextPredicate be res b, ProjectibleWithPredicate contextPredicate be res c
         , ProjectibleWithPredicate contextPredicate be res d, ProjectibleWithPredicate contextPredicate be res e, ProjectibleWithPredicate contextPredicate be res f
         , ProjectibleWithPredicate contextPredicate be res g, ProjectibleWithPredicate contextPredicate be res h ) =>
  ProjectibleWithPredicate contextPredicate be res (a, b, c, d, e, f, g, h) where

  project' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> (a, b, c, d, e, f, g, h)
-> m (a, b, c, d, e, f, g, h)
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE (a
a, b
b, c
c, d
d, e
e, f
f, g
g, h
h) =
    (,,,,,,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE a
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE b
b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE c
c
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE d
d forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE e
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE f
f
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE g
g forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> res -> m res
mkE h
h
  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m (a, b, c, d, e, f, g, h)
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM =
    (,,,,,,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' Proxy contextPredicate
context Proxy (be, res)
be forall context.
contextPredicate context =>
Proxy context -> Proxy be -> m res
mkM

-- TODO add projectSkeleton'
instance Beamable t => ProjectibleWithPredicate AnyType () T.Text (t (QField s)) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), Text)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> Text -> m Text)
-> t (QField s)
-> m (t (QField s))
project' Proxy AnyType
_ Proxy ((), Text)
be forall context.
AnyType context =>
Proxy context -> Proxy () -> Text -> m Text
mutateM t (QField s)
a =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\(Columnar' Columnar (QField s) a
f) Columnar' (QField s) a
_ ->
                      forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' (forall {k} (t :: k). Proxy t
Proxy @AnyType) Proxy ((), Text)
be forall context.
AnyType context =>
Proxy context -> Proxy () -> Text -> m Text
mutateM Columnar (QField s) a
f) t (QField s)
a t (QField s)
a

  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), Text)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> m Text)
-> m (t (QField s))
projectSkeleton' Proxy AnyType
_ Proxy ((), Text)
_ forall context.
AnyType context =>
Proxy context -> Proxy () -> m Text
mkM =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\Columnar' Ignored a
_ Columnar' Ignored a
_ -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s ty. Bool -> Text -> Text -> QField s ty
QField Bool
False Text
"" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall context.
AnyType context =>
Proxy context -> Proxy () -> m Text
mkM (forall {k} (t :: k). Proxy t
Proxy @()) (forall {k} (t :: k). Proxy t
Proxy @())))
                   (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t) (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t)

instance Beamable t => ProjectibleWithPredicate AnyType () T.Text (t (Nullable (QField s))) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), Text)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> Text -> m Text)
-> t (Nullable (QField s))
-> m (t (Nullable (QField s)))
project' Proxy AnyType
_ Proxy ((), Text)
be forall context.
AnyType context =>
Proxy context -> Proxy () -> Text -> m Text
mutateM t (Nullable (QField s))
a =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\(Columnar' Columnar (Nullable (QField s)) a
f) Columnar' (Nullable (QField s)) a
_ ->
                      forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' (forall {k} (t :: k). Proxy t
Proxy @AnyType) Proxy ((), Text)
be forall context.
AnyType context =>
Proxy context -> Proxy () -> Text -> m Text
mutateM Columnar (Nullable (QField s)) a
f) t (Nullable (QField s))
a t (Nullable (QField s))
a

  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), Text)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> m Text)
-> m (t (Nullable (QField s)))
projectSkeleton' Proxy AnyType
_ Proxy ((), Text)
_ forall context.
AnyType context =>
Proxy context -> Proxy () -> m Text
mkM =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\Columnar' Ignored a
_ Columnar' Ignored a
_ -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s ty. Bool -> Text -> Text -> QField s ty
QField Bool
False Text
"" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
AnyType context =>
Proxy context -> Proxy () -> m Text
mkM (forall {k} (t :: k). Proxy t
Proxy @()) (forall {k} (t :: k). Proxy t
Proxy @()))
                   (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t) (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t)

instance Beamable t => ProjectibleWithPredicate AnyType () res (t (Const res)) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), res)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> res -> m res)
-> t (Const res)
-> m (t (Const res))
project' Proxy AnyType
_ Proxy ((), res)
be forall context.
AnyType context =>
Proxy context -> Proxy () -> res -> m res
mutateM t (Const res)
a =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\(Columnar' Columnar (Const res) a
f) Columnar' (Const res) a
_ ->
                      forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' (forall {k} (t :: k). Proxy t
Proxy @AnyType) Proxy ((), res)
be forall context.
AnyType context =>
Proxy context -> Proxy () -> res -> m res
mutateM Columnar (Const res) a
f) t (Const res)
a t (Const res)
a

  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), res)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> m res)
-> m (t (Const res))
projectSkeleton' Proxy AnyType
_ Proxy ((), res)
_ forall context.
AnyType context =>
Proxy context -> Proxy () -> m res
mkM =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\Columnar' Ignored a
_ Columnar' Ignored a
_ -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). a -> Const a b
Const forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
AnyType context =>
Proxy context -> Proxy () -> m res
mkM (forall {k} (t :: k). Proxy t
Proxy @()) (forall {k} (t :: k). Proxy t
Proxy @()))
                   (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t) (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t)

instance Beamable t => ProjectibleWithPredicate AnyType () T.Text (t (Nullable (Const T.Text))) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), Text)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> Text -> m Text)
-> t (Nullable (Const Text))
-> m (t (Nullable (Const Text)))
project' Proxy AnyType
_ Proxy ((), Text)
be forall context.
AnyType context =>
Proxy context -> Proxy () -> Text -> m Text
mutateM t (Nullable (Const Text))
a =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\(Columnar' Columnar (Nullable (Const Text)) a
f) Columnar' (Nullable (Const Text)) a
_ ->
                      forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' (forall {k} (t :: k). Proxy t
Proxy @AnyType) Proxy ((), Text)
be forall context.
AnyType context =>
Proxy context -> Proxy () -> Text -> m Text
mutateM Columnar (Nullable (Const Text)) a
f) t (Nullable (Const Text))
a t (Nullable (Const Text))
a

  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), Text)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> m Text)
-> m (t (Nullable (Const Text)))
projectSkeleton' Proxy AnyType
_ Proxy ((), Text)
_ forall context.
AnyType context =>
Proxy context -> Proxy () -> m Text
mkM =
    forall (table :: (* -> *) -> *) (m :: * -> *) (f :: * -> *)
       (g :: * -> *) (h :: * -> *).
(Beamable table, Applicative m) =>
(forall a. Columnar' f a -> Columnar' g a -> m (Columnar' h a))
-> table f -> table g -> m (table h)
zipBeamFieldsM (\Columnar' Ignored a
_ Columnar' Ignored a
_ -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} a (b :: k). a -> Const a b
Const forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
AnyType context =>
Proxy context -> Proxy () -> m Text
mkM (forall {k} (t :: k). Proxy t
Proxy @()) (forall {k} (t :: k). Proxy t
Proxy @()))
                   (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t) (forall (table :: (* -> *) -> *).
Beamable table =>
TableSkeleton table
tblSkeleton :: TableSkeleton t)

instance ProjectibleWithPredicate AnyType () res (Const res a) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), res)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> res -> m res)
-> Const res a
-> m (Const res a)
project' Proxy AnyType
_ Proxy ((), res)
_ forall context.
AnyType context =>
Proxy context -> Proxy () -> res -> m res
mutateM (Const res
a) = forall {k} a (b :: k). a -> Const a b
Const forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
AnyType context =>
Proxy context -> Proxy () -> res -> m res
mutateM (forall {k} (t :: k). Proxy t
Proxy @()) (forall {k} (t :: k). Proxy t
Proxy @()) res
a

  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), res)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> m res)
-> m (Const res a)
projectSkeleton' Proxy AnyType
_ Proxy ((), res)
_ forall context.
AnyType context =>
Proxy context -> Proxy () -> m res
mkM =
    forall {k} a (b :: k). a -> Const a b
Const forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
AnyType context =>
Proxy context -> Proxy () -> m res
mkM (forall {k} (t :: k). Proxy t
Proxy @()) (forall {k} (t :: k). Proxy t
Proxy @())

instance ProjectibleWithPredicate AnyType () T.Text (QField s a) where
  project' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), Text)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> Text -> m Text)
-> QField s a
-> m (QField s a)
project' Proxy AnyType
_ Proxy ((), Text)
_ forall context.
AnyType context =>
Proxy context -> Proxy () -> Text -> m Text
mutateM (QField Bool
q Text
tbl Text
f) =
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall s ty. Bool -> Text -> Text -> QField s ty
QField Bool
q Text
tbl)
         (forall context.
AnyType context =>
Proxy context -> Proxy () -> Text -> m Text
mutateM (forall {k} (t :: k). Proxy t
Proxy @(QField s a)) (forall {k} (t :: k). Proxy t
Proxy @()) Text
f)

  projectSkeleton' :: forall (m :: * -> *).
Monad m =>
Proxy AnyType
-> Proxy ((), Text)
-> (forall context.
    AnyType context =>
    Proxy context -> Proxy () -> m Text)
-> m (QField s a)
projectSkeleton' Proxy AnyType
_ Proxy ((), Text)
_ forall context.
AnyType context =>
Proxy context -> Proxy () -> m Text
mkM =
    forall s ty. Bool -> Text -> Text -> QField s ty
QField Bool
False Text
"" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall context.
AnyType context =>
Proxy context -> Proxy () -> m Text
mkM (forall {k} (t :: k). Proxy t
Proxy @()) (forall {k} (t :: k). Proxy t
Proxy @())

project :: forall be a
         . Projectible be a => Proxy be -> a -> WithExprContext [ BeamSqlBackendExpressionSyntax be ]
project :: forall be a.
Projectible be a =>
Proxy be
-> a -> WithExprContext [BeamSqlBackendExpressionSyntax be]
project Proxy be
_ = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall be.
BeamSqlBackendExpressionSyntax' be
-> BeamSqlBackendExpressionSyntax be
fromBeamSqlBackendExpressionSyntax) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. DList a -> [a]
DList.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall w a. Writer w a -> w
execWriter forall b c a. (b -> c) -> (a -> b) -> a -> c
.
            forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' (forall {k} (t :: k). Proxy t
Proxy @AnyType) (forall {k} (t :: k). Proxy t
Proxy @(be, WithExprContext (BeamSqlBackendExpressionSyntax' be))) (\Proxy context
_ Proxy be
_ Text -> BeamSqlBackendExpressionSyntax' be
e -> forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (forall a. a -> DList a
DList.singleton Text -> BeamSqlBackendExpressionSyntax' be
e) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (f :: * -> *) a. Applicative f => a -> f a
pure Text -> BeamSqlBackendExpressionSyntax' be
e)

reproject :: forall be a
           . (BeamSqlBackend be, Projectible be a)
          => Proxy be -> (Int -> BeamSqlBackendExpressionSyntax be) -> a -> a
reproject :: forall be a.
(BeamSqlBackend be, Projectible be a) =>
Proxy be -> (Int -> BeamSqlBackendExpressionSyntax be) -> a -> a
reproject Proxy be
_ Int
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
mkField a
a =
  forall s a. State s a -> s -> a
evalState (forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> res -> m res)
-> a
-> m a
project' (forall {k} (t :: k). Proxy t
Proxy @AnyType) (forall {k} (t :: k). Proxy t
Proxy @(be, WithExprContext (BeamSqlBackendExpressionSyntax' be))) (\Proxy context
_ Proxy be
_ WithExprContext (BeamSqlBackendExpressionSyntax' be)
_ -> forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
state (\Int
i -> (Int
i, Int
i forall a. Num a => a -> a -> a
+ Int
1)) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall be.
BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax' be
BeamSqlBackendExpressionSyntax' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax be)))
mkField) a
a) Int
0

-- | suitable as argument to 'QAll' in the case of a table result
tableFieldsToExpressions :: ( BeamSqlBackend be, Beamable table )
                         => TableSettings table -> T.Text -> table (QGenExpr ctxt be s)
tableFieldsToExpressions :: forall be (table :: (* -> *) -> *) ctxt s.
(BeamSqlBackend be, Beamable table) =>
TableSettings table -> Text -> table (QGenExpr ctxt be s)
tableFieldsToExpressions TableSettings table
tblSettings Text
newTblNm =
    forall (table :: (* -> *) -> *) (f :: * -> *) (g :: * -> *).
Beamable table =>
(forall a. Columnar' f a -> Columnar' g a) -> table f -> table g
changeBeamRep (\(Columnar' Columnar (TableField table) a
f) -> forall (f :: * -> *) a. Columnar f a -> Columnar' f a
Columnar' (forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr (\Text
_ -> forall expr.
IsSql92ExpressionSyntax expr =>
Sql92ExpressionFieldNameSyntax expr -> expr
fieldE (forall fn. IsSql92FieldNameSyntax fn => Text -> Text -> fn
qualifiedField Text
newTblNm (forall (table :: (* -> *) -> *) ty. TableField table ty -> Text
_fieldName Columnar (TableField table) a
f))))) TableSettings table
tblSettings

mkFieldsSkeleton :: forall be res m
                  . (Projectible be res, MonadState Int m)
                 => (Int -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))) -> m res
mkFieldsSkeleton :: forall be res (m :: * -> *).
(Projectible be res, MonadState Int m) =>
(Int -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be)))
-> m res
mkFieldsSkeleton Int -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
go =
    forall (contextPredicate :: * -> Constraint) be res a
       (m :: * -> *).
(ProjectibleWithPredicate contextPredicate be res a, Monad m) =>
Proxy contextPredicate
-> Proxy (be, res)
-> (forall context.
    contextPredicate context =>
    Proxy context -> Proxy be -> m res)
-> m a
projectSkeleton' (forall {k} (t :: k). Proxy t
Proxy @AnyType) (forall {k} (t :: k). Proxy t
Proxy @(be, WithExprContext (BeamSqlBackendExpressionSyntax' be))) forall a b. (a -> b) -> a -> b
$ \Proxy context
_ Proxy be
_ ->
    do Int
i <- forall s (m :: * -> *). MonadState s m => m s
get
       forall s (m :: * -> *). MonadState s m => s -> m ()
put (Int
i forall a. Num a => a -> a -> a
+ Int
1)
       Int -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be))
go Int
i

mkFieldNames :: forall be res
              . ( BeamSqlBackend be, Projectible be res )
             => (T.Text -> BeamSqlBackendFieldNameSyntax be) -> (res, [ T.Text ])
mkFieldNames :: forall be res.
(BeamSqlBackend be, Projectible be res) =>
(Text -> BeamSqlBackendFieldNameSyntax be) -> (res, [Text])
mkFieldNames Text -> BeamSqlBackendFieldNameSyntax be
mkField =
    forall w a. Writer w a -> (a, w)
runWriter forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> b -> a -> c
flip forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT Int
0 forall a b. (a -> b) -> a -> b
$
    forall be res (m :: * -> *).
(Projectible be res, MonadState Int m) =>
(Int -> m (WithExprContext (BeamSqlBackendExpressionSyntax' be)))
-> m res
mkFieldsSkeleton @be @res forall a b. (a -> b) -> a -> b
$ \Int
i -> do
      let fieldName' :: Text
fieldName' = forall a. IsString a => String -> a
fromString (String
"res" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Int
i)
      forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [ Text
fieldName' ]
      forall (f :: * -> *) a. Applicative f => a -> f a
pure (\Text
_ -> forall be.
BeamSqlBackendExpressionSyntax be
-> BeamSqlBackendExpressionSyntax' be
BeamSqlBackendExpressionSyntax' (forall expr.
IsSql92ExpressionSyntax expr =>
Sql92ExpressionFieldNameSyntax expr -> expr
fieldE (Text -> BeamSqlBackendFieldNameSyntax be
mkField Text
fieldName')))

tableNameFromEntity :: IsSql92TableNameSyntax name
                    => DatabaseEntityDescriptor be (TableEntity tbl)
                    -> name

tableNameFromEntity :: forall name be (tbl :: (* -> *) -> *).
IsSql92TableNameSyntax name =>
DatabaseEntityDescriptor be (TableEntity tbl) -> name
tableNameFromEntity = forall tblName.
IsSql92TableNameSyntax tblName =>
Maybe Text -> Text -> tblName
tableName forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (tbl :: (* -> *) -> *) be.
DatabaseEntityDescriptor be (TableEntity tbl) -> Maybe Text
dbTableSchema forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (tbl :: (* -> *) -> *) be.
DatabaseEntityDescriptor be (TableEntity tbl) -> Text
dbTableCurrentName

rescopeQ :: QM be db s res -> QM be db s' res
rescopeQ :: forall be (db :: (* -> *) -> *) s res s'.
QM be db s res -> QM be db s' res
rescopeQ = forall a b. a -> b
unsafeCoerce