{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE UndecidableInstances #-}

-- | Arbitrarily putting leaves from RQL.IR.Select into own files to
-- parallelise compilation
module Hasura.RQL.IR.Select.TablePerm
  ( TablePerm,
    TablePermG (..),
    noTablePermissions,
  )
where

import Hasura.Prelude
import Hasura.RQL.IR.BoolExp
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.BackendType

-- Permissions

data TablePermG (b :: BackendType) v = TablePerm
  { forall (b :: BackendType) v. TablePermG b v -> AnnBoolExp b v
_tpFilter :: AnnBoolExp b v,
    forall (b :: BackendType) v. TablePermG b v -> Maybe Int
_tpLimit :: (Maybe Int)
  }
  deriving stock ((forall x. TablePermG b v -> Rep (TablePermG b v) x)
-> (forall x. Rep (TablePermG b v) x -> TablePermG b v)
-> Generic (TablePermG b v)
forall x. Rep (TablePermG b v) x -> TablePermG b v
forall x. TablePermG b v -> Rep (TablePermG b v) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (b :: BackendType) v x.
Rep (TablePermG b v) x -> TablePermG b v
forall (b :: BackendType) v x.
TablePermG b v -> Rep (TablePermG b v) x
$cfrom :: forall (b :: BackendType) v x.
TablePermG b v -> Rep (TablePermG b v) x
from :: forall x. TablePermG b v -> Rep (TablePermG b v) x
$cto :: forall (b :: BackendType) v x.
Rep (TablePermG b v) x -> TablePermG b v
to :: forall x. Rep (TablePermG b v) x -> TablePermG b v
Generic, (forall a b. (a -> b) -> TablePermG b a -> TablePermG b b)
-> (forall a b. a -> TablePermG b b -> TablePermG b a)
-> Functor (TablePermG b)
forall a b. a -> TablePermG b b -> TablePermG b a
forall a b. (a -> b) -> TablePermG b a -> TablePermG b b
forall (b :: BackendType) a b.
Backend b =>
a -> TablePermG b b -> TablePermG b a
forall (b :: BackendType) a b.
Backend b =>
(a -> b) -> TablePermG b a -> TablePermG b b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (b :: BackendType) a b.
Backend b =>
(a -> b) -> TablePermG b a -> TablePermG b b
fmap :: forall a b. (a -> b) -> TablePermG b a -> TablePermG b b
$c<$ :: forall (b :: BackendType) a b.
Backend b =>
a -> TablePermG b b -> TablePermG b a
<$ :: forall a b. a -> TablePermG b b -> TablePermG b a
Functor, (forall m. Monoid m => TablePermG b m -> m)
-> (forall m a. Monoid m => (a -> m) -> TablePermG b a -> m)
-> (forall m a. Monoid m => (a -> m) -> TablePermG b a -> m)
-> (forall a b. (a -> b -> b) -> b -> TablePermG b a -> b)
-> (forall a b. (a -> b -> b) -> b -> TablePermG b a -> b)
-> (forall b a. (b -> a -> b) -> b -> TablePermG b a -> b)
-> (forall b a. (b -> a -> b) -> b -> TablePermG b a -> b)
-> (forall a. (a -> a -> a) -> TablePermG b a -> a)
-> (forall a. (a -> a -> a) -> TablePermG b a -> a)
-> (forall a. TablePermG b a -> [a])
-> (forall a. TablePermG b a -> Bool)
-> (forall a. TablePermG b a -> Int)
-> (forall a. Eq a => a -> TablePermG b a -> Bool)
-> (forall a. Ord a => TablePermG b a -> a)
-> (forall a. Ord a => TablePermG b a -> a)
-> (forall a. Num a => TablePermG b a -> a)
-> (forall a. Num a => TablePermG b a -> a)
-> Foldable (TablePermG b)
forall a. Eq a => a -> TablePermG b a -> Bool
forall a. Num a => TablePermG b a -> a
forall a. Ord a => TablePermG b a -> a
forall m. Monoid m => TablePermG b m -> m
forall a. TablePermG b a -> Bool
forall a. TablePermG b a -> Int
forall a. TablePermG b a -> [a]
forall a. (a -> a -> a) -> TablePermG b a -> a
forall m a. Monoid m => (a -> m) -> TablePermG b a -> m
forall b a. (b -> a -> b) -> b -> TablePermG b a -> b
forall a b. (a -> b -> b) -> b -> TablePermG b a -> b
forall (b :: BackendType) a.
(Backend b, Eq a) =>
a -> TablePermG b a -> Bool
forall (b :: BackendType) a.
(Backend b, Num a) =>
TablePermG b a -> a
forall (b :: BackendType) a.
(Backend b, Ord a) =>
TablePermG b a -> a
forall (b :: BackendType) m.
(Backend b, Monoid m) =>
TablePermG b m -> m
forall (b :: BackendType) a. Backend b => TablePermG b a -> Bool
forall (b :: BackendType) a. Backend b => TablePermG b a -> Int
forall (b :: BackendType) a. Backend b => TablePermG b a -> [a]
forall (b :: BackendType) a.
Backend b =>
(a -> a -> a) -> TablePermG b a -> a
forall (b :: BackendType) m a.
(Backend b, Monoid m) =>
(a -> m) -> TablePermG b a -> m
forall (b :: BackendType) b a.
Backend b =>
(b -> a -> b) -> b -> TablePermG b a -> b
forall (b :: BackendType) a b.
Backend b =>
(a -> b -> b) -> b -> TablePermG b a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall (b :: BackendType) m.
(Backend b, Monoid m) =>
TablePermG b m -> m
fold :: forall m. Monoid m => TablePermG b m -> m
$cfoldMap :: forall (b :: BackendType) m a.
(Backend b, Monoid m) =>
(a -> m) -> TablePermG b a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> TablePermG b a -> m
$cfoldMap' :: forall (b :: BackendType) m a.
(Backend b, Monoid m) =>
(a -> m) -> TablePermG b a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> TablePermG b a -> m
$cfoldr :: forall (b :: BackendType) a b.
Backend b =>
(a -> b -> b) -> b -> TablePermG b a -> b
foldr :: forall a b. (a -> b -> b) -> b -> TablePermG b a -> b
$cfoldr' :: forall (b :: BackendType) a b.
Backend b =>
(a -> b -> b) -> b -> TablePermG b a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> TablePermG b a -> b
$cfoldl :: forall (b :: BackendType) b a.
Backend b =>
(b -> a -> b) -> b -> TablePermG b a -> b
foldl :: forall b a. (b -> a -> b) -> b -> TablePermG b a -> b
$cfoldl' :: forall (b :: BackendType) b a.
Backend b =>
(b -> a -> b) -> b -> TablePermG b a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> TablePermG b a -> b
$cfoldr1 :: forall (b :: BackendType) a.
Backend b =>
(a -> a -> a) -> TablePermG b a -> a
foldr1 :: forall a. (a -> a -> a) -> TablePermG b a -> a
$cfoldl1 :: forall (b :: BackendType) a.
Backend b =>
(a -> a -> a) -> TablePermG b a -> a
foldl1 :: forall a. (a -> a -> a) -> TablePermG b a -> a
$ctoList :: forall (b :: BackendType) a. Backend b => TablePermG b a -> [a]
toList :: forall a. TablePermG b a -> [a]
$cnull :: forall (b :: BackendType) a. Backend b => TablePermG b a -> Bool
null :: forall a. TablePermG b a -> Bool
$clength :: forall (b :: BackendType) a. Backend b => TablePermG b a -> Int
length :: forall a. TablePermG b a -> Int
$celem :: forall (b :: BackendType) a.
(Backend b, Eq a) =>
a -> TablePermG b a -> Bool
elem :: forall a. Eq a => a -> TablePermG b a -> Bool
$cmaximum :: forall (b :: BackendType) a.
(Backend b, Ord a) =>
TablePermG b a -> a
maximum :: forall a. Ord a => TablePermG b a -> a
$cminimum :: forall (b :: BackendType) a.
(Backend b, Ord a) =>
TablePermG b a -> a
minimum :: forall a. Ord a => TablePermG b a -> a
$csum :: forall (b :: BackendType) a.
(Backend b, Num a) =>
TablePermG b a -> a
sum :: forall a. Num a => TablePermG b a -> a
$cproduct :: forall (b :: BackendType) a.
(Backend b, Num a) =>
TablePermG b a -> a
product :: forall a. Num a => TablePermG b a -> a
Foldable, Functor (TablePermG b)
Foldable (TablePermG b)
Functor (TablePermG b)
-> Foldable (TablePermG b)
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> TablePermG b a -> f (TablePermG b b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    TablePermG b (f a) -> f (TablePermG b a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> TablePermG b a -> m (TablePermG b b))
-> (forall (m :: * -> *) a.
    Monad m =>
    TablePermG b (m a) -> m (TablePermG b a))
-> Traversable (TablePermG b)
forall (b :: BackendType). Backend b => Functor (TablePermG b)
forall (b :: BackendType). Backend b => Foldable (TablePermG b)
forall (b :: BackendType) (m :: * -> *) a.
(Backend b, Monad m) =>
TablePermG b (m a) -> m (TablePermG b a)
forall (b :: BackendType) (f :: * -> *) a.
(Backend b, Applicative f) =>
TablePermG b (f a) -> f (TablePermG b a)
forall (b :: BackendType) (m :: * -> *) a b.
(Backend b, Monad m) =>
(a -> m b) -> TablePermG b a -> m (TablePermG b b)
forall (b :: BackendType) (f :: * -> *) a b.
(Backend b, Applicative f) =>
(a -> f b) -> TablePermG b a -> f (TablePermG b b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
TablePermG b (m a) -> m (TablePermG b a)
forall (f :: * -> *) a.
Applicative f =>
TablePermG b (f a) -> f (TablePermG b a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> TablePermG b a -> m (TablePermG b b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> TablePermG b a -> f (TablePermG b b)
$ctraverse :: forall (b :: BackendType) (f :: * -> *) a b.
(Backend b, Applicative f) =>
(a -> f b) -> TablePermG b a -> f (TablePermG b b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> TablePermG b a -> f (TablePermG b b)
$csequenceA :: forall (b :: BackendType) (f :: * -> *) a.
(Backend b, Applicative f) =>
TablePermG b (f a) -> f (TablePermG b a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
TablePermG b (f a) -> f (TablePermG b a)
$cmapM :: forall (b :: BackendType) (m :: * -> *) a b.
(Backend b, Monad m) =>
(a -> m b) -> TablePermG b a -> m (TablePermG b b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> TablePermG b a -> m (TablePermG b b)
$csequence :: forall (b :: BackendType) (m :: * -> *) a.
(Backend b, Monad m) =>
TablePermG b (m a) -> m (TablePermG b a)
sequence :: forall (m :: * -> *) a.
Monad m =>
TablePermG b (m a) -> m (TablePermG b a)
Traversable)

deriving stock instance
  ( Backend b,
    Eq (AnnBoolExp b v)
  ) =>
  Eq (TablePermG b v)

deriving stock instance
  ( Backend b,
    Show (AnnBoolExp b v)
  ) =>
  Show (TablePermG b v)

instance
  ( Backend b,
    Hashable (AnnBoolExp b v)
  ) =>
  Hashable (TablePermG b v)

type TablePerm b = TablePermG b (SQLExpression b)

noTablePermissions :: TablePermG backend v
noTablePermissions :: forall (backend :: BackendType) v. TablePermG backend v
noTablePermissions = AnnBoolExp backend v -> Maybe Int -> TablePermG backend v
forall (b :: BackendType) v.
AnnBoolExp b v -> Maybe Int -> TablePermG b v
TablePerm AnnBoolExp backend v
forall (backend :: BackendType) scalar. AnnBoolExp backend scalar
annBoolExpTrue Maybe Int
forall a. Maybe a
Nothing