postgresql-tx-squeal-0.3.0.0: postgresql-tx interfacing for use with squeal-postgresql.
Safe HaskellNone
LanguageHaskell2010

Database.PostgreSQL.Tx.Squeal.Internal.Reexport

Synopsis

Documentation

class IsLabel (x :: Symbol) a where #

Methods

fromLabel :: a #

Instances

Instances details
alias1 ~ alias2 => IsLabel alias1 (Alias alias2) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: Alias alias2 #

FromValue ty (Maybe y) => IsLabel fld (MaybeT (DecodeRow ((fld ::: ty) ': row)) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: MaybeT (DecodeRow ((fld ::: ty) ': row)) y #

IsLabel fld (MaybeT (DecodeRow row) y) => IsLabel fld (MaybeT (DecodeRow (field ': row)) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: MaybeT (DecodeRow (field ': row)) y #

FromValue ty y => IsLabel fld (DecodeRow ((fld ::: ty) ': row) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: DecodeRow ((fld ::: ty) ': row) y #

IsLabel fld (DecodeRow row y) => IsLabel fld (DecodeRow (field ': row) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: DecodeRow (field ': row) y #

(HasUnique rel rels cols, Has col cols ty, by ~ '(rel, col)) => IsLabel col (By rels by) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

fromLabel :: By rels by #

(q' ~ "public", a ~ a') => IsLabel a (QualifiedAlias q' a') 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: QualifiedAlias q' a' #

(HasUnique rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsLabel col (NP (By rels) bys) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

fromLabel :: NP (By rels) bys #

(HasUnique tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsLabel col (NP (Expression 'Ungrouped lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Expression 'Ungrouped lat with db params from) tys #

(HasUnique tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression 'Ungrouped lat with db params from)) columns #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsLabel col (NP (Expression ('Grouped bys) lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Expression ('Grouped bys) lat with db params from) tys #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns #

(HasUnique tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression 'Ungrouped lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Aliased (Expression 'Ungrouped lat with db params from) column #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression ('Grouped bys) lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Aliased (Expression ('Grouped bys) lat with db params from) column #

aliases ~ '[alias] => IsLabel alias (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: NP Alias aliases #

(alias0 ~ alias1, alias0 ~ alias2, KnownSymbol alias2) => IsLabel alias0 (Aliased Alias (alias1 ::: alias2)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: Aliased Alias (alias1 ::: alias2) #

(q ~ "public", a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsLabel a0 (Aliased (QualifiedAlias q) (a1 ::: a2)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: Aliased (QualifiedAlias q) (a1 ::: a2) #

(HasUnique tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty]) => IsLabel col (Selection 'Ungrouped lat with db params from row1) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

fromLabel :: Selection 'Ungrouped lat with db params from row1 #

(HasUnique tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty], GroupedBy tab col bys) => IsLabel col (Selection ('Grouped bys) lat with db params from row1) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

fromLabel :: Selection ('Grouped bys) lat with db params from row1 #

(HasUnique tab (Join from lat) row, Has col row ty) => IsLabel col (Expression 'Ungrouped lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Expression 'Ungrouped lat with db params from ty #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys) => IsLabel col (Expression ('Grouped bys) lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Expression ('Grouped bys) lat with db params from ty #

(>>>) :: forall k cat (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c infixr 1 #

Left-to-right composition

(&) :: a -> (a -> b) -> b infixl 1 #

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

>>> 5 & (+1) & show
"6"

Since: base-4.8.0.0

newtype ExceptT e (m :: Type -> Type) a #

A monad transformer that adds exceptions to other monads.

ExceptT constructs a monad parameterized over two things:

  • e - The exception type.
  • m - The inner monad.

The return function yields a computation that produces the given value, while >>= sequences two subcomputations, exiting on the first exception.

Constructors

ExceptT (m (Either e a)) 

Instances

Instances details
MonadPQ db m => MonadPQ db (ExceptT e m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> ExceptT e m (Result y) #

executeParams_ :: Statement db x () -> x -> ExceptT e m () #

execute :: Statement db () y -> ExceptT e m (Result y) #

execute_ :: Statement db () () -> ExceptT e m () #

executePrepared :: Traversable list => Statement db x y -> list x -> ExceptT e m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> ExceptT e m () #

MonadTrans (ExceptT e) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

lift :: Monad m => m a -> ExceptT e m a #

Monad m => Monad (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

(>>=) :: ExceptT e m a -> (a -> ExceptT e m b) -> ExceptT e m b #

(>>) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m b #

return :: a -> ExceptT e m a #

Functor m => Functor (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

fmap :: (a -> b) -> ExceptT e m a -> ExceptT e m b #

(<$) :: a -> ExceptT e m b -> ExceptT e m a #

MonadFix m => MonadFix (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

mfix :: (a -> ExceptT e m a) -> ExceptT e m a #

MonadFail m => MonadFail (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

fail :: String -> ExceptT e m a #

(Functor m, Monad m) => Applicative (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

pure :: a -> ExceptT e m a #

(<*>) :: ExceptT e m (a -> b) -> ExceptT e m a -> ExceptT e m b #

liftA2 :: (a -> b -> c) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c #

(*>) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m b #

(<*) :: ExceptT e m a -> ExceptT e m b -> ExceptT e m a #

Foldable f => Foldable (ExceptT e f) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

fold :: Monoid m => ExceptT e f m -> m #

foldMap :: Monoid m => (a -> m) -> ExceptT e f a -> m #

foldMap' :: Monoid m => (a -> m) -> ExceptT e f a -> m #

foldr :: (a -> b -> b) -> b -> ExceptT e f a -> b #

foldr' :: (a -> b -> b) -> b -> ExceptT e f a -> b #

foldl :: (b -> a -> b) -> b -> ExceptT e f a -> b #

foldl' :: (b -> a -> b) -> b -> ExceptT e f a -> b #

foldr1 :: (a -> a -> a) -> ExceptT e f a -> a #

foldl1 :: (a -> a -> a) -> ExceptT e f a -> a #

toList :: ExceptT e f a -> [a] #

null :: ExceptT e f a -> Bool #

length :: ExceptT e f a -> Int #

elem :: Eq a => a -> ExceptT e f a -> Bool #

maximum :: Ord a => ExceptT e f a -> a #

minimum :: Ord a => ExceptT e f a -> a #

sum :: Num a => ExceptT e f a -> a #

product :: Num a => ExceptT e f a -> a #

Traversable f => Traversable (ExceptT e f) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

traverse :: Applicative f0 => (a -> f0 b) -> ExceptT e f a -> f0 (ExceptT e f b) #

sequenceA :: Applicative f0 => ExceptT e f (f0 a) -> f0 (ExceptT e f a) #

mapM :: Monad m => (a -> m b) -> ExceptT e f a -> m (ExceptT e f b) #

sequence :: Monad m => ExceptT e f (m a) -> m (ExceptT e f a) #

(Functor m, Monad m, Monoid e) => Alternative (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

empty :: ExceptT e m a #

(<|>) :: ExceptT e m a -> ExceptT e m a -> ExceptT e m a #

some :: ExceptT e m a -> ExceptT e m [a] #

many :: ExceptT e m a -> ExceptT e m [a] #

(Monad m, Monoid e) => MonadPlus (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

mzero :: ExceptT e m a #

mplus :: ExceptT e m a -> ExceptT e m a -> ExceptT e m a #

Contravariant m => Contravariant (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

contramap :: (a -> b) -> ExceptT e m b -> ExceptT e m a #

(>$) :: b -> ExceptT e m b -> ExceptT e m a #

(Eq e, Eq1 m) => Eq1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftEq :: (a -> b -> Bool) -> ExceptT e m a -> ExceptT e m b -> Bool #

(Ord e, Ord1 m) => Ord1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftCompare :: (a -> b -> Ordering) -> ExceptT e m a -> ExceptT e m b -> Ordering #

(Read e, Read1 m) => Read1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (ExceptT e m a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [ExceptT e m a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (ExceptT e m a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [ExceptT e m a] #

(Show e, Show1 m) => Show1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ExceptT e m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ExceptT e m a] -> ShowS #

MonadZip m => MonadZip (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

mzip :: ExceptT e m a -> ExceptT e m b -> ExceptT e m (a, b) #

mzipWith :: (a -> b -> c) -> ExceptT e m a -> ExceptT e m b -> ExceptT e m c #

munzip :: ExceptT e m (a, b) -> (ExceptT e m a, ExceptT e m b) #

MonadIO m => MonadIO (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftIO :: IO a -> ExceptT e m a #

(Eq e, Eq1 m, Eq a) => Eq (ExceptT e m a) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

(==) :: ExceptT e m a -> ExceptT e m a -> Bool #

(/=) :: ExceptT e m a -> ExceptT e m a -> Bool #

(Ord e, Ord1 m, Ord a) => Ord (ExceptT e m a) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

compare :: ExceptT e m a -> ExceptT e m a -> Ordering #

(<) :: ExceptT e m a -> ExceptT e m a -> Bool #

(<=) :: ExceptT e m a -> ExceptT e m a -> Bool #

(>) :: ExceptT e m a -> ExceptT e m a -> Bool #

(>=) :: ExceptT e m a -> ExceptT e m a -> Bool #

max :: ExceptT e m a -> ExceptT e m a -> ExceptT e m a #

min :: ExceptT e m a -> ExceptT e m a -> ExceptT e m a #

(Read e, Read1 m, Read a) => Read (ExceptT e m a) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

readsPrec :: Int -> ReadS (ExceptT e m a) #

readList :: ReadS [ExceptT e m a] #

readPrec :: ReadPrec (ExceptT e m a) #

readListPrec :: ReadPrec [ExceptT e m a] #

(Show e, Show1 m, Show a) => Show (ExceptT e m a) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

showsPrec :: Int -> ExceptT e m a -> ShowS #

show :: ExceptT e m a -> String #

showList :: [ExceptT e m a] -> ShowS #

data Path (p :: k -> k -> Type) (x :: k) (y :: k) where #

A Path with steps in p is a singly linked list of "type-aligned" constructions of p.

>>> :{
let
  path :: Path (->) String Int
  path = length :>> (\x -> x^2) :>> Done
in
  qfold path "hello"
:}
25

Constructors

Done :: forall k (p :: k -> k -> Type) (x :: k). Path p x x 
(:>>) :: forall k (p :: k -> k -> Type) (x :: k) (y1 :: k) (y :: k). p x y1 -> Path p y1 y -> Path p x y infixr 7 

Instances

Instances details
QFunctor (Path :: (k -> k -> Type) -> k -> k -> Type) 
Instance details

Defined in Control.Category.Free

Methods

qmap :: forall p q (x :: k2) (y :: k3). (forall (x1 :: k0) (y1 :: k1). p x1 y1 -> q x1 y1) -> Path p x y -> Path q x y #

QPointed (Path :: (k -> k -> Type) -> k -> k -> Type) 
Instance details

Defined in Control.Category.Free

Methods

qsingle :: forall p (x :: k0) (y :: k1). p x y -> Path p x y #

QMonad (Path :: (k -> k -> Type) -> k -> k -> Type) 
Instance details

Defined in Control.Category.Free

Methods

qjoin :: forall (p :: k0 -> k1 -> Type) (x :: k0) (y :: k1). Path (Path p) x y -> Path p x y #

qbind :: forall p (q :: k0 -> k1 -> Type) (x :: k0) (y :: k1). (forall (x1 :: k0) (y1 :: k1). p x1 y1 -> Path q x1 y1) -> Path p x y -> Path q x y #

CFree (Path :: (k -> k -> Type) -> k -> k -> Type) 
Instance details

Defined in Control.Category.Free

QFoldable (Path :: (k -> k -> Type) -> k -> k -> Type) 
Instance details

Defined in Control.Category.Free

Methods

qfoldMap :: forall q p (x :: k0) (y :: k0). Category q => (forall (x1 :: k0) (y1 :: k0). p x1 y1 -> q x1 y1) -> Path p x y -> q x y #

qfold :: forall q (x :: k0) (y :: k0). Category q => Path q x y -> q x y #

qfoldr :: forall k1 p q (y :: k0) (z :: k1) (x :: k0). (forall (x1 :: k0) (y1 :: k0) (z1 :: k1). p x1 y1 -> q y1 z1 -> q x1 z1) -> q y z -> Path p x y -> q x z #

qfoldl :: forall k1 q p (x :: k1) (y :: k0) (z :: k0). (forall (x1 :: k1) (y1 :: k0) (z1 :: k0). q x1 y1 -> p y1 z1 -> q x1 z1) -> q x y -> Path p y z -> q x z #

qtoMonoid :: forall m p (x :: k0) (y :: k0). Monoid m => (forall (x1 :: k0) (y1 :: k0). p x1 y1 -> m) -> Path p x y -> m #

qtoList :: forall p a (x :: k0) (y :: k0). (forall (x1 :: k0) (y1 :: k0). p x1 y1 -> a) -> Path p x y -> [a] #

qtraverse_ :: forall m q p (x :: k0) (y :: k0). (Applicative m, Category q) => (forall (x1 :: k0) (y1 :: k0). p x1 y1 -> m (q x1 y1)) -> Path p x y -> m (q x y) #

QTraversable (Path :: (k -> k -> Type) -> k -> k -> Type) 
Instance details

Defined in Control.Category.Free

Methods

qtraverse :: forall m p q (x :: k0) (y :: k0). Applicative m => (forall (x1 :: k0) (y1 :: k0). p x1 y1 -> m (q x1 y1)) -> Path p x y -> m (Path q x y) #

Category (Path p :: k -> k -> Type) 
Instance details

Defined in Control.Category.Free

Methods

id :: forall (a :: k0). Path p a a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). Path p b c -> Path p a b -> Path p a c #

(KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (Path (CommonTableExpression statement db params) with with1) 
Instance details

Defined in Squeal.PostgreSQL.Query.With

Methods

as :: statement with db params common -> Alias cte -> Path (CommonTableExpression statement db params) with with1 #

(forall (x1 :: k) (y1 :: k). Show (p x1 y1)) => Show (Path p x y) 
Instance details

Defined in Control.Category.Free

Methods

showsPrec :: Int -> Path p x y -> ShowS #

show :: Path p x y -> String #

showList :: [Path p x y] -> ShowS #

x ~ y => Semigroup (Path p x y) 
Instance details

Defined in Control.Category.Free

Methods

(<>) :: Path p x y -> Path p x y -> Path p x y #

sconcat :: NonEmpty (Path p x y) -> Path p x y #

stimes :: Integral b => b -> Path p x y -> Path p x y #

x ~ y => Monoid (Path p x y) 
Instance details

Defined in Control.Category.Free

Methods

mempty :: Path p x y #

mappend :: Path p x y -> Path p x y -> Path p x y #

mconcat :: [Path p x y] -> Path p x y #

data IsoQ (c :: k -> k -> Type) (x :: k) (y :: k) #

Arrows of IsoQ are bidirectional edges.

Constructors

IsoQ 

Fields

Instances

Instances details
Category c => Category (IsoQ c :: k -> k -> Type) 
Instance details

Defined in Data.Quiver

Methods

id :: forall (a :: k0). IsoQ c a a #

(.) :: forall (b :: k0) (c0 :: k0) (a :: k0). IsoQ c b c0 -> IsoQ c a b -> IsoQ c a c0 #

Migratory (IsoQ (Indexed PQ IO ())) (IsoQ (Indexed PQ IO ()))

impure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ (Indexed PQ IO ()))) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

Migratory (IsoQ Definition) (IsoQ (Indexed PQ IO ()))

pure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ Definition)) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

(Eq (c x y), Eq (c y x)) => Eq (IsoQ c x y) 
Instance details

Defined in Data.Quiver

Methods

(==) :: IsoQ c x y -> IsoQ c x y -> Bool #

(/=) :: IsoQ c x y -> IsoQ c x y -> Bool #

(Ord (c x y), Ord (c y x)) => Ord (IsoQ c x y) 
Instance details

Defined in Data.Quiver

Methods

compare :: IsoQ c x y -> IsoQ c x y -> Ordering #

(<) :: IsoQ c x y -> IsoQ c x y -> Bool #

(<=) :: IsoQ c x y -> IsoQ c x y -> Bool #

(>) :: IsoQ c x y -> IsoQ c x y -> Bool #

(>=) :: IsoQ c x y -> IsoQ c x y -> Bool #

max :: IsoQ c x y -> IsoQ c x y -> IsoQ c x y #

min :: IsoQ c x y -> IsoQ c x y -> IsoQ c x y #

(Show (c x y), Show (c y x)) => Show (IsoQ c x y) 
Instance details

Defined in Data.Quiver

Methods

showsPrec :: Int -> IsoQ c x y -> ShowS #

show :: IsoQ c x y -> String #

showList :: [IsoQ c x y] -> ShowS #

(Category c, x ~ y) => Semigroup (IsoQ c x y) 
Instance details

Defined in Data.Quiver

Methods

(<>) :: IsoQ c x y -> IsoQ c x y -> IsoQ c x y #

sconcat :: NonEmpty (IsoQ c x y) -> IsoQ c x y #

stimes :: Integral b => b -> IsoQ c x y -> IsoQ c x y #

(Category c, x ~ y) => Monoid (IsoQ c x y) 
Instance details

Defined in Data.Quiver

Methods

mempty :: IsoQ c x y #

mappend :: IsoQ c x y -> IsoQ c x y -> IsoQ c x y #

mconcat :: [IsoQ c x y] -> IsoQ c x y #

newtype K a (b :: k) #

The constant type functor.

Like Constant, but kind-polymorphic in its second argument and with a shorter name.

Constructors

K a 

Instances

Instances details
IsPGlabel label (y -> K y label) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

label :: y -> K y label #

IsPGlabel label (y -> NP (K y :: Symbol -> Type) '[label]) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

label :: y -> NP (K y) '[label] #

Eq2 (K :: Type -> Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> K a c -> K b d -> Bool #

Ord2 (K :: Type -> Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> K a c -> K b d -> Ordering #

Read2 (K :: Type -> Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (K a b) #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [K a b] #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (K a b) #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [K a b] #

Show2 (K :: Type -> Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> K a b -> ShowS #

liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [K a b] -> ShowS #

NFData2 (K :: Type -> Type -> Type)

Since: sop-core-0.2.5.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftRnf2 :: (a -> ()) -> (b -> ()) -> K a b -> () #

Functor (K a :: Type -> Type) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

fmap :: (a0 -> b) -> K a a0 -> K a b #

(<$) :: a0 -> K a b -> K a a0 #

Monoid a => Applicative (K a :: Type -> Type) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

pure :: a0 -> K a a0 #

(<*>) :: K a (a0 -> b) -> K a a0 -> K a b #

liftA2 :: (a0 -> b -> c) -> K a a0 -> K a b -> K a c #

(*>) :: K a a0 -> K a b -> K a b #

(<*) :: K a a0 -> K a b -> K a a0 #

Foldable (K a :: Type -> Type) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

fold :: Monoid m => K a m -> m #

foldMap :: Monoid m => (a0 -> m) -> K a a0 -> m #

foldMap' :: Monoid m => (a0 -> m) -> K a a0 -> m #

foldr :: (a0 -> b -> b) -> b -> K a a0 -> b #

foldr' :: (a0 -> b -> b) -> b -> K a a0 -> b #

foldl :: (b -> a0 -> b) -> b -> K a a0 -> b #

foldl' :: (b -> a0 -> b) -> b -> K a a0 -> b #

foldr1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 #

foldl1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 #

toList :: K a a0 -> [a0] #

null :: K a a0 -> Bool #

length :: K a a0 -> Int #

elem :: Eq a0 => a0 -> K a a0 -> Bool #

maximum :: Ord a0 => K a a0 -> a0 #

minimum :: Ord a0 => K a a0 -> a0 #

sum :: Num a0 => K a a0 -> a0 #

product :: Num a0 => K a a0 -> a0 #

Traversable (K a :: Type -> Type) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

traverse :: Applicative f => (a0 -> f b) -> K a a0 -> f (K a b) #

sequenceA :: Applicative f => K a (f a0) -> f (K a a0) #

mapM :: Monad m => (a0 -> m b) -> K a a0 -> m (K a b) #

sequence :: Monad m => K a (m a0) -> m (K a a0) #

Eq a => Eq1 (K a :: Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftEq :: (a0 -> b -> Bool) -> K a a0 -> K a b -> Bool #

Ord a => Ord1 (K a :: Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftCompare :: (a0 -> b -> Ordering) -> K a a0 -> K a b -> Ordering #

Read a => Read1 (K a :: Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (K a a0) #

liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [K a a0] #

liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (K a a0) #

liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [K a a0] #

Show a => Show1 (K a :: Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> K a a0 -> ShowS #

liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [K a a0] -> ShowS #

NFData a => NFData1 (K a :: Type -> Type)

Since: sop-core-0.2.5.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftRnf :: (a0 -> ()) -> K a a0 -> () #

Eq a => Eq (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

(==) :: K a b -> K a b -> Bool #

(/=) :: K a b -> K a b -> Bool #

Ord a => Ord (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

compare :: K a b -> K a b -> Ordering #

(<) :: K a b -> K a b -> Bool #

(<=) :: K a b -> K a b -> Bool #

(>) :: K a b -> K a b -> Bool #

(>=) :: K a b -> K a b -> Bool #

max :: K a b -> K a b -> K a b #

min :: K a b -> K a b -> K a b #

Read a => Read (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

readsPrec :: Int -> ReadS (K a b) #

readList :: ReadS [K a b] #

readPrec :: ReadPrec (K a b) #

readListPrec :: ReadPrec [K a b] #

Show a => Show (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

showsPrec :: Int -> K a b -> ShowS #

show :: K a b -> String #

showList :: [K a b] -> ShowS #

Generic (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

Associated Types

type Rep (K a b) :: Type -> Type #

Methods

from :: K a b -> Rep (K a b) x #

to :: Rep (K a b) x -> K a b #

Semigroup a => Semigroup (K a b)

Since: sop-core-0.4.0.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

(<>) :: K a b -> K a b -> K a b #

sconcat :: NonEmpty (K a b) -> K a b #

stimes :: Integral b0 => b0 -> K a b -> K a b #

Monoid a => Monoid (K a b)

Since: sop-core-0.4.0.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

mempty :: K a b #

mappend :: K a b -> K a b -> K a b #

mconcat :: [K a b] -> K a b #

NFData a => NFData (K a b)

Since: sop-core-0.2.5.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

rnf :: K a b -> () #

type Rep (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

type Rep (K a b) = D1 ('MetaData "K" "Data.SOP.BasicFunctors" "sop-core-0.5.0.1-LSgc1wfRk3m3wHkiLjj5ug" 'True) (C1 ('MetaCons "K" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
type Code (K a b) 
Instance details

Defined in Generics.SOP.Instances

type Code (K a b) = '['[a]]
type DatatypeInfoOf (K a b) 
Instance details

Defined in Generics.SOP.Instances

type DatatypeInfoOf (K a b) = 'Newtype "Data.SOP.BasicFunctors" "K" ('Constructor "K")

unK :: forall k a (b :: k). K a b -> a #

Extract the contents of a K value.

data NP (a :: k -> Type) (b :: [k]) where #

An n-ary product.

The product is parameterized by a type constructor f and indexed by a type-level list xs. The length of the list determines the number of elements in the product, and if the i-th element of the list is of type x, then the i-th element of the product is of type f x.

The constructor names are chosen to resemble the names of the list constructors.

Two common instantiations of f are the identity functor I and the constant functor K. For I, the product becomes a heterogeneous list, where the type-level list describes the types of its components. For K a, the product becomes a homogeneous list, where the contents of the type-level list are ignored, but its length still specifies the number of elements.

In the context of the SOP approach to generic programming, an n-ary product describes the structure of the arguments of a single data constructor.

Examples:

I 'x'    :* I True  :* Nil  ::  NP I       '[ Char, Bool ]
K 0      :* K 1     :* Nil  ::  NP (K Int) '[ Char, Bool ]
Just 'x' :* Nothing :* Nil  ::  NP Maybe   '[ Char, Bool ]

Constructors

Nil :: forall k (a :: k -> Type). NP a ('[] :: [k]) 
(:*) :: forall k (a :: k -> Type) (x :: k) (xs :: [k]). a x -> NP a xs -> NP a (x ': xs) infixr 5 

Instances

Instances details
(Has rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsQualified rel col (NP (By rels) bys) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

(!) :: Alias rel -> Alias col -> NP (By rels) bys #

(Has tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsQualified tab col (NP (Expression 'Ungrouped lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression 'Ungrouped lat with db params from) tys #

(Has tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression 'Ungrouped lat with db params from)) columns #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsQualified tab col (NP (Expression ('Grouped bys) lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression ('Grouped bys) lat with db params from) tys #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns #

HTrans (NP :: (k1 -> Type) -> [k1] -> Type) (NP :: (k2 -> Type) -> [k2] -> Type) 
Instance details

Defined in Data.SOP.NP

Methods

htrans :: forall c (xs :: l1) (ys :: l2) proxy f g. AllZipN (Prod NP) c xs ys => proxy c -> (forall (x :: k10) (y :: k20). c x y => f x -> g y) -> NP f xs -> NP g ys #

hcoerce :: forall (f :: k10 -> Type) (g :: k20 -> Type) (xs :: l1) (ys :: l2). AllZipN (Prod NP) (LiftedCoercible f g) xs ys => NP f xs -> NP g ys #

HSequence (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

Methods

hsequence' :: forall (xs :: l) f (g :: k0 -> Type). (SListIN NP xs, Applicative f) => NP (f :.: g) xs -> f (NP g xs) #

hctraverse' :: forall c (xs :: l) g proxy f f'. (AllN NP c xs, Applicative g) => proxy c -> (forall (a :: k0). c a => f a -> g (f' a)) -> NP f xs -> g (NP f' xs) #

htraverse' :: forall (xs :: l) g f f'. (SListIN NP xs, Applicative g) => (forall (a :: k0). f a -> g (f' a)) -> NP f xs -> g (NP f' xs) #

HTraverse_ (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

Methods

hctraverse_ :: forall c (xs :: l) g proxy f. (AllN NP c xs, Applicative g) => proxy c -> (forall (a :: k0). c a => f a -> g ()) -> NP f xs -> g () #

htraverse_ :: forall (xs :: l) g f. (SListIN NP xs, Applicative g) => (forall (a :: k0). f a -> g ()) -> NP f xs -> g () #

HCollapse (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

Methods

hcollapse :: forall (xs :: l) a. SListIN NP xs => NP (K a) xs -> CollapseTo NP a #

HAp (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

Methods

hap :: forall (f :: k0 -> Type) (g :: k0 -> Type) (xs :: l). Prod NP (f -.-> g) xs -> NP f xs -> NP g xs #

HPure (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

Methods

hpure :: forall (xs :: l) f. SListIN NP xs => (forall (a :: k0). f a) -> NP f xs #

hcpure :: forall c (xs :: l) proxy f. AllN NP c xs => proxy c -> (forall (a :: k0). c a => f a) -> NP f xs #

(KnownSymbol alias, tys ~ '[alias ::: ty]) => Aliasable alias (expression ty) (NP (Aliased expression) tys) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

as :: expression ty -> Alias alias -> NP (Aliased expression) tys #

IsPGlabel label (y -> NP (K y :: Symbol -> Type) '[label]) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

label :: y -> NP (K y) '[label] #

Additional (NP expr :: [a] -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Type.List

Methods

also :: forall (ys :: [a0]) (xs :: [a0]). NP expr ys -> NP expr xs -> NP expr (Join xs ys) #

(HasUnique rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsLabel col (NP (By rels) bys) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

fromLabel :: NP (By rels) bys #

(HasUnique tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsLabel col (NP (Expression 'Ungrouped lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Expression 'Ungrouped lat with db params from) tys #

(HasUnique tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression 'Ungrouped lat with db params from)) columns #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsLabel col (NP (Expression ('Grouped bys) lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Expression ('Grouped bys) lat with db params from) tys #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns #

aliases ~ '[alias] => IsLabel alias (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: NP Alias aliases #

labels ~ '[label] => IsPGlabel label (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

label :: NP PGlabel labels #

All (Compose Eq f) xs => Eq (NP f xs) 
Instance details

Defined in Data.SOP.NP

Methods

(==) :: NP f xs -> NP f xs -> Bool #

(/=) :: NP f xs -> NP f xs -> Bool #

(All (Compose Eq f) xs, All (Compose Ord f) xs) => Ord (NP f xs) 
Instance details

Defined in Data.SOP.NP

Methods

compare :: NP f xs -> NP f xs -> Ordering #

(<) :: NP f xs -> NP f xs -> Bool #

(<=) :: NP f xs -> NP f xs -> Bool #

(>) :: NP f xs -> NP f xs -> Bool #

(>=) :: NP f xs -> NP f xs -> Bool #

max :: NP f xs -> NP f xs -> NP f xs #

min :: NP f xs -> NP f xs -> NP f xs #

All (Compose Show f) xs => Show (NP f xs) 
Instance details

Defined in Data.SOP.NP

Methods

showsPrec :: Int -> NP f xs -> ShowS #

show :: NP f xs -> String #

showList :: [NP f xs] -> ShowS #

All (Compose Semigroup f) xs => Semigroup (NP f xs)

Since: sop-core-0.4.0.0

Instance details

Defined in Data.SOP.NP

Methods

(<>) :: NP f xs -> NP f xs -> NP f xs #

sconcat :: NonEmpty (NP f xs) -> NP f xs #

stimes :: Integral b => b -> NP f xs -> NP f xs #

(All (Compose Monoid f) xs, All (Compose Semigroup f) xs) => Monoid (NP f xs)

Since: sop-core-0.4.0.0

Instance details

Defined in Data.SOP.NP

Methods

mempty :: NP f xs #

mappend :: NP f xs -> NP f xs -> NP f xs #

mconcat :: [NP f xs] -> NP f xs #

All (Compose NFData f) xs => NFData (NP f xs)

Since: sop-core-0.2.5.0

Instance details

Defined in Data.SOP.NP

Methods

rnf :: NP f xs -> () #

All KnownSymbol labels => RenderSQL (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

renderSQL :: NP PGlabel labels -> ByteString #

All KnownSymbol aliases => RenderSQL (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

renderSQL :: NP Alias aliases -> ByteString #

type AllZipN (NP :: (k -> Type) -> [k] -> Type) (c :: a -> b -> Constraint) 
Instance details

Defined in Data.SOP.NP

type AllZipN (NP :: (k -> Type) -> [k] -> Type) (c :: a -> b -> Constraint) = AllZip c
type Same (NP :: (k1 -> Type) -> [k1] -> Type) 
Instance details

Defined in Data.SOP.NP

type Same (NP :: (k1 -> Type) -> [k1] -> Type) = NP :: (k2 -> Type) -> [k2] -> Type
type SListIN (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

type SListIN (NP :: (k -> Type) -> [k] -> Type) = SListI :: [k] -> Constraint
type Prod (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

type Prod (NP :: (k -> Type) -> [k] -> Type) = NP :: (k -> Type) -> [k] -> Type
type AllN (NP :: (k -> Type) -> [k] -> Type) (c :: k -> Constraint) 
Instance details

Defined in Data.SOP.NP

type AllN (NP :: (k -> Type) -> [k] -> Type) (c :: k -> Constraint) = All c
type CollapseTo (NP :: (k -> Type) -> [k] -> Type) a 
Instance details

Defined in Data.SOP.NP

type CollapseTo (NP :: (k -> Type) -> [k] -> Type) a = [a]

newtype StateT s (m :: Type -> Type) a #

A state transformer monad parameterized by:

  • s - The state.
  • m - The inner monad.

The return function leaves the state unchanged, while >>= uses the final state of the first computation as the initial state of the second.

Constructors

StateT 

Fields

Instances

Instances details
MonadPQ db m => MonadPQ db (StateT s m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> StateT s m (Result y) #

executeParams_ :: Statement db x () -> x -> StateT s m () #

execute :: Statement db () y -> StateT s m (Result y) #

execute_ :: Statement db () () -> StateT s m () #

executePrepared :: Traversable list => Statement db x y -> list x -> StateT s m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> StateT s m () #

MonadTrans (StateT s) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

lift :: Monad m => m a -> StateT s m a #

Monad m => Monad (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

(>>=) :: StateT s m a -> (a -> StateT s m b) -> StateT s m b #

(>>) :: StateT s m a -> StateT s m b -> StateT s m b #

return :: a -> StateT s m a #

Functor m => Functor (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

fmap :: (a -> b) -> StateT s m a -> StateT s m b #

(<$) :: a -> StateT s m b -> StateT s m a #

MonadFix m => MonadFix (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

mfix :: (a -> StateT s m a) -> StateT s m a #

MonadFail m => MonadFail (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

fail :: String -> StateT s m a #

(Functor m, Monad m) => Applicative (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

pure :: a -> StateT s m a #

(<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b #

liftA2 :: (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c #

(*>) :: StateT s m a -> StateT s m b -> StateT s m b #

(<*) :: StateT s m a -> StateT s m b -> StateT s m a #

(Functor m, MonadPlus m) => Alternative (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

empty :: StateT s m a #

(<|>) :: StateT s m a -> StateT s m a -> StateT s m a #

some :: StateT s m a -> StateT s m [a] #

many :: StateT s m a -> StateT s m [a] #

MonadPlus m => MonadPlus (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

mzero :: StateT s m a #

mplus :: StateT s m a -> StateT s m a -> StateT s m a #

Contravariant m => Contravariant (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

contramap :: (a -> b) -> StateT s m b -> StateT s m a #

(>$) :: b -> StateT s m b -> StateT s m a #

MonadIO m => MonadIO (StateT s m) 
Instance details

Defined in Control.Monad.Trans.State.Lazy

Methods

liftIO :: IO a -> StateT s m a #

data Oid #

Instances

Instances details
Eq Oid 
Instance details

Defined in Database.PostgreSQL.LibPQ

Methods

(==) :: Oid -> Oid -> Bool #

(/=) :: Oid -> Oid -> Bool #

Ord Oid 
Instance details

Defined in Database.PostgreSQL.LibPQ

Methods

compare :: Oid -> Oid -> Ordering #

(<) :: Oid -> Oid -> Bool #

(<=) :: Oid -> Oid -> Bool #

(>) :: Oid -> Oid -> Bool #

(>=) :: Oid -> Oid -> Bool #

max :: Oid -> Oid -> Oid #

min :: Oid -> Oid -> Oid #

Read Oid 
Instance details

Defined in Database.PostgreSQL.LibPQ

Show Oid 
Instance details

Defined in Database.PostgreSQL.LibPQ

Methods

showsPrec :: Int -> Oid -> ShowS #

show :: Oid -> String #

showList :: [Oid] -> ShowS #

Storable Oid 
Instance details

Defined in Database.PostgreSQL.LibPQ

Methods

sizeOf :: Oid -> Int #

alignment :: Oid -> Int #

peekElemOff :: Ptr Oid -> Int -> IO Oid #

pokeElemOff :: Ptr Oid -> Int -> Oid -> IO () #

peekByteOff :: Ptr b -> Int -> IO Oid #

pokeByteOff :: Ptr b -> Int -> Oid -> IO () #

peek :: Ptr Oid -> IO Oid #

poke :: Ptr Oid -> Oid -> IO () #

Inline Oid 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Oid -> Expr (null (PG Oid)) #

FromPG Oid 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG Oid

PGint2

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Oid :: PGType #

ToPG db Oid 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Oid -> ReaderT (K Connection db) IO Encoding #

type PG Oid 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Oid = 'PGoid

data ExecStatus #

Constructors

EmptyQuery

The string sent to the server was empty.

CommandOk

Successful completion of a command returning no data.

TuplesOk

Successful completion of a command returning data (such as a SELECT or SHOW).

CopyOut

Copy Out (from server) data transfer started.

CopyIn

Copy In (to server) data transfer started.

CopyBoth

Copy In/Out data transfer started.

BadResponse

The server's response was not understood.

NonfatalError

A nonfatal error (a notice or warning) occurred.

FatalError

A fatal error occurred.

SingleTuple

The PGresult contains a single result tuple from the current command. This status occurs only when single-row mode has been selected for the query.

data Connection #

Connection encapsulates a connection to the backend.

Instances

Instances details
Eq Connection 
Instance details

Defined in Database.PostgreSQL.LibPQ.Internal

commentOnSchema #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType). (KnownSymbol sch, Has sch db schema) 
=> Alias sch

schema

-> Text

comment

-> Definition db db 

When a user views a schema in the database (i.e. with dn+ schema), it is useful to be able to read a description.

commentOnColumn #

Arguments

:: forall (sch :: Symbol) (tab :: Symbol) (col :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (cons :: TableConstraints) (cols :: ColumnsType) (def :: Optionality) (nulltyp :: NullType). (KnownSymbol sch, KnownSymbol tab, KnownSymbol col, Has sch db schema, Has tab schema ('Table '(cons, cols)), Has col cols '(def, nulltyp)) 
=> QualifiedAlias sch tab

table

-> Alias col

column

-> Text

comment

-> Definition db db 

When a user views a table in the database (i.e. with d+ table), it is useful to be able to view descriptions of the columns in that table.

commentOnFunction #

Arguments

:: forall (sch :: Symbol) (fun :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (function :: FunctionType). (KnownSymbol sch, KnownSymbol fun, Has sch db schema, Has fun schema ('Function function)) 
=> QualifiedAlias sch fun

function

-> Text

comment

-> Definition db db 

When a user views a function in the database (i.e. with df+ function), it is useful to be able to read a description of the function.

commentOnIndex #

Arguments

:: forall (sch :: Symbol) (ind :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (index :: IndexType). (KnownSymbol sch, KnownSymbol ind, Has sch db schema, Has ind schema ('Index index)) 
=> QualifiedAlias sch ind

index

-> Text

comment

-> Definition db db 

When a user views an index in the database (i.e. with di+ index), it is useful to be able to read a description of the index.

commentOnView #

Arguments

:: forall (sch :: Symbol) (vie :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (view :: RowType). (KnownSymbol sch, KnownSymbol vie, Has sch db schema, Has vie schema ('View view)) 
=> QualifiedAlias sch vie

view

-> Text

comment

-> Definition db db 

When a user views a view in the database (i.e. with dv view), it is useful to be able to read a description of the view.

commentOnType #

Arguments

:: forall (sch :: Symbol) (typ :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (type_ :: PGType). (KnownSymbol sch, KnownSymbol typ, Has sch db schema, Has typ schema ('Typedef type_)) 
=> QualifiedAlias sch typ

type

-> Text

comment

-> Definition db db 

When a user views a type in the database (i.e with dT type), it is useful to be able to read a description of the type.

commentOnTable #

Arguments

:: forall (sch :: Symbol) (tab :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (table :: TableType). (KnownSymbol sch, KnownSymbol tab, Has sch db schema, Has tab schema ('Table table)) 
=> QualifiedAlias sch tab

table

-> Text

comment

-> Definition db db 

When a user views a table in the database (i.e. with d+ table), it is useful to be able to read a description of the table.

dropFunctionIfExists #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol). (Has sch db schema, KnownSymbol fun) 
=> QualifiedAlias sch fun

function alias

-> Definition db (Alter sch (DropSchemumIfExists fun 'Function schema) db) 

Drop a function.

>>> type Fn = 'Function ( '[ 'Null 'PGint4, 'Null 'PGint4] :=> 'Returns ( 'Null 'PGint4))
>>> :{
let
  definition :: Definition (Public '[]) (Public '[])
  definition = dropFunctionIfExists #fn
in printSQL definition
:}
DROP FUNCTION IF EXISTS "fn";

dropFunction #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol). (Has sch db schema, KnownSymbol fun) 
=> QualifiedAlias sch fun

function alias

-> Definition db (Alter sch (DropSchemum fun 'Function schema) db) 

Drop a function.

>>> type Fn = 'Function ( '[ 'Null 'PGint4, 'Null 'PGint4] :=> 'Returns ( 'Null 'PGint4))
>>> :{
let
  definition :: Definition (Public '["fn" ::: Fn]) (Public '[])
  definition = dropFunction #fn
in printSQL definition
:}
DROP FUNCTION "fn";

createOrReplaceSetFunction #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (rets :: [(Symbol, NullType)]). (Has sch db schema, KnownSymbol fun, SListI args, SListI rets) 
=> QualifiedAlias sch fun

function alias

-> NP (TypeExpression db) args

arguments

-> NP (Aliased (TypeExpression db)) rets

return type

-> FunctionDefinition db args ('ReturnsTable rets)

function definition

-> Definition db (Alter sch (CreateOrReplace fun ('Function (args :=> 'ReturnsTable rets)) schema) db) 

Create or replace a set function.

>>> type Tab = 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])
>>> type Fn = 'Function ('[ 'Null 'PGint4, 'Null 'PGint4] :=> 'ReturnsTable '["ret" ::: 'Null 'PGint4])
>>> :{
let
  definition :: Definition (Public '["tab" ::: Tab, "fn" ::: Fn]) (Public '["tab" ::: Tab, "fn" ::: Fn])
  definition = createOrReplaceSetFunction #fn (int4 *: int4) (int4 `as` #ret) $
    languageSqlQuery (select_ ((param @1 * param @2 + #col) `as` #ret) (from (table #tab)))
in printSQL definition
:}
CREATE OR REPLACE FUNCTION "fn" (int4, int4) RETURNS TABLE ("ret" int4) language sql as $$ SELECT ((($1 :: int4) * ($2 :: int4)) + "col") AS "ret" FROM "tab" AS "tab" $$;

createSetFunction #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (rets :: [(Symbol, NullType)]). (Has sch db schema, KnownSymbol fun, SListI args, SListI rets) 
=> QualifiedAlias sch fun

function alias

-> NP (TypeExpression db) args

arguments

-> NP (Aliased (TypeExpression db)) rets

return type

-> FunctionDefinition db args ('ReturnsTable rets)

function definition

-> Definition db (Alter sch (Create fun ('Function (args :=> 'ReturnsTable rets)) schema) db) 

Create a set function.

>>> type Tab = 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])
>>> type Fn = 'Function ('[ 'Null 'PGint4, 'Null 'PGint4] :=> 'ReturnsTable '["ret" ::: 'Null 'PGint4])
>>> :{
let
  definition :: Definition (Public '["tab" ::: Tab]) (Public '["tab" ::: Tab, "fn" ::: Fn])
  definition = createSetFunction #fn (int4 *: int4) (int4 `as` #ret) $
    languageSqlQuery (select_ ((param @1 * param @2 + #col) `as` #ret) (from (table #tab)))
in printSQL definition
:}
CREATE FUNCTION "fn" (int4, int4) RETURNS TABLE ("ret" int4) language sql as $$ SELECT ((($1 :: int4) * ($2 :: int4)) + "col") AS "ret" FROM "tab" AS "tab" $$;

languageSqlQuery #

Arguments

:: forall (db :: SchemasType) (args :: [NullType]) (rets :: RowType). Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db args rets

function body

-> FunctionDefinition db args ('ReturnsTable rets) 

Use a parametrized Query as a function body

languageSqlExpr #

Arguments

:: forall (db :: SchemasType) (args :: [NullType]) (ret :: NullType). Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db args ('[] :: [(Symbol, RowType)]) ret

function body

-> FunctionDefinition db args ('Returns ret) 

Use a parameterized Expression as a function body

createOrReplaceFunction #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (ret :: NullType). (Has sch db schema, KnownSymbol fun, SListI args) 
=> QualifiedAlias sch fun

function alias

-> NP (TypeExpression db) args

arguments

-> TypeExpression db ret

return type

-> FunctionDefinition db args ('Returns ret)

function definition

-> Definition db (Alter sch (CreateOrReplace fun ('Function (args :=> 'Returns ret)) schema) db) 

Create or replace a function. It is not possible to change the name or argument types or return type of a function this way.

>>> type Fn = 'Function ( '[ 'Null 'PGint4, 'Null 'PGint4] :=> 'Returns ( 'Null 'PGint4))
>>> :{
let
  definition :: Definition (Public '["fn" ::: Fn]) (Public '["fn" ::: Fn])
  definition =
    createOrReplaceFunction #fn
      (int4 *: int4) int4 $
      languageSqlExpr (param @1 @('Null 'PGint4) * param @2 @('Null 'PGint4) + 1)
in printSQL definition
:}
CREATE OR REPLACE FUNCTION "fn" (int4, int4) RETURNS int4 language sql as $$ SELECT * FROM (VALUES (((($1 :: int4) * ($2 :: int4)) + (1 :: int4)))) AS t ("ret") $$;

createFunction #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (ret :: NullType). (Has sch db schema, KnownSymbol fun, SListI args) 
=> QualifiedAlias sch fun

function alias

-> NP (TypeExpression db) args

arguments

-> TypeExpression db ret

return type

-> FunctionDefinition db args ('Returns ret)

function definition

-> Definition db (Alter sch (Create fun ('Function (args :=> 'Returns ret)) schema) db) 

Create a function.

>>> type Fn = 'Function ( '[ 'Null 'PGint4, 'Null 'PGint4] :=> 'Returns ( 'Null 'PGint4))
>>> :{
let
  definition :: Definition (Public '[]) (Public '["fn" ::: Fn])
  definition = createFunction #fn (int4 *: int4) int4 $
    languageSqlExpr (param @1 * param @2 + 1)
in printSQL definition
:}
CREATE FUNCTION "fn" (int4, int4) RETURNS int4 language sql as $$ SELECT * FROM (VALUES (((($1 :: int4) * ($2 :: int4)) + (1 :: int4)))) AS t ("ret") $$;

newtype FunctionDefinition (db :: k) (args :: k1) (ret :: k2) #

Body of a user defined function

Instances

Instances details
Eq (FunctionDefinition db args ret) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Function

Methods

(==) :: FunctionDefinition db args ret -> FunctionDefinition db args ret -> Bool #

(/=) :: FunctionDefinition db args ret -> FunctionDefinition db args ret -> Bool #

Show (FunctionDefinition db args ret) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Function

Methods

showsPrec :: Int -> FunctionDefinition db args ret -> ShowS #

show :: FunctionDefinition db args ret -> String #

showList :: [FunctionDefinition db args ret] -> ShowS #

Generic (FunctionDefinition db args ret) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Function

Associated Types

type Rep (FunctionDefinition db args ret) :: Type -> Type #

Methods

from :: FunctionDefinition db args ret -> Rep (FunctionDefinition db args ret) x #

to :: Rep (FunctionDefinition db args ret) x -> FunctionDefinition db args ret #

NFData (FunctionDefinition db args ret) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Function

Methods

rnf :: FunctionDefinition db args ret -> () #

RenderSQL (FunctionDefinition db args ret) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Function

Methods

renderSQL :: FunctionDefinition db args ret -> ByteString #

type Rep (FunctionDefinition db args ret) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Function

type Rep (FunctionDefinition db args ret) = D1 ('MetaData "FunctionDefinition" "Squeal.PostgreSQL.Definition.Function" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeFunctionDefinition" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderFunctionDefinition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

dropIndexIfExists :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (ix :: Symbol). (Has sch db schema, KnownSymbol ix) => QualifiedAlias sch ix -> Definition db (Alter sch (DropSchemumIfExists ix 'Index schema) db) #

Drop an index if it exists.

dropIndex :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (ix :: Symbol). (Has sch db schema, KnownSymbol ix) => QualifiedAlias sch ix -> Definition db (Alter sch (DropSchemum ix 'Index schema) db) #

Drop an index.

>>> printSQL (dropIndex #ix :: Definition (Public '["ix" ::: 'Index 'Btree]) (Public '[]))
DROP INDEX "ix";

brin :: IndexMethod 'Brin #

BRIN indexes (a shorthand for Block Range INdexes) store summaries about the values stored in consecutive physical block ranges of a table.

gin :: IndexMethod 'Gin #

GIN indexes are “inverted indexes” which are appropriate for data values that contain multiple component values, such as arrays.

spgist :: IndexMethod 'Spgist #

SP-GiST indexes, like GiST indexes, offer an infrastructure that supports various kinds of searches.

gist :: IndexMethod 'Gist #

GiST indexes are not a single kind of index, but rather an infrastructure within which many different indexing strategies can be implemented.

hash :: IndexMethod 'Hash #

Hash indexes can only handle simple equality comparisons.

btree :: IndexMethod 'Btree #

B-trees can handle equality and range queries on data that can be sorted into some ordering.

createIndexIfNotExists #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (ix :: Symbol) (method :: IndexType). (Has sch db schema, Has tab schema ('Table table), KnownSymbol ix) 
=> Alias ix

index alias

-> QualifiedAlias sch tab

table alias

-> IndexMethod method

index method

-> [SortExpression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[tab ::: TableToRow table]]

sorted columns

-> Definition db (Alter sch (CreateIfNotExists ix ('Index method) schema) db) 

Create an index if it doesn't exist.

createIndex #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (ix :: Symbol) (method :: IndexType). (Has sch db schema, Has tab schema ('Table table), KnownSymbol ix) 
=> Alias ix

index alias

-> QualifiedAlias sch tab

table alias

-> IndexMethod method

index method

-> [SortExpression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[tab ::: TableToRow table]]

sorted columns

-> Definition db (Alter sch (Create ix ('Index method) schema) db) 

Create an index.

>>> :{
type Table = '[] :=>
  '[ "a" ::: 'NoDef :=> 'Null 'PGint4
   , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ]
:}
>>> :{
let
  setup :: Definition (Public '[]) (Public '["tab" ::: 'Table Table, "ix" ::: 'Index 'Btree])
  setup =
    createTable #tab (nullable int `as` #a :* nullable real `as` #b) Nil >>>
    createIndex #ix #tab btree [#a & AscNullsFirst, #b & AscNullsLast]
in printSQL setup
:}
CREATE TABLE "tab" ("a" int NULL, "b" real NULL);
CREATE INDEX "ix" ON "tab" USING btree (("a") ASC NULLS FIRST, ("b") ASC NULLS LAST);

newtype IndexMethod (ty :: k) #

PostgreSQL provides several index types: B-tree, Hash, GiST, SP-GiST, GIN and BRIN. Each index type uses a different algorithm that is best suited to different types of queries.

Instances

Instances details
Eq (IndexMethod ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Index

Methods

(==) :: IndexMethod ty -> IndexMethod ty -> Bool #

(/=) :: IndexMethod ty -> IndexMethod ty -> Bool #

Ord (IndexMethod ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Index

Show (IndexMethod ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Index

Generic (IndexMethod ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Index

Associated Types

type Rep (IndexMethod ty) :: Type -> Type #

Methods

from :: IndexMethod ty -> Rep (IndexMethod ty) x #

to :: Rep (IndexMethod ty) x -> IndexMethod ty #

RenderSQL (IndexMethod ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Index

type Rep (IndexMethod ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Index

type Rep (IndexMethod ty) = D1 ('MetaData "IndexMethod" "Squeal.PostgreSQL.Definition.Index" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeIndexMethod" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderIndexMethod") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

dropProcedureIfExists #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol). (Has sch db schema, KnownSymbol pro) 
=> QualifiedAlias sch pro

procedure alias

-> Definition db (Alter sch (DropSchemumIfExists pro 'Procedure schema) db) 

Drop a procedure.

>>> type Proc = 'Procedure '[ 'Null 'PGint4, 'Null 'PGint4 ]
>>> :{
let
  definition :: Definition (Public '[]) (Public '[])
  definition = dropProcedureIfExists #proc
in printSQL definition
:}
DROP PROCEDURE IF EXISTS "proc";

dropProcedure #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol). (Has sch db schema, KnownSymbol pro) 
=> QualifiedAlias sch pro

procedure alias

-> Definition db (Alter sch (DropSchemum pro 'Procedure schema) db) 

Drop a procedure.

>>> type Proc = 'Procedure '[ 'Null 'PGint4, 'Null 'PGint4]
>>> :{
let
  definition :: Definition (Public '["proc" ::: Proc]) (Public '[])
  definition = dropProcedure #proc
in printSQL definition
:}
DROP PROCEDURE "proc";

languageSqlManipulation #

Arguments

:: forall (db :: SchemasType) (args :: [NullType]). [Manipulation ('[] :: [(Symbol, RowType)]) db args ('[] :: [(Symbol, NullType)])]

procedure body

-> ProcedureDefinition db args 

Use a parameterized Manipulation as a procedure body

createOrReplaceProcedure #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol) (args :: [NullType]). (Has sch db schema, KnownSymbol pro, SListI args) 
=> QualifiedAlias sch pro

procedure alias

-> NP (TypeExpression db) args

arguments

-> ProcedureDefinition db args

procedure definition

-> Definition db (Alter sch (CreateOrReplace pro ('Procedure args) schema) db) 

Create or replace a procedure. It is not possible to change the name or argument types of a procedure this way.

>>> type Proc = 'Procedure '[ 'NotNull 'PGint4 ]
>>> type Thing = 'Table ('[] :=> '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4 ])
>>> :{
let
  definition :: Definition (Public '["things" ::: Thing ]) (Public '["things" ::: Thing, "proc" ::: Proc])
  definition = createOrReplaceProcedure #proc (one int4) 
             . languageSqlManipulation
             $ [deleteFrom_ #things (#id .== param @1)]
in printSQL definition
:}
CREATE OR REPLACE PROCEDURE "proc" (int4) language sql as $$ DELETE FROM "things" AS "things" WHERE ("id" = ($1 :: int4)); $$;

createProcedure #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol) (args :: [NullType]). (Has sch db schema, KnownSymbol pro, SListI args) 
=> QualifiedAlias sch pro

procedure alias

-> NP (TypeExpression db) args

arguments

-> ProcedureDefinition db args

procedure definition

-> Definition db (Alter sch (Create pro ('Procedure args) schema) db) 

Create a procedure.

>>> type Proc = 'Procedure '[ 'NotNull 'PGint4 ]
>>> type Thing = 'Table ('[] :=> '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4 ])
>>> :{
let
  definition :: Definition (Public '["things" ::: Thing ]) (Public '["things" ::: Thing, "proc" ::: Proc])
  definition = createProcedure #proc (one int4) 
             . languageSqlManipulation
             $ [deleteFrom_ #things (#id .== param @1)]
in printSQL definition
:}
CREATE PROCEDURE "proc" (int4) language sql as $$ DELETE FROM "things" AS "things" WHERE ("id" = ($1 :: int4)); $$;

newtype ProcedureDefinition (db :: k) (args :: k1) #

Body of a user defined procedure

Instances

Instances details
Eq (ProcedureDefinition db args) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Procedure

Methods

(==) :: ProcedureDefinition db args -> ProcedureDefinition db args -> Bool #

(/=) :: ProcedureDefinition db args -> ProcedureDefinition db args -> Bool #

Show (ProcedureDefinition db args) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Procedure

Generic (ProcedureDefinition db args) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Procedure

Associated Types

type Rep (ProcedureDefinition db args) :: Type -> Type #

Methods

from :: ProcedureDefinition db args -> Rep (ProcedureDefinition db args) x #

to :: Rep (ProcedureDefinition db args) x -> ProcedureDefinition db args #

NFData (ProcedureDefinition db args) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Procedure

Methods

rnf :: ProcedureDefinition db args -> () #

RenderSQL (ProcedureDefinition db args) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Procedure

type Rep (ProcedureDefinition db args) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Procedure

type Rep (ProcedureDefinition db args) = D1 ('MetaData "ProcedureDefinition" "Squeal.PostgreSQL.Definition.Procedure" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeProcedureDefinition" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderProcedureDefinition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

dropSchemaCascadeIfExists #

Arguments

:: forall (sch :: Symbol) (db :: SchemasType). KnownSymbol sch 
=> Alias sch

schema alias

-> Definition db (DropIfExists sch db) 

Drop a schema if it exists. Automatically drop objects (tables, functions, etc.) that are contained in the schema.

dropSchemaCascade #

Arguments

:: forall (sch :: Symbol) (db :: SchemasType). KnownSymbol sch 
=> Alias sch

schema alias

-> Definition db (Drop sch db) 

Drop a schema. Automatically drop objects (tables, functions, etc.) that are contained in the schema.

>>> :{
let
  definition :: Definition '["muh_schema" ::: schema, "public" ::: public] '["public" ::: public]
  definition = dropSchemaCascade #muh_schema
:}
>>> printSQL definition
DROP SCHEMA "muh_schema" CASCADE;

createSchemaIfNotExists #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType). (KnownSymbol sch, Has sch db schema) 
=> Alias sch

schema alias

-> Definition db (CreateIfNotExists sch ('[] :: [(Symbol, SchemumType)]) db) 

Create a schema if it does not yet exist.

createSchema #

Arguments

:: forall (sch :: Symbol) (db :: SchemasType). KnownSymbol sch 
=> Alias sch

schema alias

-> Definition db (Create sch ('[] :: [(Symbol, SchemumType)]) db) 

createSchema enters a new schema into the current database. The schema name must be distinct from the name of any existing schema in the current database.

A schema is essentially a namespace: it contains named objects (tables, data types, functions, and operators) whose names can duplicate those of other objects existing in other schemas. Named objects are accessed by QualifiedAliases with the schema name as a prefix.

>>> :{
let
  definition :: Definition '["public" ::: '[]] '["public" ::: '[], "my_schema" ::: '[]]
  definition = createSchema #my_schema
in printSQL definition
:}
CREATE SCHEMA "my_schema";

mainMigrateIso #

Arguments

:: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory (IsoQ def) (IsoQ (Indexed PQ IO ())) 
=> ByteString

connection string

-> Path (Migration (IsoQ def)) db0 db1

migrations

-> IO () 

mainMigrateIso creates a simple executable from a connection string and a Path of Migration IsoQs.

mainMigrate #

Arguments

:: forall (p :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory p (Indexed PQ IO ()) 
=> ByteString

connection string

-> Path (Migration p) db0 db1

migrations

-> IO () 

mainMigrate creates a simple executable from a connection string and a Path of Migrations.

migrateDown :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory def (IsoQ (Indexed PQ IO ())) => Path (Migration def) db0 db1 -> PQ db1 db0 IO () #

Rewind migrations.

migrateUp :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory def (IsoQ (Indexed PQ IO ())) => Path (Migration def) db0 db1 -> PQ db0 db1 IO () #

Run rewindable migrations.

migrate :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory def (Indexed PQ IO ()) => Path (Migration def) db0 db1 -> PQ db0 db1 IO () #

Run migrations.

data Migration (def :: k -> k1 -> Type) (db0 :: k) (db1 :: k1) #

A Migration consists of a name and a migration definition.

Constructors

Migration 

Fields

Instances

Instances details
QFunctor (Migration :: (k2 -> k3 -> Type) -> k2 -> k3 -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

qmap :: forall p q (x :: k20) (y :: k30). (forall (x1 :: k) (y1 :: k1). p x1 y1 -> q x1 y1) -> Migration p x y -> Migration q x y #

Generic (Migration def db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Associated Types

type Rep (Migration def db0 db1) :: Type -> Type #

Methods

from :: Migration def db0 db1 -> Rep (Migration def db0 db1) x #

to :: Rep (Migration def db0 db1) x -> Migration def db0 db1 #

type Rep (Migration def db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Session.Migration

type Rep (Migration def db0 db1) = D1 ('MetaData "Migration" "Squeal.PostgreSQL.Session.Migration" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) (C1 ('MetaCons "Migration" 'PrefixI 'True) (S1 ('MetaSel ('Just "migrationName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "migrationDef") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (def db0 db1))))

class (Category def, Category run) => Migratory (def :: k -> k -> Type) (run :: k -> k -> Type) | def -> run where #

A Migratory Category can run or possibly rewind a Path of Migrations.

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration def) db0 db1 -> run db0 db1 #

Run a Path of Migrations.

Instances

Instances details
Migratory Definition (Indexed PQ IO ())

pure migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration Definition) db0 db1 -> Indexed PQ IO () db0 db1 #

Migratory (IsoQ (Indexed PQ IO ())) (IsoQ (Indexed PQ IO ()))

impure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ (Indexed PQ IO ()))) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

Migratory (IsoQ Definition) (IsoQ (Indexed PQ IO ()))

pure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ Definition)) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

Migratory (OpQ (Indexed PQ IO ())) (OpQ (Indexed PQ IO ()))

impure rewinds

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ (Indexed PQ IO ()))) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 #

Migratory (OpQ Definition) (OpQ (Indexed PQ IO ()))

pure rewinds

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ Definition)) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 #

Migratory (Indexed PQ IO ()) (Indexed PQ IO ())

impure migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (Indexed PQ IO ())) db0 db1 -> Indexed PQ IO () db0 db1 #

type MigrationsTable = '["migrations_unique_name" ::: 'Unique '["name"]] :=> '["name" ::: ('NoDef :=> 'NotNull 'PGtext), "executed_at" ::: ('Def :=> 'NotNull 'PGtimestamptz)] #

The TableType for a Squeal migration.

alterType :: forall (db :: SchemasType) (ty :: ColumnType) (ty0 :: ColumnType). ColumnTypeExpression db ty -> AlterColumn db ty0 ty #

An alterType converts a column to a different data type. This will succeed only if each existing entry in the column can be converted to the new type by an implicit cast.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGnumeric])]]
  definition =
    alterTable #tab (alterColumn #col (alterType (numeric & notNullable)))
in printSQL definition
:}
ALTER TABLE "tab" ALTER COLUMN "col" TYPE numeric NOT NULL;

dropNotNull :: forall (db :: SchemasType) (constraint :: Optionality) (ty :: PGType). AlterColumn db (constraint :=> 'NotNull ty) (constraint :=> 'Null ty) #

A dropNotNull drops a NOT NULL constraint from a column.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = alterTable #tab (alterColumn #col dropNotNull)
in printSQL definition
:}
ALTER TABLE "tab" ALTER COLUMN "col" DROP NOT NULL;

setNotNull :: forall (db :: SchemasType) (constraint :: Optionality) (ty :: PGType). AlterColumn db (constraint :=> 'Null ty) (constraint :=> 'NotNull ty) #

A setNotNull adds a NOT NULL constraint to a column. The constraint will be checked immediately, so the table data must satisfy the constraint before it can be added.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
  definition = alterTable #tab (alterColumn #col setNotNull)
in printSQL definition
:}
ALTER TABLE "tab" ALTER COLUMN "col" SET NOT NULL;

dropDefault :: forall (db :: SchemasType) (ty :: NullType). AlterColumn db ('Def :=> ty) ('NoDef :=> ty) #

A dropDefault removes any default value for a column.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'Def :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = alterTable #tab (alterColumn #col dropDefault)
in printSQL definition
:}
ALTER TABLE "tab" ALTER COLUMN "col" DROP DEFAULT;

setDefault #

Arguments

:: forall (db :: SchemasType) (ty :: NullType) (constraint :: Optionality). Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) ('[] :: [(Symbol, RowType)]) ty

default value to set

-> AlterColumn db (constraint :=> ty) ('Def :=> ty) 

A setDefault sets a new default for a column. Note that this doesn't affect any existing rows in the table, it just changes the default for future insert and update commands.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'Def :=> 'Null 'PGint4])]]
  definition = alterTable #tab (alterColumn #col (setDefault 5))
in printSQL definition
:}
ALTER TABLE "tab" ALTER COLUMN "col" SET DEFAULT (5 :: int4);

alterColumn #

Arguments

:: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType) (ty0 :: ColumnType) (ty1 :: ColumnType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns)), Has column columns ty0) 
=> Alias column

column to alter

-> AlterColumn db ty0 ty1

alteration to perform

-> AlterTable sch tab db (constraints :=> Alter column ty1 columns) 

An alterColumn alters a single column.

renameColumn #

Arguments

:: forall (column0 :: Symbol) (column1 :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column0, KnownSymbol column1, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) 
=> Alias column0

column to rename

-> Alias column1

what to rename the column

-> AlterTable sch tab db (constraints :=> Rename column0 column1 columns) 

A renameColumn renames a column.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["foo" ::: 'NoDef :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["bar" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = alterTable #tab (renameColumn #foo #bar)
in printSQL definition
:}
ALTER TABLE "tab" RENAME COLUMN "foo" TO "bar";

dropColumn #

Arguments

:: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) 
=> Alias column

column to remove

-> AlterTable sch tab db (constraints :=> Drop column columns) 

A dropColumn removes a column. Whatever data was in the column disappears. Table constraints involving the column are dropped, too. However, if the column is referenced by a foreign key constraint of another table, PostgreSQL will not silently drop that constraint.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=>
       '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
        , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = alterTable #tab (dropColumn #col2)
in printSQL definition
:}
ALTER TABLE "tab" DROP COLUMN "col2";

dropConstraint #

Arguments

:: forall (constraint :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol constraint, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) 
=> Alias constraint

constraint to drop

-> AlterTable sch tab db (Drop constraint constraints :=> columns) 

A dropConstraint drops a table constraint.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('["positive" ::: Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
  definition = alterTable #tab (dropConstraint #positive)
in printSQL definition
:}
ALTER TABLE "tab" DROP CONSTRAINT "positive";

addConstraint #

Arguments

:: forall (alias :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType) (constraint :: TableConstraint). (KnownSymbol alias, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) 
=> Alias alias 
-> TableConstraintExpression sch tab db constraint

constraint to add

-> AlterTable sch tab db (Create alias constraint constraints :=> columns) 

An addConstraint adds a table constraint.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('["positive" ::: 'Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
  definition = alterTable #tab (addConstraint #positive (check #col (#col .> 0)))
in printSQL definition
:}
ALTER TABLE "tab" ADD CONSTRAINT "positive" CHECK (("col" > (0 :: int4)));

alterTableSetSchema #

Arguments

:: forall (sch0 :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (sch1 :: Symbol) (schema1 :: [(Symbol, SchemumType)]). (Has sch0 db schema0, Has tab schema0 ('Table table), Has sch1 db schema1) 
=> QualifiedAlias sch0 tab

table to move

-> Alias sch1

where to move it

-> Definition db (SetSchema sch0 sch1 schema0 schema1 tab 'Table table db) 

This form moves the table into another schema.

>>> type DB0 = '[ "sch0" ::: '[ "tab" ::: 'Table ('[] :=> '[]) ], "sch1" ::: '[] ]
>>> type DB1 = '[ "sch0" ::: '[], "sch1" ::: '[ "tab" ::: 'Table ('[] :=> '[]) ] ]
>>> :{
let def :: Definition DB0 DB1
    def = alterTableSetSchema (#sch0 ! #tab) #sch1
in printSQL def
:}
ALTER TABLE "sch0"."tab" SET SCHEMA "sch1";

alterTableIfExistsRename #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab0 :: Symbol) (tab1 :: Symbol). (Has sch db schema, KnownSymbol tab0, KnownSymbol tab1) 
=> QualifiedAlias sch tab0

table to rename

-> Alias tab1

what to rename it

-> Definition db (Alter sch (RenameIfExists tab0 tab1 schema) db) 

alterTableIfExistsRename changes the name of a table from the schema if it exists.

>>> type Schemas = '[ "public" ::: '[ "foo" ::: 'Table ('[] :=> '[]) ] ]
>>> :{
 let migration :: Definition Schemas Schemas
     migration = alterTableIfExistsRename #goo #gar
 in printSQL migration
:}
ALTER TABLE IF EXISTS "goo" RENAME TO "gar";

alterTableRename #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab1 :: Symbol) (tab0 :: Symbol) (table :: TableType). (Has sch db schema, KnownSymbol tab1, Has tab0 schema ('Table table)) 
=> QualifiedAlias sch tab0

table to rename

-> Alias tab1

what to rename it

-> Definition db (Alter sch (Rename tab0 tab1 schema) db) 

alterTableRename changes the name of a table from the schema.

>>> type Schemas = '[ "public" ::: '[ "foo" ::: 'Table ('[] :=> '[]) ] ]
>>> :{
 let migration :: Definition Schemas '["public" ::: '["bar" ::: 'Table ('[] :=> '[]) ] ]
     migration = alterTableRename #foo #bar
 in printSQL migration
:}
ALTER TABLE "foo" RENAME TO "bar";

alterTableIfExists #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol) (table :: TableType). (Has sch db schema, KnownSymbol tab) 
=> QualifiedAlias sch tab

table to alter

-> AlterTable sch tab db table

alteration to perform

-> Definition db (Alter sch (AlterIfExists tab ('Table table) schema) db) 

alterTable changes the definition of a table from the schema.

alterTable #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol) (table :: TableType). (Has sch db schema, KnownSymbol tab) 
=> QualifiedAlias sch tab

table to alter

-> AlterTable sch tab db table

alteration to perform

-> Definition db (Alter sch (Alter tab ('Table table) schema) db) 

alterTable changes the definition of a table from the schema.

dropTableIfExists #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol). (Has sch db schema, KnownSymbol tab) 
=> QualifiedAlias sch tab

table to remove

-> Definition db (Alter sch (DropSchemumIfExists tab 'Table schema) db) 

Drop a table if it exists.

dropTable #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol). (Has sch db schema, KnownSymbol tab) 
=> QualifiedAlias sch tab

table to remove

-> Definition db (Alter sch (DropSchemum tab 'Table schema) db) 

dropTable removes a table from the schema.

>>> :{
let
  definition :: Definition '["public" ::: '["muh_table" ::: 'Table t]] (Public '[])
  definition = dropTable #muh_table
:}
>>> printSQL definition
DROP TABLE "muh_table";

createTableIfNotExists #

Arguments

:: forall (sch :: Symbol) (tab :: Symbol) (columns :: [(Symbol, ColumnType)]) (col :: (Symbol, ColumnType)) (cols :: [(Symbol, ColumnType)]) (constraints :: [(Symbol, TableConstraint)]) (db0 :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (db1 :: [(Symbol, [(Symbol, SchemumType)])]). (KnownSymbol sch, KnownSymbol tab, columns ~ (col ': cols), SListI columns, SListI constraints, Has sch db0 schema0, db1 ~ Alter sch (CreateIfNotExists tab ('Table (constraints :=> columns)) schema0) db0) 
=> QualifiedAlias sch tab

the name of the table to add

-> NP (Aliased (ColumnTypeExpression db0)) columns

the names and datatype of each column

-> NP (Aliased (TableConstraintExpression sch tab db1)) constraints

constraints that must hold for the table

-> Definition db0 db1 

createTableIfNotExists creates a table if it doesn't exist, but does not add it to the schema. Instead, the schema already has the table so if the table did not yet exist, the schema was wrong. createTableIfNotExists fixes this. Interestingly, this property makes it an idempotent in the Category of Definitions.

>>> :set -XOverloadedLabels -XTypeApplications
>>> :{
type Table = '[] :=>
  '[ "a" ::: 'NoDef :=> 'Null 'PGint4
   , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ]
:}
>>> type Schemas = Public '["tab" ::: 'Table Table]
>>> :{
let
  setup :: Definition Schemas Schemas
  setup = createTableIfNotExists #tab
    (nullable int `as` #a :* nullable real `as` #b) Nil
in printSQL setup
:}
CREATE TABLE IF NOT EXISTS "tab" ("a" int NULL, "b" real NULL);

createTable #

Arguments

:: forall (sch :: Symbol) (tab :: Symbol) (columns :: [(Symbol, ColumnType)]) (col :: (Symbol, ColumnType)) (cols :: [(Symbol, ColumnType)]) (constraints :: [(Symbol, TableConstraint)]) (db0 :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (db1 :: [(Symbol, [(Symbol, SchemumType)])]). (KnownSymbol sch, KnownSymbol tab, columns ~ (col ': cols), SListI columns, SListI constraints, Has sch db0 schema0, db1 ~ Alter sch (Create tab ('Table (constraints :=> columns)) schema0) db0) 
=> QualifiedAlias sch tab

the name of the table to add

-> NP (Aliased (ColumnTypeExpression db0)) columns

the names and datatype of each column

-> NP (Aliased (TableConstraintExpression sch tab db1)) constraints

constraints that must hold for the table

-> Definition db0 db1 

createTable adds a table to the schema.

>>> :set -XOverloadedLabels
>>> :{
type Table = '[] :=>
  '[ "a" ::: 'NoDef :=> 'Null 'PGint4
   , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ]
:}
>>> :{
let
  setup :: Definition (Public '[]) (Public '["tab" ::: 'Table Table])
  setup = createTable #tab
    (nullable int `as` #a :* nullable real `as` #b) Nil
in printSQL setup
:}
CREATE TABLE "tab" ("a" int NULL, "b" real NULL);

newtype AlterTable (sch :: Symbol) (tab :: Symbol) (db :: SchemasType) (table :: TableType) #

An AlterTable describes the alteration to perform on the columns of a table.

Instances

Instances details
Eq (AlterTable sch tab db table) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

(==) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool #

(/=) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool #

Ord (AlterTable sch tab db table) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

compare :: AlterTable sch tab db table -> AlterTable sch tab db table -> Ordering #

(<) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool #

(<=) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool #

(>) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool #

(>=) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool #

max :: AlterTable sch tab db table -> AlterTable sch tab db table -> AlterTable sch tab db table #

min :: AlterTable sch tab db table -> AlterTable sch tab db table -> AlterTable sch tab db table #

Show (AlterTable sch tab db table) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

showsPrec :: Int -> AlterTable sch tab db table -> ShowS #

show :: AlterTable sch tab db table -> String #

showList :: [AlterTable sch tab db table] -> ShowS #

Generic (AlterTable sch tab db table) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Associated Types

type Rep (AlterTable sch tab db table) :: Type -> Type #

Methods

from :: AlterTable sch tab db table -> Rep (AlterTable sch tab db table) x #

to :: Rep (AlterTable sch tab db table) x -> AlterTable sch tab db table #

NFData (AlterTable sch tab db table) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

rnf :: AlterTable sch tab db table -> () #

type Rep (AlterTable sch tab db table) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

type Rep (AlterTable sch tab db table) = D1 ('MetaData "AlterTable" "Squeal.PostgreSQL.Definition.Table" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeAlterTable" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderAlterTable") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

class AddColumn (ty :: ColumnType) where #

An AddColumn is either NULL or has DEFAULT.

Minimal complete definition

Nothing

Methods

addColumn #

Arguments

:: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) 
=> Alias column

column to add

-> ColumnTypeExpression db ty

type of the new column

-> AlterTable sch tab db (constraints :=> Create column ty columns) 

addColumn adds a new column, initially filled with whatever default value is given or with NULL.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=>
       '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
        , "col2" ::: 'Def :=> 'Null 'PGtext ])]]
  definition = alterTable #tab (addColumn #col2 (text & nullable & default_ "foo"))
in printSQL definition
:}
ALTER TABLE "tab" ADD COLUMN "col2" text NULL DEFAULT (E'foo' :: text);
>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=>
       '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
        , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]]
  definition = alterTable #tab (addColumn #col2 (text & nullable))
in printSQL definition
:}
ALTER TABLE "tab" ADD COLUMN "col2" text NULL;

Instances

Instances details
AddColumn ('NoDef :=> 'Null ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ('NoDef :=> 'Null ty) -> AlterTable sch tab db (constraints :=> Create column ('NoDef :=> 'Null ty) columns) #

AddColumn ('Def :=> ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ('Def :=> ty) -> AlterTable sch tab db (constraints :=> Create column ('Def :=> ty) columns) #

newtype AlterColumn (db :: SchemasType) (ty0 :: ColumnType) (ty1 :: ColumnType) #

An AlterColumn describes the alteration to perform on a single column.

Instances

Instances details
Eq (AlterColumn db ty0 ty1) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

(==) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool #

(/=) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool #

Ord (AlterColumn db ty0 ty1) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

compare :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Ordering #

(<) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool #

(<=) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool #

(>) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool #

(>=) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool #

max :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 #

min :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 #

Show (AlterColumn db ty0 ty1) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

showsPrec :: Int -> AlterColumn db ty0 ty1 -> ShowS #

show :: AlterColumn db ty0 ty1 -> String #

showList :: [AlterColumn db ty0 ty1] -> ShowS #

Generic (AlterColumn db ty0 ty1) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Associated Types

type Rep (AlterColumn db ty0 ty1) :: Type -> Type #

Methods

from :: AlterColumn db ty0 ty1 -> Rep (AlterColumn db ty0 ty1) x #

to :: Rep (AlterColumn db ty0 ty1) x -> AlterColumn db ty0 ty1 #

NFData (AlterColumn db ty0 ty1) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

rnf :: AlterColumn db ty0 ty1 -> () #

type Rep (AlterColumn db ty0 ty1) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

type Rep (AlterColumn db ty0 ty1) = D1 ('MetaData "AlterColumn" "Squeal.PostgreSQL.Definition.Table" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeAlterColumn" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderAlterColumn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

alterTypeSetSchema #

Arguments

:: forall (sch0 :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (ty :: Symbol) (td :: PGType) (sch1 :: Symbol) (schema1 :: [(Symbol, SchemumType)]). (Has sch0 db schema0, Has ty schema0 ('Typedef td), Has sch1 db schema1) 
=> QualifiedAlias sch0 ty

type to move

-> Alias sch1

where to move it

-> Definition db (SetSchema sch0 sch1 schema0 schema1 ty 'Typedef td db) 

This form moves the type into another schema.

>>> type DB0 = '[ "sch0" ::: '[ "ty" ::: 'Typedef 'PGfloat8 ], "sch1" ::: '[] ]
>>> type DB1 = '[ "sch0" ::: '[], "sch1" ::: '[ "ty" ::: 'Typedef 'PGfloat8 ] ]
>>> :{
let def :: Definition DB0 DB1
    def = alterTypeSetSchema (#sch0 ! #ty) #sch1
in printSQL def
:}
ALTER TYPE "sch0"."ty" SET SCHEMA "sch1";

alterTypeRename #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (ty1 :: Symbol) (ty0 :: Symbol) (ty :: PGType). (Has sch db schema, KnownSymbol ty1, Has ty0 schema ('Typedef ty)) 
=> QualifiedAlias sch ty0

type to rename

-> Alias ty1

what to rename it

-> Definition db (Alter sch (Rename ty0 ty1 schema) db) 

alterTypeRename changes the name of a type from the schema.

>>> type DB = '[ "public" ::: '[ "foo" ::: 'Typedef 'PGbool ] ]
>>> :{
 let def :: Definition DB '["public" ::: '["bar" ::: 'Typedef 'PGbool ] ]
     def = alterTypeRename #foo #bar
 in printSQL def
:}
ALTER TYPE "foo" RENAME TO "bar";

dropTypeIfExists #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (td :: Symbol). (Has sch db schema, KnownSymbol td) 
=> QualifiedAlias sch td

name of the user defined type

-> Definition db (Alter sch (DropSchemumIfExists td 'Typedef schema) db) 

Drop a type if it exists.

dropType #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (td :: Symbol). (Has sch db schema, KnownSymbol td) 
=> QualifiedAlias sch td

name of the user defined type

-> Definition db (Alter sch (DropSchemum td 'Typedef schema) db) 

Drop a type.

>>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
>>> instance SOP.Generic Schwarma
>>> instance SOP.HasDatatypeInfo Schwarma
>>> printSQL (dropType #schwarma :: Definition '["public" ::: '["schwarma" ::: 'Typedef (PG (Enumerated Schwarma))]] (Public '[]))
DROP TYPE "schwarma";

createTypeRange #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (range :: Symbol) (ty :: PGType). (Has sch db schema, KnownSymbol range) 
=> QualifiedAlias sch range

range alias

-> (forall (null :: PGType -> NullType). TypeExpression db (null ty))

underlying type

-> Definition db (Alter sch (Create range ('Typedef ('PGrange ty)) schema) db) 

Range types are data types representing a range of values of some element type (called the range's subtype). The subtype must have a total order so that it is well-defined whether element values are within, before, or after a range of values.

Range types are useful because they represent many element values in a single range value, and because concepts such as overlapping ranges can be expressed clearly. The use of time and date ranges for scheduling purposes is the clearest example; but price ranges, measurement ranges from an instrument, and so forth can also be useful.

>>> :{
let
  createSmallIntRange :: Definition (Public '[]) (Public '["int2range" ::: 'Typedef ('PGrange 'PGint2)])
  createSmallIntRange = createTypeRange #int2range int2
in printSQL createSmallIntRange
:}
CREATE TYPE "int2range" AS RANGE (subtype = int2);

createDomain #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (dom :: Symbol) (ty :: PGType). (Has sch db schema, KnownSymbol dom) 
=> QualifiedAlias sch dom

domain alias

-> (forall (null :: PGType -> NullType). TypeExpression db (null ty))

underlying type

-> (forall (tab :: Symbol). Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[tab ::: '["value" ::: 'Null ty]])

constraint on type

-> Definition db (Alter sch (Create dom ('Typedef ty) schema) db) 

createDomain creates a new domain. A domain is essentially a data type with constraints (restrictions on the allowed set of values).

Domains are useful for abstracting common constraints on fields into a single location for maintenance. For example, several tables might contain email address columns, all requiring the same check constraint to verify the address syntax. Define a domain rather than setting up each table's constraint individually.

>>> :{
let
  createPositive :: Definition (Public '[]) (Public '["positive" ::: 'Typedef 'PGfloat4])
  createPositive = createDomain #positive real (#value .> 0)
in printSQL createPositive
:}
CREATE DOMAIN "positive" AS real CHECK (("value" > (0.0 :: float4)));

createTypeCompositeFrom #

Arguments

:: forall hask (sch :: Symbol) (ty :: Symbol) (db :: SchemasType) (schema :: SchemaType). (All (FieldTyped db) (RowPG hask), KnownSymbol ty, Has sch db schema) 
=> QualifiedAlias sch ty

name of the user defined composite type

-> Definition db (Alter sch (Create ty ('Typedef (PG (Composite hask))) schema) db) 

Composite types can also be generated from a Haskell type, for example

>>> data Complex = Complex {real :: Double, imaginary :: Double} deriving GHC.Generic
>>> instance SOP.Generic Complex
>>> instance SOP.HasDatatypeInfo Complex
>>> type Schema = '["complex" ::: 'Typedef (PG (Composite Complex))]
>>> :{
let
  createComplex :: Definition (Public '[]) (Public Schema)
  createComplex = createTypeCompositeFrom @Complex #complex
in
  printSQL createComplex
:}
CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);

createTypeComposite #

Arguments

:: forall (ty :: Symbol) (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fields :: [(Symbol, NullType)]). (KnownSymbol ty, Has sch db schema, SListI fields) 
=> QualifiedAlias sch ty

name of the user defined composite type

-> NP (Aliased (TypeExpression db)) fields

list of attribute names and data types

-> Definition db (Alter sch (Create ty ('Typedef ('PGcomposite fields)) schema) db) 

createTypeComposite creates a composite type. The composite type is specified by a list of attribute names and data types.

>>> :{
type PGcomplex = 'PGcomposite
  '[ "real"      ::: 'NotNull 'PGfloat8
   , "imaginary" ::: 'NotNull 'PGfloat8 ]
:}
>>> :{
let
  setup :: Definition (Public '[]) '["public" ::: '["complex" ::: 'Typedef PGcomplex]]
  setup = createTypeComposite #complex
    (float8 `as` #real :* float8 `as` #imaginary)
in printSQL setup
:}
CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);

createTypeEnumFrom #

Arguments

:: forall hask (sch :: Symbol) (enum :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType). (Generic hask, All KnownSymbol (LabelsPG hask), KnownSymbol enum, Has sch db schema) 
=> QualifiedAlias sch enum

name of the user defined enumerated type

-> Definition db (Alter sch (Create enum ('Typedef (PG (Enumerated hask))) schema) db) 

Enumerated types can also be generated from a Haskell type, for example

>>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
>>> instance SOP.Generic Schwarma
>>> instance SOP.HasDatatypeInfo Schwarma
>>> :{
let
  createSchwarma :: Definition (Public '[]) '["public" ::: '["schwarma" ::: 'Typedef (PG (Enumerated Schwarma))]]
  createSchwarma = createTypeEnumFrom @Schwarma #schwarma
in
  printSQL createSchwarma
:}
CREATE TYPE "schwarma" AS ENUM ('Beef', 'Lamb', 'Chicken');

createTypeEnum #

Arguments

:: forall (enum :: Symbol) (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (labels :: [Symbol]). (KnownSymbol enum, Has sch db schema, All KnownSymbol labels) 
=> QualifiedAlias sch enum

name of the user defined enumerated type

-> NP PGlabel labels

labels of the enumerated type

-> Definition db (Alter sch (Create enum ('Typedef ('PGenum labels)) schema) db) 

Enumerated types are created using the createTypeEnum command, for example

>>> printSQL $ (createTypeEnum #mood (label @"sad" :* label @"ok" :* label @"happy") :: Definition (Public '[]) '["public" ::: '["mood" ::: 'Typedef ('PGenum '["sad","ok","happy"])]])
CREATE TYPE "mood" AS ENUM ('sad', 'ok', 'happy');

alterViewSetSchema #

Arguments

:: forall (sch0 :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (vw :: Symbol) (view :: RowType) (sch1 :: Symbol) (schema1 :: [(Symbol, SchemumType)]). (Has sch0 db schema0, Has vw schema0 ('View view), Has sch1 db schema1) 
=> QualifiedAlias sch0 vw

view to move

-> Alias sch1

where to move it

-> Definition db (SetSchema sch0 sch1 schema0 schema1 vw 'View view db) 

This form moves the view into another schema.

>>> type DB0 = '[ "sch0" ::: '[ "vw" ::: 'View '[] ], "sch1" ::: '[] ]
>>> type DB1 = '[ "sch0" ::: '[], "sch1" ::: '[ "vw" ::: 'View '[] ] ]
>>> :{
let def :: Definition DB0 DB1
    def = alterViewSetSchema (#sch0 ! #vw) #sch1
in printSQL def
:}
ALTER VIEW "sch0"."vw" SET SCHEMA "sch1";

alterViewRename #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (ty1 :: Symbol) (ty0 :: Symbol) (vw :: RowType). (Has sch db schema, KnownSymbol ty1, Has ty0 schema ('View vw)) 
=> QualifiedAlias sch ty0

view to rename

-> Alias ty1

what to rename it

-> Definition db (Alter sch (Rename ty0 ty1 schema) db) 

alterViewRename changes the name of a view from the schema.

>>> type DB = '[ "public" ::: '[ "foo" ::: 'View '[] ] ]
>>> :{
 let def :: Definition DB '["public" ::: '["bar" ::: 'View '[] ] ]
     def = alterViewRename #foo #bar
 in printSQL def
:}
ALTER VIEW "foo" RENAME TO "bar";

dropViewIfExists #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol). (Has sch db schema, KnownSymbol vw) 
=> QualifiedAlias sch vw

view to remove

-> Definition db (Alter sch (DropIfExists vw schema) db) 

Drop a view if it exists.

>>> :{
let
  definition :: Definition
    '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])
     , "bc"  ::: 'View ('["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4])]]
    '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = dropViewIfExists #bc
in printSQL definition
:}
DROP VIEW IF EXISTS "bc";

dropView #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol). (Has sch db schema, KnownSymbol vw) 
=> QualifiedAlias sch vw

view to remove

-> Definition db (Alter sch (DropSchemum vw 'View schema) db) 

Drop a view.

>>> :{
let
  definition :: Definition
    '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])
     , "bc"  ::: 'View ('["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4])]]
    '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = dropView #bc
in printSQL definition
:}
DROP VIEW "bc";

createOrReplaceView #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol) (view :: RowType). (Has sch db schema, KnownSymbol vw) 
=> QualifiedAlias sch vw

the name of the view to add

-> Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) view

query

-> Definition db (Alter sch (CreateOrReplace vw ('View view) schema) db) 

Create or replace a view.

>>> type ABC = '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4]
>>> type BC = '["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4]
>>> :{
let
  definition :: Definition
    '[ "public" ::: '["abc" ::: 'Table ('[] :=> ABC)]]
    '[ "public" ::: '["abc" ::: 'Table ('[] :=> ABC), "bc"  ::: 'View BC]]
  definition =
    createOrReplaceView #bc (select_ (#b :* #c) (from (table #abc)))
in printSQL definition
:}
CREATE OR REPLACE VIEW "bc" AS SELECT "b" AS "b", "c" AS "c" FROM "abc" AS "abc";

createView #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol) (view :: RowType). (Has sch db schema, KnownSymbol vw) 
=> QualifiedAlias sch vw

the name of the view to add

-> Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) view

query

-> Definition db (Alter sch (Create vw ('View view) schema) db) 

Create a view.

>>> type ABC = '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4]
>>> type BC = '["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4]
>>> :{
let
  definition :: Definition
    '[ "public" ::: '["abc" ::: 'Table ('[] :=> ABC)]]
    '[ "public" ::: '["abc" ::: 'Table ('[] :=> ABC), "bc"  ::: 'View BC]]
  definition =
    createView #bc (select_ (#b :* #c) (from (table #abc)))
in printSQL definition
:}
CREATE VIEW "bc" AS SELECT "b" AS "b", "c" AS "c" FROM "abc" AS "abc";

destroyConnectionPool #

Arguments

:: forall k io (db :: k). MonadUnliftIO io 
=> Pool (K Connection db)

pool

-> io () 

Destroy all connections in all stripes in the pool. Note that this will ignore any exceptions in the destroy function.

This function is useful when you detect that all connections in the pool are broken. For example after a database has been restarted all connections opened before the restart will be broken. In that case it's better to close those connections so that usingConnectionPool won't take a broken connection from the pool but will open a new connection instead.

Another use-case for this function is that when you know you are done with the pool you can destroy all idle connections immediately instead of waiting on the garbage collector to destroy them, thus freeing up those connections sooner.

usingConnectionPool #

Arguments

:: forall io (db :: SchemasType) x. MonadUnliftIO io 
=> Pool (K Connection db)

pool

-> PQ db db io x

session

-> io x 

Temporarily take a connection from a Pool, perform an action with it, and return it to the pool afterwards.

If the pool has an idle connection available, it is used immediately. Otherwise, if the maximum number of connections has not yet been reached, a new connection is created and used. If the maximum number of connections has been reached, this function blocks until a connection becomes available.

createConnectionPool #

Arguments

:: forall (db :: SchemasType) io. MonadUnliftIO io 
=> ByteString

The passed string can be empty to use all default parameters, or it can contain one or more parameter settings separated by whitespace. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value or a value containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., ' and .

-> Int

The number of stripes (distinct sub-pools) to maintain. The smallest acceptable value is 1.

-> NominalDiffTime

Amount of time for which an unused connection is kept open. The smallest acceptable value is 0.5 seconds. The elapsed time before destroying a connection may be a little longer than requested, as the reaper thread wakes at 1-second intervals.

-> Int

Maximum number of connections to keep open per stripe. The smallest acceptable value is 1. Requests for connections will block if this limit is reached on a single stripe, even if other stripes have idle connections available.

-> io (Pool (K Connection db)) 

Create a striped pool of connections. Although the garbage collector will destroy all idle connections when the pool is garbage collected it's recommended to manually destroyAllResources when you're done with the pool so that the connections are freed up as soon as possible.

withConnection :: forall (db0 :: SchemasType) (db1 :: SchemasType) io x. MonadUnliftIO io => ByteString -> PQ db0 db1 io x -> io x #

Do connectdb and finish before and after a computation.

evalPQ :: forall m (db0 :: SchemasType) (db1 :: SchemasType) x. Functor m => PQ db0 db1 m x -> K Connection db0 -> m x #

Evaluate a PQ and discard the Connection but keep the result.

execPQ :: forall m (db0 :: SchemasType) (db1 :: SchemasType) x. Functor m => PQ db0 db1 m x -> K Connection db0 -> m (K Connection db1) #

Execute a PQ and discard the result but keep the Connection.

runPQ :: forall m (db0 :: SchemasType) (db1 :: SchemasType) x. Functor m => PQ db0 db1 m x -> K Connection db0 -> m (x, K Connection db1) #

Run a PQ and keep the result and the Connection.

newtype PQ (db0 :: SchemasType) (db1 :: SchemasType) (m :: Type -> Type) x #

We keep track of the schema via an Atkey indexed state monad transformer, PQ.

Constructors

PQ 

Fields

Instances

Instances details
IndexedMonadTransPQ PQ 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

define :: forall (io :: Type -> Type) (db0 :: SchemasType) (db1 :: SchemasType). MonadIO io => Definition db0 db1 -> PQ db0 db1 io () #

IndexedMonadTrans PQ 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

pqAp :: forall (m :: Type -> Type) (i :: k) (j :: k) x y (k1 :: k). Monad m => PQ i j m (x -> y) -> PQ j k1 m x -> PQ i k1 m y #

pqJoin :: forall (m :: Type -> Type) (i :: k) (j :: k) (k1 :: k) y. Monad m => PQ i j m (PQ j k1 m y) -> PQ i k1 m y #

pqBind :: forall (m :: Type -> Type) x (j :: k) (k1 :: k) y (i :: k). Monad m => (x -> PQ j k1 m y) -> PQ i j m x -> PQ i k1 m y #

pqThen :: forall (m :: Type -> Type) (j :: k) (k1 :: k) y (i :: k) x. Monad m => PQ j k1 m y -> PQ i j m x -> PQ i k1 m y #

pqAndThen :: forall (m :: Type -> Type) y (j :: k) (k1 :: k) z x (i :: k). Monad m => (y -> PQ j k1 m z) -> (x -> PQ i j m y) -> x -> PQ i k1 m z #

Migratory Definition (Indexed PQ IO ())

pure migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration Definition) db0 db1 -> Indexed PQ IO () db0 db1 #

db0 ~ db1 => MFunctor (PQ db0 db1 :: (Type -> Type) -> Type -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> PQ db0 db1 m b -> PQ db0 db1 n b #

Migratory (IsoQ (Indexed PQ IO ())) (IsoQ (Indexed PQ IO ()))

impure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ (Indexed PQ IO ()))) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

Migratory (IsoQ Definition) (IsoQ (Indexed PQ IO ()))

pure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ Definition)) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

MonadBase b m => MonadBase b (PQ schema schema m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

liftBase :: b α -> PQ schema schema m α #

(MonadBaseControl b m, schema0 ~ schema1) => MonadBaseControl b (PQ schema0 schema1 m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Associated Types

type StM (PQ schema0 schema1 m) a #

Methods

liftBaseWith :: (RunInBase (PQ schema0 schema1 m) b -> b a) -> PQ schema0 schema1 m a #

restoreM :: StM (PQ schema0 schema1 m) a -> PQ schema0 schema1 m a #

(MonadIO io, db0 ~ db, db1 ~ db) => MonadPQ db (PQ db0 db1 io) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

executeParams :: Statement db x y -> x -> PQ db0 db1 io (Result y) #

executeParams_ :: Statement db x () -> x -> PQ db0 db1 io () #

execute :: Statement db () y -> PQ db0 db1 io (Result y) #

execute_ :: Statement db () () -> PQ db0 db1 io () #

executePrepared :: Traversable list => Statement db x y -> list x -> PQ db0 db1 io (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> PQ db0 db1 io () #

Migratory (OpQ (Indexed PQ IO ())) (OpQ (Indexed PQ IO ()))

impure rewinds

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ (Indexed PQ IO ()))) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 #

Migratory (OpQ Definition) (OpQ (Indexed PQ IO ()))

pure rewinds

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ Definition)) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 #

Migratory (Indexed PQ IO ()) (Indexed PQ IO ())

impure migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (Indexed PQ IO ())) db0 db1 -> Indexed PQ IO () db0 db1 #

db0 ~ db1 => MonadTrans (PQ db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

lift :: Monad m => m a -> PQ db0 db1 m a #

db0 ~ db1 => MMonad (PQ db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

embed :: forall (n :: Type -> Type) m b. Monad n => (forall a. m a -> PQ db0 db1 n a) -> PQ db0 db1 m b -> PQ db0 db1 n b #

db0 ~ db1 => MonadTransControl (PQ db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Session

Associated Types

type StT (PQ db0 db1) a #

Methods

liftWith :: Monad m => (Run (PQ db0 db1) -> m a) -> PQ db0 db1 m a #

restoreT :: Monad m => m (StT (PQ db0 db1) a) -> PQ db0 db1 m a #

(Monad m, db0 ~ db1) => Monad (PQ db0 db1 m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

(>>=) :: PQ db0 db1 m a -> (a -> PQ db0 db1 m b) -> PQ db0 db1 m b #

(>>) :: PQ db0 db1 m a -> PQ db0 db1 m b -> PQ db0 db1 m b #

return :: a -> PQ db0 db1 m a #

Monad m => Functor (PQ db0 db1 m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

fmap :: (a -> b) -> PQ db0 db1 m a -> PQ db0 db1 m b #

(<$) :: a -> PQ db0 db1 m b -> PQ db0 db1 m a #

(Monad m, db0 ~ db1) => MonadFail (PQ db0 db1 m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

fail :: String -> PQ db0 db1 m a #

(Monad m, db0 ~ db1) => Applicative (PQ db0 db1 m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

pure :: a -> PQ db0 db1 m a #

(<*>) :: PQ db0 db1 m (a -> b) -> PQ db0 db1 m a -> PQ db0 db1 m b #

liftA2 :: (a -> b -> c) -> PQ db0 db1 m a -> PQ db0 db1 m b -> PQ db0 db1 m c #

(*>) :: PQ db0 db1 m a -> PQ db0 db1 m b -> PQ db0 db1 m b #

(<*) :: PQ db0 db1 m a -> PQ db0 db1 m b -> PQ db0 db1 m a #

(MonadIO m, schema0 ~ schema1) => MonadIO (PQ schema0 schema1 m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

liftIO :: IO a -> PQ schema0 schema1 m a #

(MonadThrow m, db0 ~ db1) => MonadThrow (PQ db0 db1 m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

throwM :: Exception e => e -> PQ db0 db1 m a #

(MonadCatch m, db0 ~ db1) => MonadCatch (PQ db0 db1 m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

catch :: Exception e => PQ db0 db1 m a -> (e -> PQ db0 db1 m a) -> PQ db0 db1 m a #

(MonadMask m, db0 ~ db1) => MonadMask (PQ db0 db1 m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

mask :: ((forall a. PQ db0 db1 m a -> PQ db0 db1 m a) -> PQ db0 db1 m b) -> PQ db0 db1 m b #

uninterruptibleMask :: ((forall a. PQ db0 db1 m a -> PQ db0 db1 m a) -> PQ db0 db1 m b) -> PQ db0 db1 m b #

generalBracket :: PQ db0 db1 m a -> (a -> ExitCase b -> PQ db0 db1 m c) -> (a -> PQ db0 db1 m b) -> PQ db0 db1 m (b, c) #

(MonadUnliftIO m, db0 ~ db1) => MonadUnliftIO (PQ db0 db1 m) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

withRunInIO :: ((forall a. PQ db0 db1 m a -> IO a) -> IO b) -> PQ db0 db1 m b #

(Monad m, Semigroup r, db0 ~ db1) => Semigroup (PQ db0 db1 m r) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

(<>) :: PQ db0 db1 m r -> PQ db0 db1 m r -> PQ db0 db1 m r #

sconcat :: NonEmpty (PQ db0 db1 m r) -> PQ db0 db1 m r #

stimes :: Integral b => b -> PQ db0 db1 m r -> PQ db0 db1 m r #

(Monad m, Monoid r, db0 ~ db1) => Monoid (PQ db0 db1 m r) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

mempty :: PQ db0 db1 m r #

mappend :: PQ db0 db1 m r -> PQ db0 db1 m r -> PQ db0 db1 m r #

mconcat :: [PQ db0 db1 m r] -> PQ db0 db1 m r #

type StT (PQ db0 db1) a 
Instance details

Defined in Squeal.PostgreSQL.Session

type StT (PQ db0 db1) a = a
type StM (PQ schema0 schema1 m) x 
Instance details

Defined in Squeal.PostgreSQL.Session

type StM (PQ schema0 schema1 m) x = StM m (K x schema0)

indexedDefine :: forall (pq :: SchemasType -> SchemasType -> (Type -> Type) -> Type -> Type) (io :: Type -> Type) (db0 :: SchemasType) (db1 :: SchemasType). (IndexedMonadTransPQ pq, MonadIO io) => Definition db0 db1 -> Indexed pq io () db0 db1 #

Run a pure SQL Definition functorially in effect

  • indexedDefine id = id
  • indexedDefine (def1 >>> def2) = indexedDefine def1 >>> indexedDefine def2

class (forall (i :: k) (j :: k) (m :: Type -> Type). Monad m => Functor (t i j m), forall (i :: k) (j :: k) (m :: Type -> Type). (i ~ j, Monad m) => Monad (t i j m), forall (i :: k) (j :: k). i ~ j => MonadTrans (t i j)) => IndexedMonadTrans (t :: k -> k -> (Type -> Type) -> Type -> Type) where #

An Atkey indexed monad is a Functor enriched category. An indexed monad transformer transforms a Monad into an indexed monad, and is a monad transformer when its source and target are the same, enabling use of standard do notation for endo-index operations.

Minimal complete definition

pqJoin | pqBind

Methods

pqAp :: forall (m :: Type -> Type) (i :: k) (j :: k) x y (k1 :: k). Monad m => t i j m (x -> y) -> t j k1 m x -> t i k1 m y #

indexed analog of <*>

pqJoin :: forall (m :: Type -> Type) (i :: k) (j :: k) (k1 :: k) y. Monad m => t i j m (t j k1 m y) -> t i k1 m y #

indexed analog of join

pqBind :: forall (m :: Type -> Type) x (j :: k) (k1 :: k) y (i :: k). Monad m => (x -> t j k1 m y) -> t i j m x -> t i k1 m y #

indexed analog of =<<

pqThen :: forall (m :: Type -> Type) (j :: k) (k1 :: k) y (i :: k) x. Monad m => t j k1 m y -> t i j m x -> t i k1 m y #

indexed analog of flipped >>

pqAndThen :: forall (m :: Type -> Type) y (j :: k) (k1 :: k) z x (i :: k). Monad m => (y -> t j k1 m z) -> (x -> t i j m y) -> x -> t i k1 m z #

indexed analog of <=<

Instances

Instances details
IndexedMonadTrans PQ 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

pqAp :: forall (m :: Type -> Type) (i :: k) (j :: k) x y (k1 :: k). Monad m => PQ i j m (x -> y) -> PQ j k1 m x -> PQ i k1 m y #

pqJoin :: forall (m :: Type -> Type) (i :: k) (j :: k) (k1 :: k) y. Monad m => PQ i j m (PQ j k1 m y) -> PQ i k1 m y #

pqBind :: forall (m :: Type -> Type) x (j :: k) (k1 :: k) y (i :: k). Monad m => (x -> PQ j k1 m y) -> PQ i j m x -> PQ i k1 m y #

pqThen :: forall (m :: Type -> Type) (j :: k) (k1 :: k) y (i :: k) x. Monad m => PQ j k1 m y -> PQ i j m x -> PQ i k1 m y #

pqAndThen :: forall (m :: Type -> Type) y (j :: k) (k1 :: k) z x (i :: k). Monad m => (y -> PQ j k1 m z) -> (x -> PQ i j m y) -> x -> PQ i k1 m z #

newtype Indexed (t :: k -> k1 -> k2 -> k3 -> Type) (m :: k2) (r :: k3) (i :: k) (j :: k1) #

Indexed reshuffles the type parameters of an IndexedMonadTrans, exposing its Category instance.

Constructors

Indexed 

Fields

Instances

Instances details
Migratory Definition (Indexed PQ IO ())

pure migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration Definition) db0 db1 -> Indexed PQ IO () db0 db1 #

Migratory (IsoQ (Indexed PQ IO ())) (IsoQ (Indexed PQ IO ()))

impure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ (Indexed PQ IO ()))) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

Migratory (IsoQ Definition) (IsoQ (Indexed PQ IO ()))

pure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ Definition)) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

Migratory (OpQ (Indexed PQ IO ())) (OpQ (Indexed PQ IO ()))

impure rewinds

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ (Indexed PQ IO ()))) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 #

Migratory (OpQ Definition) (OpQ (Indexed PQ IO ()))

pure rewinds

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ Definition)) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 #

(IndexedMonadTrans t, Monad m, Monoid r) => Category (Indexed t m r :: k -> k -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Session.Indexed

Methods

id :: forall (a :: k0). Indexed t m r a a #

(.) :: forall (b :: k0) (c :: k0) (a :: k0). Indexed t m r b c -> Indexed t m r a b -> Indexed t m r a c #

Migratory (Indexed PQ IO ()) (Indexed PQ IO ())

impure migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (Indexed PQ IO ())) db0 db1 -> Indexed PQ IO () db0 db1 #

class IndexedMonadTrans pq => IndexedMonadTransPQ (pq :: SchemasType -> SchemasType -> (Type -> Type) -> Type -> Type) where #

IndexedMonadTransPQ is a class for indexed monad transformers that support running Definitions using define which acts functorially in effect.

  • define id = return ()
  • define (statement1 >>> statement2) = define statement1 & pqThen (define statement2)

Methods

define :: forall (io :: Type -> Type) (db0 :: SchemasType) (db1 :: SchemasType). MonadIO io => Definition db0 db1 -> pq db0 db1 io () #

Instances

Instances details
IndexedMonadTransPQ PQ 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

define :: forall (io :: Type -> Type) (db0 :: SchemasType) (db1 :: SchemasType). MonadIO io => Definition db0 db1 -> PQ db0 db1 io () #

manipulation_ #

Arguments

:: forall (db :: SchemasType). Manipulation ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) ('[] :: [(Symbol, NullType)])

no input or output

-> Definition db db 

A Manipulation without input or output can be run as a statement along with other Definitions, by embedding it using manipulation_.

newtype Definition (db0 :: SchemasType) (db1 :: SchemasType) #

A Definition is a statement that changes the schemas of the database, like a createTable, dropTable, or alterTable command. Definitions may be composed using the >>> operator.

Instances

Instances details
Category Definition 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

id :: forall (a :: k). Definition a a #

(.) :: forall (b :: k) (c :: k) (a :: k). Definition b c -> Definition a b -> Definition a c #

Migratory Definition (Indexed PQ IO ())

pure migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration Definition) db0 db1 -> Indexed PQ IO () db0 db1 #

Migratory (IsoQ Definition) (IsoQ (Indexed PQ IO ()))

pure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ Definition)) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

Migratory (OpQ Definition) (OpQ (Indexed PQ IO ()))

pure rewinds

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ Definition)) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 #

Eq (Definition db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

(==) :: Definition db0 db1 -> Definition db0 db1 -> Bool #

(/=) :: Definition db0 db1 -> Definition db0 db1 -> Bool #

Ord (Definition db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

compare :: Definition db0 db1 -> Definition db0 db1 -> Ordering #

(<) :: Definition db0 db1 -> Definition db0 db1 -> Bool #

(<=) :: Definition db0 db1 -> Definition db0 db1 -> Bool #

(>) :: Definition db0 db1 -> Definition db0 db1 -> Bool #

(>=) :: Definition db0 db1 -> Definition db0 db1 -> Bool #

max :: Definition db0 db1 -> Definition db0 db1 -> Definition db0 db1 #

min :: Definition db0 db1 -> Definition db0 db1 -> Definition db0 db1 #

Show (Definition db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

showsPrec :: Int -> Definition db0 db1 -> ShowS #

show :: Definition db0 db1 -> String #

showList :: [Definition db0 db1] -> ShowS #

Generic (Definition db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep (Definition db0 db1) :: Type -> Type #

Methods

from :: Definition db0 db1 -> Rep (Definition db0 db1) x #

to :: Rep (Definition db0 db1) x -> Definition db0 db1 #

db0 ~ db1 => Semigroup (Definition db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

(<>) :: Definition db0 db1 -> Definition db0 db1 -> Definition db0 db1 #

sconcat :: NonEmpty (Definition db0 db1) -> Definition db0 db1 #

stimes :: Integral b => b -> Definition db0 db1 -> Definition db0 db1 #

db0 ~ db1 => Monoid (Definition db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

mempty :: Definition db0 db1 #

mappend :: Definition db0 db1 -> Definition db0 db1 -> Definition db0 db1 #

mconcat :: [Definition db0 db1] -> Definition db0 db1 #

NFData (Definition db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: Definition db0 db1 -> () #

RenderSQL (Definition db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

renderSQL :: Definition db0 db1 -> ByteString #

type Rep (Definition db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep (Definition db0 db1) = D1 ('MetaData "Definition" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeDefinition" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderDefinition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

foreignKey #

Arguments

:: forall (db :: [(Symbol, [(Symbol, SchemumType)])]) (sch0 :: Symbol) (sch1 :: Symbol) (schema0 :: [(Symbol, SchemumType)]) (schema1 :: [(Symbol, SchemumType)]) (child :: Symbol) (parent :: Symbol) (table :: TableType) (reftable :: TableType) (columns :: [Symbol]) (refcolumns :: [Symbol]) (constraints :: TableConstraints) (cols :: ColumnsType) (reftys :: [(Symbol, ColumnType)]) (tys :: [(Symbol, ColumnType)]). ForeignKeyed db sch0 sch1 schema0 schema1 child parent table reftable columns refcolumns constraints cols reftys tys 
=> NP Alias columns

column or columns in the table

-> QualifiedAlias sch0 parent

reference table

-> NP Alias refcolumns

reference column or columns in the reference table

-> OnDeleteClause

what to do when reference is deleted

-> OnUpdateClause

what to do when reference is updated

-> TableConstraintExpression sch1 child db ('ForeignKey columns sch0 parent refcolumns) 

A foreignKey specifies that the values in a column (or a group of columns) must match the values appearing in some row of another table. We say this maintains the referential integrity between two related tables.

>>> :{
type Schema =
  '[ "users" ::: 'Table (
       '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
       '[ "id" ::: 'Def :=> 'NotNull 'PGint4
        , "name" ::: 'NoDef :=> 'NotNull 'PGtext
        ])
   , "emails" ::: 'Table (
       '[  "pk_emails" ::: 'PrimaryKey '["id"]
        , "fk_user_id" ::: 'ForeignKey '["user_id"] "public" "users" '["id"]
        ] :=>
       '[ "id" ::: 'Def :=> 'NotNull 'PGint4
        , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
        , "email" ::: 'NoDef :=> 'Null 'PGtext
        ])
   ]
:}
>>> :{
let
  setup :: Definition (Public '[]) (Public Schema)
  setup =
   createTable #users
     ( serial `as` #id :*
       (text & notNullable) `as` #name )
     ( primaryKey #id `as` #pk_users ) >>>
   createTable #emails
     ( serial `as` #id :*
       (int & notNullable) `as` #user_id :*
       (text & nullable) `as` #email )
     ( primaryKey #id `as` #pk_emails :*
       foreignKey #user_id #users #id
         (OnDelete Cascade) (OnUpdate Cascade) `as` #fk_user_id )
in printSQL setup
:}
CREATE TABLE "users" ("id" serial, "name" text NOT NULL, CONSTRAINT "pk_users" PRIMARY KEY ("id"));
CREATE TABLE "emails" ("id" serial, "user_id" int NOT NULL, "email" text NULL, CONSTRAINT "pk_emails" PRIMARY KEY ("id"), CONSTRAINT "fk_user_id" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE);

A foreignKey can even be a table self-reference.

>>> :{
type Schema =
  '[ "employees" ::: 'Table (
       '[ "employees_pk"          ::: 'PrimaryKey '["id"]
        , "employees_employer_fk" ::: 'ForeignKey '["employer_id"] "public" "employees" '["id"]
        ] :=>
       '[ "id"          :::   'Def :=> 'NotNull 'PGint4
        , "name"        ::: 'NoDef :=> 'NotNull 'PGtext
        , "employer_id" ::: 'NoDef :=>    'Null 'PGint4
        ])
   ]
:}
>>> :{
let
  setup :: Definition (Public '[]) (Public Schema)
  setup =
   createTable #employees
     ( serial `as` #id :*
       (text & notNullable) `as` #name :*
       (integer & nullable) `as` #employer_id )
     ( primaryKey #id `as` #employees_pk :*
       foreignKey #employer_id #employees #id
         (OnDelete Cascade) (OnUpdate Cascade) `as` #employees_employer_fk )
in printSQL setup
:}
CREATE TABLE "employees" ("id" serial, "name" text NOT NULL, "employer_id" integer NULL, CONSTRAINT "employees_pk" PRIMARY KEY ("id"), CONSTRAINT "employees_employer_fk" FOREIGN KEY ("employer_id") REFERENCES "employees" ("id") ON DELETE CASCADE ON UPDATE CASCADE);

primaryKey #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (aliases :: [Symbol]) (subcolumns :: [(Symbol, ColumnType)]). (Has sch db schema, Has tab schema ('Table table), HasAll aliases (TableToColumns table) subcolumns, AllNotNull subcolumns) 
=> NP Alias aliases

specify the subcolumns which together form a primary key.

-> TableConstraintExpression sch tab db ('PrimaryKey aliases) 

A primaryKey constraint indicates that a column, or group of columns, can be used as a unique identifier for rows in the table. This requires that the values be both unique and not null.

>>> :{
type Schema = '[
  "tab" ::: 'Table ('[ "pk_id" ::: 'PrimaryKey '["id"]] :=> '[
    "id" ::: 'Def :=> 'NotNull 'PGint4,
    "name" ::: 'NoDef :=> 'NotNull 'PGtext
  ])]
:}
>>> :{
let
  definition :: Definition (Public '[]) (Public Schema)
  definition = createTable #tab
    ( serial `as` #id :*
      (text & notNullable) `as` #name )
    ( primaryKey #id `as` #pk_id )
:}
>>> printSQL definition
CREATE TABLE "tab" ("id" serial, "name" text NOT NULL, CONSTRAINT "pk_id" PRIMARY KEY ("id"));

unique #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (aliases :: [Symbol]) (subcolumns :: [(Symbol, NullType)]). (Has sch db schema, Has tab schema ('Table table), HasAll aliases (TableToRow table) subcolumns) 
=> NP Alias aliases

specify subcolumns which together are unique for each row

-> TableConstraintExpression sch tab db ('Unique aliases) 

A unique constraint ensure that the data contained in a column, or a group of columns, is unique among all the rows in the table.

>>> :{
type Schema = '[
  "tab" ::: 'Table( '[ "uq_a_b" ::: 'Unique '["a","b"]] :=> '[
    "a" ::: 'NoDef :=> 'Null 'PGint4,
    "b" ::: 'NoDef :=> 'Null 'PGint4
  ])]
:}
>>> :{
let
  definition :: Definition (Public '[]) (Public Schema)
  definition = createTable #tab
    ( (int & nullable) `as` #a :*
      (int & nullable) `as` #b )
    ( unique (#a :* #b) `as` #uq_a_b )
:}
>>> printSQL definition
CREATE TABLE "tab" ("a" int NULL, "b" int NULL, CONSTRAINT "uq_a_b" UNIQUE ("a", "b"));

check #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (aliases :: [Symbol]) (subcolumns :: [(Symbol, NullType)]). (Has sch db schema, Has tab schema ('Table table), HasAll aliases (TableToRow table) subcolumns) 
=> NP Alias aliases

specify the subcolumns which are getting checked

-> (forall (t :: Symbol). Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[t ::: subcolumns])

a closed Condition on those subcolumns

-> TableConstraintExpression sch tab db ('Check aliases) 

A check constraint is the most generic TableConstraint type. It allows you to specify that the value in a certain column must satisfy a Boolean (truth-value) expression.

>>> :{
type Schema = '[
  "tab" ::: 'Table ('[ "inequality" ::: 'Check '["a","b"]] :=> '[
    "a" ::: 'NoDef :=> 'NotNull 'PGint4,
    "b" ::: 'NoDef :=> 'NotNull 'PGint4
  ])]
:}
>>> :{
let
  definition :: Definition (Public '[]) (Public Schema)
  definition = createTable #tab
    ( (int & notNullable) `as` #a :*
      (int & notNullable) `as` #b )
    ( check (#a :* #b) (#a .> #b) `as` #inequality )
:}
>>> printSQL definition
CREATE TABLE "tab" ("a" int NOT NULL, "b" int NOT NULL, CONSTRAINT "inequality" CHECK (("a" > "b")));

newtype TableConstraintExpression (sch :: Symbol) (tab :: Symbol) (db :: SchemasType) (constraint :: TableConstraint) #

Data types are a way to limit the kind of data that can be stored in a table. For many applications, however, the constraint they provide is too coarse. For example, a column containing a product price should probably only accept positive values. But there is no standard data type that accepts only positive numbers. Another issue is that you might want to constrain column data with respect to other columns or rows. For example, in a table containing product information, there should be only one row for each product number. TableConstraints give you as much control over the data in your tables as you wish. If a user attempts to store data in a column that would violate a constraint, an error is raised. This applies even if the value came from the default value definition.

Instances

Instances details
Eq (TableConstraintExpression sch tab db constraint) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Methods

(==) :: TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint -> Bool #

(/=) :: TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint -> Bool #

Ord (TableConstraintExpression sch tab db constraint) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Methods

compare :: TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint -> Ordering #

(<) :: TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint -> Bool #

(<=) :: TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint -> Bool #

(>) :: TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint -> Bool #

(>=) :: TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint -> Bool #

max :: TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint #

min :: TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint -> TableConstraintExpression sch tab db constraint #

Show (TableConstraintExpression sch tab db constraint) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Methods

showsPrec :: Int -> TableConstraintExpression sch tab db constraint -> ShowS #

show :: TableConstraintExpression sch tab db constraint -> String #

showList :: [TableConstraintExpression sch tab db constraint] -> ShowS #

Generic (TableConstraintExpression sch tab db constraint) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Associated Types

type Rep (TableConstraintExpression sch tab db constraint) :: Type -> Type #

Methods

from :: TableConstraintExpression sch tab db constraint -> Rep (TableConstraintExpression sch tab db constraint) x #

to :: Rep (TableConstraintExpression sch tab db constraint) x -> TableConstraintExpression sch tab db constraint #

NFData (TableConstraintExpression sch tab db constraint) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Methods

rnf :: TableConstraintExpression sch tab db constraint -> () #

RenderSQL (TableConstraintExpression sch tab db constraint) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Methods

renderSQL :: TableConstraintExpression sch tab db constraint -> ByteString #

type Rep (TableConstraintExpression sch tab db constraint) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

type Rep (TableConstraintExpression sch tab db constraint) = D1 ('MetaData "TableConstraintExpression" "Squeal.PostgreSQL.Definition.Constraint" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeTableConstraintExpression" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderTableConstraintExpression") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

type ForeignKeyed (db :: [(Symbol, [(Symbol, SchemumType)])]) (sch0 :: Symbol) (sch1 :: Symbol) (schema0 :: [(Symbol, SchemumType)]) (schema1 :: [(Symbol, SchemumType)]) (child :: Symbol) (parent :: Symbol) (table :: TableType) (reftable :: TableType) (columns :: [Symbol]) (refcolumns :: [Symbol]) (constraints :: TableConstraints) (cols :: ColumnsType) (reftys :: [(Symbol, ColumnType)]) (tys :: [(Symbol, ColumnType)]) = (Has sch0 db schema0, Has sch1 db schema1, Has parent schema0 ('Table reftable), Has child schema1 ('Table table), HasAll columns (TableToColumns table) tys, reftable ~ (constraints :=> cols), HasAll refcolumns cols reftys, AllZip SamePGType tys reftys, Uniquely refcolumns constraints) #

A constraint synonym between types involved in a foreign key constraint.

newtype OnDeleteClause #

OnDeleteClause indicates what to do with rows that reference a deleted row.

Instances

Instances details
Eq OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Ord OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Show OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Generic OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Associated Types

type Rep OnDeleteClause :: Type -> Type #

NFData OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Methods

rnf :: OnDeleteClause -> () #

RenderSQL OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

type Rep OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

type Rep OnDeleteClause = D1 ('MetaData "OnDeleteClause" "Squeal.PostgreSQL.Definition.Constraint" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "OnDelete" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReferentialAction)))

newtype OnUpdateClause #

Analagous to OnDeleteClause there is also OnUpdateClause which is invoked when a referenced column is changed (updated).

Instances

Instances details
Eq OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Ord OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Show OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Generic OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Associated Types

type Rep OnUpdateClause :: Type -> Type #

NFData OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Methods

rnf :: OnUpdateClause -> () #

RenderSQL OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

type Rep OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

type Rep OnUpdateClause = D1 ('MetaData "OnUpdateClause" "Squeal.PostgreSQL.Definition.Constraint" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "OnUpdate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ReferentialAction)))

data ReferentialAction #

When the data in the referenced columns is changed, certain actions are performed on the data in this table's columns.

Constructors

NoAction

Produce an error indicating that the deletion or update would create a foreign key constraint violation. If the constraint is deferred, this error will be produced at constraint check time if there still exist any referencing rows.

Restrict

Produce an error indicating that the deletion or update would create a foreign key constraint violation. This is the same as NoAction except that the check is not deferrable.

Cascade

Delete any rows referencing the deleted row, or update the value of the referencing column to the new value of the referenced column, respectively.

SetNull

Set the referencing column(s) to null.

SetDefault

Set the referencing column(s) to their default values.

Instances

Instances details
Eq ReferentialAction 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Ord ReferentialAction 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Show ReferentialAction 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Generic ReferentialAction 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Associated Types

type Rep ReferentialAction :: Type -> Type #

NFData ReferentialAction 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Methods

rnf :: ReferentialAction -> () #

RenderSQL ReferentialAction 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

type Rep ReferentialAction 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

type Rep ReferentialAction = D1 ('MetaData "ReferentialAction" "Squeal.PostgreSQL.Definition.Constraint" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) ((C1 ('MetaCons "NoAction" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Restrict" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Cascade" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "SetNull" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SetDefault" 'PrefixI 'False) (U1 :: Type -> Type))))

callN #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (pro :: Symbol) (xs :: [NullType]) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has pro schema ('Procedure xs), SListI xs) 
=> QualifiedAlias sch pro

procedure to call

-> NP (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)])) xs

arguments

-> Manipulation with db params ('[] :: [(Symbol, NullType)]) 

Call a user defined procedure.

>>> type Schema = '[ "p" ::: 'Procedure '[ 'NotNull 'PGint4, 'NotNull 'PGtext ] ]
>>> :{
let
  p :: Manipulation '[] (Public Schema) '[] '[]
  p = callN #p (1 *: "hi")
in
  printSQL p
:}
CALL "p"((1 :: int4), (E'hi' :: text))

unsafeCallN #

Arguments

:: forall (xs :: [NullType]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI xs 
=> ByteString

procedure to call

-> NP (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)])) xs

arguments

-> Manipulation with db params ('[] :: [(Symbol, NullType)]) 
>>> printSQL $ unsafeCallN "p" (true *: false)
CALL p(TRUE, FALSE)

call #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (pro :: Symbol) (x :: NullType) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has pro schema ('Procedure '[x])) 
=> QualifiedAlias sch pro

procedure to call

-> Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)]) x

arguments

-> Manipulation with db params ('[] :: [(Symbol, NullType)]) 

Call a user defined procedure of one variable.

>>> type Schema = '[ "p" ::: 'Procedure '[ 'NotNull 'PGint4 ] ]
>>> :{
let
  p :: Manipulation '[] (Public Schema) '[] '[]
  p = call #p 1
in
  printSQL p
:}
CALL "p"((1 :: int4))

unsafeCall #

Arguments

:: forall (with :: FromType) (db :: SchemasType) (params :: [NullType]) (x :: NullType). ByteString

procedure to call

-> Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)]) x

arguments

-> Manipulation with db params ('[] :: [(Symbol, NullType)]) 
>>> printSQL $ unsafeCall "p" true
CALL p(TRUE)

deleteFrom_ #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table)) 
=> Aliased (QualifiedAlias sch) (tab ::: tab0)

table to delete from

-> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params '[tab ::: TableToRow table]

condition under which to delete a row

-> Manipulation with db params ('[] :: [(Symbol, NullType)]) 

Delete rows returning Nil.

>>> type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4]
>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>> :{
let
  manp :: Manipulation with (Public Schema) '[ 'NotNull 'PGint4] '[]
  manp = deleteFrom_ (#tab `as` #t) (#t ! #col1 .== param @1)
in printSQL manp
:}
DELETE FROM "tab" AS "t" WHERE ("t"."col1" = ($1 :: int4))

deleteFrom #

Arguments

:: forall (row :: [(Symbol, NullType)]) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (with :: FromType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (SListI row, Has sch db schema, Has tab0 schema ('Table table)) 
=> Aliased (QualifiedAlias sch) (tab ::: tab0)

table to delete from

-> UsingClause with db params from 
-> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ((tab ::: TableToRow table) ': from)

condition under which to delete a row

-> ReturningClause with db params ((tab ::: TableToRow table) ': from) row

results to return

-> Manipulation with db params row 

Delete rows from a table.

>>> type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]
>>> type Schema = '["tab1" ::: 'Table ('[] :=> Columns), "tab2" ::: 'Table ('[] :=> Columns)]
>>> :{
let
  manp :: Manipulation with (Public Schema) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  manp = deleteFrom #tab1 (Using (table #tab2)) (#tab1 ! #col1 .== #tab2 ! #col2) (Returning (#tab1 & DotStar))
in printSQL manp
:}
DELETE FROM "tab1" AS "tab1" USING "tab2" AS "tab2" WHERE ("tab1"."col1" = "tab2"."col2") RETURNING "tab1".*

inlineValues #

Arguments

:: forall hask (xs :: RecordCode) (columns :: [(Symbol, ColumnType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask xs, AllZip InlineColumn xs columns) 
=> hask

record

-> [hask]

more

-> QueryClause with db params columns 

inlineValues Haskell records in insertInto.

inlineValues_ #

Arguments

:: forall hask (xs :: RecordCode) (columns :: [(Symbol, ColumnType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask xs, AllZip InlineColumn xs columns) 
=> hask

record

-> QueryClause with db params columns 

inlineValues_ a Haskell record in insertInto.

insertInto_ #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table), SListI (TableToColumns table)) 
=> Aliased (QualifiedAlias sch) (tab ::: tab0)

table

-> QueryClause with db params (TableToColumns table)

what to insert

-> Manipulation with db params ('[] :: [(Symbol, NullType)]) 

Like insertInto but with OnConflictDoRaise and no ReturningClause.

>>> type Columns = '["col1" ::: 'NoDef :=> 'Null 'PGint4, "col2" ::: 'Def :=> 'NotNull 'PGint4]
>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>> :{
let
  manp :: Manipulation with (Public Schema) '[] '[]
  manp =
    insertInto_ #tab (Values_ (Set 2 `as` #col1 :* Default `as` #col2))
in printSQL manp
:}
INSERT INTO "tab" AS "tab" ("col1", "col2") VALUES ((2 :: int4), DEFAULT)

insertInto #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (row :: [(Symbol, NullType)]) (tab :: Symbol) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table), SListI (TableToColumns table), SListI row) 
=> Aliased (QualifiedAlias sch) (tab ::: tab0)

table

-> QueryClause with db params (TableToColumns table)

what to insert

-> ConflictClause tab with db params table

what to do in case of conflict

-> ReturningClause with db params '[tab ::: TableToRow table] row

what to return

-> Manipulation with db params row 

When a table is created, it contains no data. The first thing to do before a database can be of much use is to insert data. Data is conceptually inserted one row at a time. Of course you can also insert more than one row, but there is no way to insert less than one row. Even if you know only some column values, a complete row must be created.

>>> type CustomersColumns = '["name" ::: 'NoDef :=> 'NotNull 'PGtext, "email" ::: 'NoDef :=> 'NotNull 'PGtext]
>>> type CustomersConstraints = '["uq" ::: 'Unique '["name"]]
>>> type CustomersSchema = '["customers" ::: 'Table (CustomersConstraints :=> CustomersColumns)]
>>> :{
let
  manp :: Manipulation with (Public CustomersSchema) '[] '[]
  manp =
    insertInto #customers
      (Values_ (Set "John Smith" `as` #name :* Set "john@smith.com" `as` #email))
      (OnConflict (OnConstraint #uq)
        (DoUpdate (Set (#excluded ! #email <> "; " <> #customers ! #email) `as` #email) []))
      (Returning_ Nil)
in printSQL manp
:}
INSERT INTO "customers" AS "customers" ("name", "email") VALUES ((E'John Smith' :: text), (E'john@smith.com' :: text)) ON CONFLICT ON CONSTRAINT "uq" DO UPDATE SET "email" = ("excluded"."email" || ((E'; ' :: text) || "customers"."email"))

pattern Values_ #

Arguments

:: forall columns with db params (from :: FromType). SListI columns 
=> NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from))) columns

row of values

-> QueryClause with db params columns 

Values_ describes a single NP list of Aliased Optional Expressions whose ColumnsType must match the tables'.

data QueryClause (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: [(Symbol, (Optionality, NullType))]) where #

A QueryClause describes what to insertInto a table.

Constructors

Values 

Fields

Select 

Fields

Subquery 

Fields

Instances

Instances details
RenderSQL (QueryClause with db params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation.Insert

Methods

renderSQL :: QueryClause with db params columns -> ByteString #

data ConflictClause (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: ([(Symbol, TableConstraint)], ColumnsType)) where #

A ConflictClause specifies an action to perform upon a constraint violation. OnConflictDoRaise will raise an error. OnConflict DoNothing simply avoids inserting a row. OnConflict DoUpdate updates the existing row that conflicts with the row proposed for insertion.

Constructors

OnConflictDoRaise :: forall (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: ([(Symbol, TableConstraint)], ColumnsType)). ConflictClause tab with db params table 
OnConflict 

Fields

Instances

Instances details
SListI (TableToColumns table) => RenderSQL (ConflictClause tab with db params table)

Render a ConflictClause.

Instance details

Defined in Squeal.PostgreSQL.Manipulation.Insert

Methods

renderSQL :: ConflictClause tab with db params table -> ByteString #

data ConflictAction (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: TableType) where #

ConflictAction specifies an alternative OnConflict action. It can be either DoNothing, or a DoUpdate clause specifying the exact details of the update action to be performed in case of a conflict. The Set and WHERE Conditions in OnConflict DoUpdate have access to the existing row using the table's name, and to rows proposed for insertion using the special #excluded row. OnConflict DoNothing simply avoids inserting a row as its alternative action. OnConflict DoUpdate updates the existing row that conflicts with the row proposed for insertion as its alternative action.

Constructors

DoNothing :: forall (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: TableType). ConflictAction tab with db params table 
DoUpdate 

Fields

Instances

Instances details
RenderSQL (ConflictAction tab with db params table) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation.Insert

Methods

renderSQL :: ConflictAction tab with db params table -> ByteString #

data ConflictTarget (table :: ([(Symbol, kind)], k)) where #

A ConflictTarget specifies the constraint violation that triggers a ConflictAction.

Constructors

OnConstraint :: forall kind k (con :: Symbol) (constraints :: [(Symbol, kind)]) (constraint :: kind) (columns :: k). Has con constraints constraint => Alias con -> ConflictTarget '(constraints, columns) 

Instances

Instances details
RenderSQL (ConflictTarget constraints)

Render a ConflictTarget

Instance details

Defined in Squeal.PostgreSQL.Manipulation.Insert

Methods

renderSQL :: ConflictTarget constraints -> ByteString #

update_ #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (updates :: [(Symbol, (Optionality, NullType))]) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table), KnownSymbol tab, Updatable table updates) 
=> Aliased (QualifiedAlias sch) (tab ::: tab0)

table to update

-> NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params '[tab ::: TableToRow table]))) updates

modified values to replace old values

-> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params '[tab ::: TableToRow table]

condition under which to perform update on a row

-> Manipulation with db params ('[] :: [(Symbol, NullType)]) 

Update a row returning Nil.

>>> type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]
>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>> :{
let
  manp :: Manipulation with (Public Schema) '[] '[]
  manp = update_ #tab (Set 2 `as` #col1) (#col1 ./= #col2)
in printSQL manp
:}
UPDATE "tab" AS "tab" SET "col1" = (2 :: int4) WHERE ("col1" <> "col2")

update #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (updates :: [(Symbol, (Optionality, NullType))]) (row :: [(Symbol, NullType)]) (tab :: Symbol) (with :: FromType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (Has sch db schema, Has tab0 schema ('Table table), Updatable table updates, SListI row) 
=> Aliased (QualifiedAlias sch) (tab ::: tab0)

table to update

-> NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ((tab ::: TableToRow table) ': from)))) updates

update expressions, modified values to replace old values

-> UsingClause with db params from

FROM A table expression allowing columns from other tables to appear in the WHERE condition and update expressions.

-> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ((tab ::: TableToRow table) ': from)

WHERE condition under which to perform update on a row

-> ReturningClause with db params ((tab ::: TableToRow table) ': from) row

results to return

-> Manipulation with db params row 

An update command changes the values of the specified columns in all rows that satisfy the condition.

>>> type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]
>>> type Schema = '["tab1" ::: 'Table ('[] :=> Columns), "tab2" ::: 'Table ('[] :=> Columns)]
>>> :{
let
  manp :: Manipulation with (Public Schema) '[]
    '["col1" ::: 'NotNull 'PGint4,
      "col2" ::: 'NotNull 'PGint4]
  manp = update
    (#tab1 `as` #t1)
    (Set (2 + #t2 ! #col2) `as` #col1)
    (Using (table (#tab2 `as` #t2)))
    (#t1 ! #col1 ./= #t2 ! #col2)
    (Returning (#t1 & DotStar))
in printSQL manp
:}
UPDATE "tab1" AS "t1" SET "col1" = ((2 :: int4) + "t2"."col2") FROM "tab2" AS "t2" WHERE ("t1"."col1" <> "t2"."col2") RETURNING "t1".*

longRunningMode :: TransactionMode #

TransactionMode with a Serializable IsolationLevel, ReadOnly AccessMode and Deferrable DeferrableMode. This mode is well suited for long-running reports or backups.

rollback :: forall (db :: SchemasType). Manipulation_ db () () #

ROLLBACK a transaction.

commit :: forall (db :: SchemasType). Manipulation_ db () () #

COMMIT a transaction.

begin :: forall (db :: SchemasType). TransactionMode -> Manipulation_ db () () #

BEGIN a transaction.

data IsolationLevel #

The SQL standard defines four levels of transaction isolation. The most strict is Serializable, which is defined by the standard in a paragraph which says that any concurrent execution of a set of Serializable transactions is guaranteed to produce the same effect as running them one at a time in some order. The other three levels are defined in terms of phenomena, resulting from interaction between concurrent transactions, which must not occur at each level. The phenomena which are prohibited at various levels are:

Dirty read: A transaction reads data written by a concurrent uncommitted transaction.

Nonrepeatable read: A transaction re-reads data it has previously read and finds that data has been modified by another transaction (that committed since the initial read).

Phantom read: A transaction re-executes a query returning a set of rows that satisfy a search condition and finds that the set of rows satisfying the condition has changed due to another recently-committed transaction.

Serialization anomaly: The result of successfully committing a group of transactions is inconsistent with all possible orderings of running those transactions one at a time.

In PostgreSQL, you can request any of the four standard transaction isolation levels, but internally only three distinct isolation levels are implemented, i.e. PostgreSQL's ReadUncommitted mode behaves like ReadCommitted. This is because it is the only sensible way to map the standard isolation levels to PostgreSQL's multiversion concurrency control architecture.

Constructors

Serializable

Dirty read is not possible. Nonrepeatable read is not possible. Phantom read is not possible. Serialization anomaly is not possible.

RepeatableRead

Dirty read is not possible. Nonrepeatable read is not possible. Phantom read is not possible. Serialization anomaly is possible.

ReadCommitted

Dirty read is not possible. Nonrepeatable read is possible. Phantom read is possible. Serialization anomaly is possible.

ReadUncommitted

Dirty read is not possible. Nonrepeatable read is possible. Phantom read is possible. Serialization anomaly is possible.

data AccessMode #

The transaction access mode determines whether the transaction is ReadWrite or ReadOnly. ReadWrite is the default. When a transaction is ReadOnly, the following SQL commands are disallowed: INSERT, UPDATE, DELETE, and COPY FROM if the table they would write to is not a temporary table; all CREATE, ALTER, and DROP commands; COMMENT, GRANT, REVOKE, TRUNCATE; and EXPLAIN ANALYZE and EXECUTE if the command they would execute is among those listed. This is a high-level notion of ReadOnly that does not prevent all writes to disk.

Constructors

ReadWrite 
ReadOnly 

Instances

Instances details
Eq AccessMode 
Instance details

Defined in Squeal.PostgreSQL.Session.Transaction

Show AccessMode 
Instance details

Defined in Squeal.PostgreSQL.Session.Transaction

RenderSQL AccessMode

Render an AccessMode.

Instance details

Defined in Squeal.PostgreSQL.Session.Transaction

data DeferrableMode #

The Deferrable transaction property has no effect unless the transaction is also Serializable and ReadOnly. When all three of these properties are selected for a transaction, the transaction may block when first acquiring its snapshot, after which it is able to run without the normal overhead of a Serializable transaction and without any risk of contributing to or being canceled by a serialization failure. This longRunningMode is well suited for long-running reports or backups.

Constructors

Deferrable 
NotDeferrable 

class Monad pq => MonadPQ (db :: SchemasType) (pq :: Type -> Type) | pq -> db #

MonadPQ is an mtl style constraint, similar to MonadState, for using LibPQ to run Statements.

Instances

Instances details
MonadPQ db m => MonadPQ db (MaybeT m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> MaybeT m (Result y) #

executeParams_ :: Statement db x () -> x -> MaybeT m () #

execute :: Statement db () y -> MaybeT m (Result y) #

execute_ :: Statement db () () -> MaybeT m () #

executePrepared :: Traversable list => Statement db x y -> list x -> MaybeT m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> MaybeT m () #

(Monoid w, MonadPQ db m) => MonadPQ db (WriterT w m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> WriterT w m (Result y) #

executeParams_ :: Statement db x () -> x -> WriterT w m () #

execute :: Statement db () y -> WriterT w m (Result y) #

execute_ :: Statement db () () -> WriterT w m () #

executePrepared :: Traversable list => Statement db x y -> list x -> WriterT w m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> WriterT w m () #

(Monoid w, MonadPQ db m) => MonadPQ db (WriterT w m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> WriterT w m (Result y) #

executeParams_ :: Statement db x () -> x -> WriterT w m () #

execute :: Statement db () y -> WriterT w m (Result y) #

execute_ :: Statement db () () -> WriterT w m () #

executePrepared :: Traversable list => Statement db x y -> list x -> WriterT w m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> WriterT w m () #

MonadPQ db m => MonadPQ db (StateT s m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> StateT s m (Result y) #

executeParams_ :: Statement db x () -> x -> StateT s m () #

execute :: Statement db () y -> StateT s m (Result y) #

execute_ :: Statement db () () -> StateT s m () #

executePrepared :: Traversable list => Statement db x y -> list x -> StateT s m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> StateT s m () #

MonadPQ db m => MonadPQ db (StateT s m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> StateT s m (Result y) #

executeParams_ :: Statement db x () -> x -> StateT s m () #

execute :: Statement db () y -> StateT s m (Result y) #

execute_ :: Statement db () () -> StateT s m () #

executePrepared :: Traversable list => Statement db x y -> list x -> StateT s m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> StateT s m () #

MonadPQ db m => MonadPQ db (ReaderT r m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> ReaderT r m (Result y) #

executeParams_ :: Statement db x () -> x -> ReaderT r m () #

execute :: Statement db () y -> ReaderT r m (Result y) #

execute_ :: Statement db () () -> ReaderT r m () #

executePrepared :: Traversable list => Statement db x y -> list x -> ReaderT r m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> ReaderT r m () #

MonadPQ db m => MonadPQ db (IdentityT m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> IdentityT m (Result y) #

executeParams_ :: Statement db x () -> x -> IdentityT m () #

execute :: Statement db () y -> IdentityT m (Result y) #

execute_ :: Statement db () () -> IdentityT m () #

executePrepared :: Traversable list => Statement db x y -> list x -> IdentityT m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> IdentityT m () #

MonadPQ db m => MonadPQ db (ExceptT e m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> ExceptT e m (Result y) #

executeParams_ :: Statement db x () -> x -> ExceptT e m () #

execute :: Statement db () y -> ExceptT e m (Result y) #

execute_ :: Statement db () () -> ExceptT e m () #

executePrepared :: Traversable list => Statement db x y -> list x -> ExceptT e m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> ExceptT e m () #

MonadPQ db m => MonadPQ db (ContT r m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> ContT r m (Result y) #

executeParams_ :: Statement db x () -> x -> ContT r m () #

execute :: Statement db () y -> ContT r m (Result y) #

execute_ :: Statement db () () -> ContT r m () #

executePrepared :: Traversable list => Statement db x y -> list x -> ContT r m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> ContT r m () #

(MonadIO io, db0 ~ db, db1 ~ db) => MonadPQ db (PQ db0 db1 io) 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

executeParams :: Statement db x y -> x -> PQ db0 db1 io (Result y) #

executeParams_ :: Statement db x () -> x -> PQ db0 db1 io () #

execute :: Statement db () y -> PQ db0 db1 io (Result y) #

execute_ :: Statement db () () -> PQ db0 db1 io () #

executePrepared :: Traversable list => Statement db x y -> list x -> PQ db0 db1 io (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> PQ db0 db1 io () #

(Monoid w, MonadPQ db m) => MonadPQ db (RWST r w s m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> RWST r w s m (Result y) #

executeParams_ :: Statement db x () -> x -> RWST r w s m () #

execute :: Statement db () y -> RWST r w s m (Result y) #

execute_ :: Statement db () () -> RWST r w s m () #

executePrepared :: Traversable list => Statement db x y -> list x -> RWST r w s m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> RWST r w s m () #

(Monoid w, MonadPQ db m) => MonadPQ db (RWST r w s m) 
Instance details

Defined in Squeal.PostgreSQL.Session.Monad

Methods

executeParams :: Statement db x y -> x -> RWST r w s m (Result y) #

executeParams_ :: Statement db x () -> x -> RWST r w s m () #

execute :: Statement db () y -> RWST r w s m (Result y) #

execute_ :: Statement db () () -> RWST r w s m () #

executePrepared :: Traversable list => Statement db x y -> list x -> RWST r w s m (list (Result y)) #

executePrepared_ :: Foldable list => Statement db x () -> list x -> RWST r w s m () #

manipulation #

Arguments

:: forall (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]) (row :: [(Symbol, NullType)]) y (ys :: RecordCode). (GenericParams db params x xs, GenericRow row y ys) 
=> Manipulation ('[] :: [(Symbol, RowType)]) db params row

insertInto, update, or deleteFrom, ...

-> Statement db x y 

Smart constructor for a data manipulation language statement

query #

Arguments

:: forall (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]) (row :: [(Symbol, NullType)]) y (ys :: RecordCode). (GenericParams db params x xs, GenericRow row y ys) 
=> Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db params row

select, values, ...

-> Statement db x y 

Smart constructor for a structured query language statement

data Statement (db :: SchemasType) x y where #

A Statement consists of a Manipulation or a Query that can be run in a MonadPQ.

Constructors

Manipulation

Constructor for a data manipulation language statement

Fields

Query

Constructor for a structured query language statement

Fields

Instances

Instances details
Profunctor (Statement db) 
Instance details

Defined in Squeal.PostgreSQL.Session.Statement

Methods

dimap :: (a -> b) -> (c -> d) -> Statement db b c -> Statement db a d #

lmap :: (a -> b) -> Statement db b c -> Statement db a c #

rmap :: (b -> c) -> Statement db a b -> Statement db a c #

(#.) :: forall a b c q. Coercible c b => q b c -> Statement db a b -> Statement db a c #

(.#) :: forall a b c q. Coercible b a => Statement db b c -> q a b -> Statement db a c #

Functor (Statement db x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Statement

Methods

fmap :: (a -> b) -> Statement db x a -> Statement db x b #

(<$) :: a -> Statement db x b -> Statement db x a #

RenderSQL (Statement db x y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Statement

Methods

renderSQL :: Statement db x y -> ByteString #

type GenericParams (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]) = (All (OidOfNull db) params, IsProductType x xs, AllZip (ToParam db) params xs) #

A GenericParams constraint to ensure that a Haskell type is a product type, all its terms have known Oids, and can be encoded to corresponding Postgres types.

type GenericRow (row :: [(Symbol, NullType)]) y (ys :: RecordCode) = (IsRecord y ys, AllZip FromField row ys) #

A GenericRow constraint to ensure that a Haskell type is a record type, and all its fields and can be decoded from corresponding Postgres fields.

queryStatement #

Arguments

:: forall (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query ('[] :: [(Symbol, RowType)]) with db params columns

Query to embed as a Manipulation

-> Manipulation with db params columns 

Convert a Query into a Manipulation.

pattern Returning_ #

Arguments

:: SListI row 
=> NP (Aliased (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from)) row

row of values

-> ReturningClause with db params from row 

newtype Manipulation (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType) #

A Manipulation is a statement which may modify data in the database, but does not alter its schemas. Examples are insertIntos, updates and deleteFroms. A queryStatement is also considered a Manipulation even though it does not modify data.

The general Manipulation type is parameterized by

  • with :: FromType - scope for all common table expressions,
  • db :: SchemasType - scope for all tables and views,
  • params :: [NullType] - scope for all parameters,
  • row :: RowType - return type of the Manipulation.

Let's see some examples of Manipulations.

simple insert:

>>> type Columns = '["col1" ::: 'NoDef :=> 'Null 'PGint4, "col2" ::: 'Def :=> 'NotNull 'PGint4]
>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>> :{
let
  manp :: Manipulation with (Public Schema) '[] '[]
  manp =
    insertInto_ #tab (Values_ (Set 2 `as` #col1 :* Default `as` #col2))
in printSQL manp
:}
INSERT INTO "tab" AS "tab" ("col1", "col2") VALUES ((2 :: int4), DEFAULT)

out-of-line parameterized insert:

>>> type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]
>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>> :{
let
  manp :: Manipulation with (Public Schema) '[ 'NotNull 'PGint4] '[]
  manp =
    insertInto_ #tab $ Values_
      (Default `as` #col1 :* Set (param @1) `as` #col2)
in printSQL manp
:}
INSERT INTO "tab" AS "tab" ("col1", "col2") VALUES (DEFAULT, ($1 :: int4))

in-line parameterized insert:

>>> type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]
>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>> :{
data Row = Row { col1 :: Optional SOP.I ('Def :=> Int32), col2 :: Int32 }
  deriving stock (GHC.Generic)
  deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
:}
>>> :{
let
  manp :: Row -> Row -> Manipulation with (Public Schema) '[] '[]
  manp row1 row2 = insertInto_ #tab $ inlineValues row1 [row2]
  row1 = Row {col1 = Default, col2 = 2 :: Int32}
  row2 = Row {col1 = NotDefault (3 :: Int32), col2 = 4 :: Int32}
in printSQL (manp row1 row2)
:}
INSERT INTO "tab" AS "tab" ("col1", "col2") VALUES (DEFAULT, (2 :: int4)), ((3 :: int4), (4 :: int4))

returning insert:

>>> :{
let
  manp :: Manipulation with (Public Schema) '[] '["col1" ::: 'NotNull 'PGint4]
  manp =
    insertInto #tab (Values_ (Set 2 `as` #col1 :* Set 3 `as` #col2))
      OnConflictDoRaise (Returning #col1)
in printSQL manp
:}
INSERT INTO "tab" AS "tab" ("col1", "col2") VALUES ((2 :: int4), (3 :: int4)) RETURNING "col1" AS "col1"

upsert:

>>> type CustomersColumns = '["name" ::: 'NoDef :=> 'NotNull 'PGtext, "email" ::: 'NoDef :=> 'NotNull 'PGtext]
>>> type CustomersConstraints = '["uq" ::: 'Unique '["name"]]
>>> type CustomersSchema = '["customers" ::: 'Table (CustomersConstraints :=> CustomersColumns)]
>>> :{
let
  manp :: Manipulation with (Public CustomersSchema) '[] '[]
  manp =
    insertInto #customers
      (Values_ (Set "John Smith" `as` #name :* Set "john@smith.com" `as` #email))
      (OnConflict (OnConstraint #uq)
        (DoUpdate (Set (#excluded ! #email <> "; " <> #customers ! #email) `as` #email) []))
      (Returning_ Nil)
in printSQL manp
:}
INSERT INTO "customers" AS "customers" ("name", "email") VALUES ((E'John Smith' :: text), (E'john@smith.com' :: text)) ON CONFLICT ON CONSTRAINT "uq" DO UPDATE SET "email" = ("excluded"."email" || ((E'; ' :: text) || "customers"."email"))

query insert:

>>> :{
let
  manp :: Manipulation with (Public Schema) '[] '[]
  manp = insertInto_ #tab (Subquery (select Star (from (table #tab))))
in printSQL manp
:}
INSERT INTO "tab" AS "tab" SELECT * FROM "tab" AS "tab"

update:

>>> :{
let
  manp :: Manipulation with (Public Schema) '[] '[]
  manp = update_ #tab (Set 2 `as` #col1) (#col1 ./= #col2)
in printSQL manp
:}
UPDATE "tab" AS "tab" SET "col1" = (2 :: int4) WHERE ("col1" <> "col2")

delete:

>>> :{
let
  manp :: Manipulation with (Public Schema) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  manp = deleteFrom #tab NoUsing (#col1 .== #col2) (Returning Star)
in printSQL manp
:}
DELETE FROM "tab" AS "tab" WHERE ("col1" = "col2") RETURNING *

delete and using clause:

>>> :{
type Schema3 =
  '[ "tab" ::: 'Table ('[] :=> Columns)
   , "other_tab" ::: 'Table ('[] :=> Columns)
   , "third_tab" ::: 'Table ('[] :=> Columns) ]
:}
>>> :{
let
  manp :: Manipulation with (Public Schema3) '[] '[]
  manp =
    deleteFrom #tab (Using (table #other_tab & also (table #third_tab)))
    ( (#tab ! #col2 .== #other_tab ! #col2)
    .&& (#tab ! #col2 .== #third_tab ! #col2) )
    (Returning_ Nil)
in printSQL manp
:}
DELETE FROM "tab" AS "tab" USING "other_tab" AS "other_tab", "third_tab" AS "third_tab" WHERE (("tab"."col2" = "other_tab"."col2") AND ("tab"."col2" = "third_tab"."col2"))

with manipulation:

>>> type ProductsColumns = '["product" ::: 'NoDef :=> 'NotNull 'PGtext, "date" ::: 'Def :=> 'NotNull 'PGdate]
>>> type ProductsSchema = '["products" ::: 'Table ('[] :=> ProductsColumns), "products_deleted" ::: 'Table ('[] :=> ProductsColumns)]
>>> :{
let
  manp :: Manipulation with (Public ProductsSchema) '[ 'NotNull 'PGdate] '[]
  manp = with
    (deleteFrom #products NoUsing (#date .< param @1) (Returning Star) `as` #del)
    (insertInto_ #products_deleted (Subquery (select Star (from (common #del)))))
in printSQL manp
:}
WITH "del" AS (DELETE FROM "products" AS "products" WHERE ("date" < ($1 :: date)) RETURNING *) INSERT INTO "products_deleted" AS "products_deleted" SELECT * FROM "del" AS "del"

Instances

Instances details
With Manipulation 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

with :: forall (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) (row :: RowType). Path (CommonTableExpression Manipulation db params) with0 with1 -> Manipulation with1 db params row -> Manipulation with0 db params row #

Eq (Manipulation with db params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

(==) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool #

(/=) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool #

Ord (Manipulation with db params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

compare :: Manipulation with db params columns -> Manipulation with db params columns -> Ordering #

(<) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool #

(<=) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool #

(>) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool #

(>=) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool #

max :: Manipulation with db params columns -> Manipulation with db params columns -> Manipulation with db params columns #

min :: Manipulation with db params columns -> Manipulation with db params columns -> Manipulation with db params columns #

Show (Manipulation with db params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

showsPrec :: Int -> Manipulation with db params columns -> ShowS #

show :: Manipulation with db params columns -> String #

showList :: [Manipulation with db params columns] -> ShowS #

Generic (Manipulation with db params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Associated Types

type Rep (Manipulation with db params columns) :: Type -> Type #

Methods

from :: Manipulation with db params columns -> Rep (Manipulation with db params columns) x #

to :: Rep (Manipulation with db params columns) x -> Manipulation with db params columns #

NFData (Manipulation with db params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

rnf :: Manipulation with db params columns -> () #

RenderSQL (Manipulation with db params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: Manipulation with db params columns -> ByteString #

type Rep (Manipulation with db params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

type Rep (Manipulation with db params columns) = D1 ('MetaData "Manipulation" "Squeal.PostgreSQL.Manipulation" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeManipulation" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderManipulation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

type family Manipulation_ (db :: SchemasType) params row where ... #

The Manipulation_ type is parameterized by a db SchemasType, against which it is type-checked, an input params Haskell Type, and an ouput row Haskell Type.

Generally, params will be a Haskell tuple or record whose entries may be referenced using positional params and row will be a Haskell record, whose entries will be targeted using overloaded labels.

A Manipulation_ can be run using manipulateParams, or if params = () using manipulate.

Manipulation_ is a type family which resolves into a Manipulation, so don't be fooled by the input params and output row Haskell Types, which are converted into appropriate Postgres [NullType] params and RowType rows. Use manipulation to fix actual Haskell input params and output rows.

>>> :set -XDeriveAnyClass -XDerivingStrategies
>>> type Columns = '["col1" ::: 'NoDef :=> 'Null 'PGint8, "col2" ::: 'Def :=> 'NotNull 'PGtext]
>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>> :{
data Row = Row { col1 :: Maybe Int64, col2 :: String }
  deriving stock (GHC.Generic)
  deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
:}
>>> :{
let
  manp :: Manipulation_ (Public Schema) (Int64, Int64) Row
  manp = deleteFrom #tab NoUsing (#col1 .== param @1 + param @2) (Returning Star)
  stmt :: Statement (Public Schema) (Int64, Int64) Row
  stmt = manipulation manp
:}
>>> :type manp
manp
  :: Manipulation
       '[]
       '["public" ::: '["tab" ::: 'Table ('[] :=> Columns)]]
       '[ 'NotNull 'PGint8, 'NotNull 'PGint8]
       '["col1" ::: 'Null 'PGint8, "col2" ::: 'NotNull 'PGtext]
>>> :type stmt
stmt
  :: Statement
       '["public" ::: '["tab" ::: 'Table ('[] :=> Columns)]]
       (Int64, Int64)
       Row

Equations

Manipulation_ db params row = Manipulation ('[] :: [(Symbol, RowType)]) db (TuplePG params) (RowPG row) 

newtype ReturningClause (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]) (row :: RowType) #

A ReturningClause computes and returns value(s) based on each row actually inserted, updated or deleted. This is primarily useful for obtaining values that were supplied by defaults, such as a serial sequence number. However, any expression using the table's columns is allowed. Only rows that were successfully inserted or updated or deleted will be returned. For example, if a row was locked but not updated because an OnConflict DoUpdate condition was not satisfied, the row will not be returned. Returning Star will return all columns in the row. Use Returning_ Nil in the common case where no return values are desired.

Constructors

Returning (Selection 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from row) 

Instances

Instances details
RenderSQL (ReturningClause with db params from row) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: ReturningClause with db params from row -> ByteString #

data UsingClause (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]) where #

Specify additional tables with Using an also list of table expressions, allowing columns from other tables to appear in the WHERE condition. This is similar to the list of tables that can be specified in the FROM Clause of a SELECT statement; for example, an alias for the table name can be specified. Do not repeat the target table in the Using list, unless you wish to set up a self-join. NoUsing if no additional tables are to be used.

Constructors

NoUsing :: forall (with :: FromType) (db :: SchemasType) (params :: [NullType]). UsingClause with db params ('[] :: [(Symbol, RowType)]) 
Using 

Fields

selectDistinctOn_ #

Arguments

:: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI columns, columns ~ (col ': cols)) 
=> [SortExpression grp lat with db params from]

distinct on and return the first row in ordering

-> NP (Aliased (Expression grp lat with db params from)) columns

selection

-> TableExpression grp lat with db params from

intermediate virtual table

-> Query lat with db params columns 

Like selectDistinctOn but takes an NP list of Expressions instead of a general Selection.

selectDistinctOn #

Arguments

:: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI columns, columns ~ (col ': cols)) 
=> [SortExpression grp lat with db params from]

DISTINCT ON expression(s) and prepended to ORDER BY clause

-> Selection grp lat with db params from columns

selection

-> TableExpression grp lat with db params from

intermediate virtual table

-> Query lat with db params columns 

selectDistinctOn keeps only the first row of each set of rows where the given expressions evaluate to equal. The DISTINCT ON expressions are interpreted using the same rules as for ORDER BY. ORDER BY is used to ensure that the desired row appears first.

The DISTINCT ON expression(s) must match the leftmost ORDER BY expression(s). The ORDER BY clause will normally contain additional expression(s) that determine the desired precedence of rows within each DISTINCT ON group.

In order to guarantee they match and reduce redundancy, this function will prepend the The DISTINCT ON expressions to the ORDER BY clause.

selectDistinct_ #

Arguments

:: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI columns, columns ~ (col ': cols)) 
=> NP (Aliased (Expression grp lat with db params from)) columns

select list

-> TableExpression grp lat with db params from

intermediate virtual table

-> Query lat with db params columns 

Like selectDistinct but takes an NP list of Expressions instead of a general Selection.

selectDistinct #

Arguments

:: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (SListI columns, columns ~ (col ': cols)) 
=> Selection grp lat with db params from columns

selection

-> TableExpression grp lat with db params from

intermediate virtual table

-> Query lat with db params columns 

After the select list has been processed, the result table can be subject to the elimination of duplicate rows using selectDistinct.

select_ #

Arguments

:: forall (row :: [(Symbol, NullType)]) (x :: (Symbol, NullType)) (xs :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI row, row ~ (x ': xs)) 
=> NP (Aliased (Expression grp lat with db params from)) row

select list

-> TableExpression grp lat with db params from

intermediate virtual table

-> Query lat with db params row 

Like select but takes an NP list of Expressions instead of a general Selection.

select #

Arguments

:: forall (row :: [(Symbol, NullType)]) (x :: (Symbol, NullType)) (xs :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (SListI row, row ~ (x ': xs)) 
=> Selection grp lat with db params from row

selection

-> TableExpression grp lat with db params from

intermediate virtual table

-> Query lat with db params row 

the TableExpression in the select command constructs an intermediate virtual table by possibly combining tables, views, eliminating rows, grouping, etc. This table is finally passed on to processing by the select list. The Selection determines which columns of the intermediate table are actually output.

data Selection (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]) (row :: RowType) where #

The simplest kinds of Selection are Star and DotStar which emits all columns that a TableExpression produces. A select List is a list of Expressions. A Selection could be a list of WindowFunctions Over WindowDefinition. Additional Selections can be selected with Also.

Constructors

Star 

Fields

DotStar 

Fields

List 

Fields

Over 

Fields

Also 

Fields

Instances

Instances details
(Has tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty]) => IsQualified tab col (Selection 'Ungrouped lat with db params from row1) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

(!) :: Alias tab -> Alias col -> Selection 'Ungrouped lat with db params from row1 #

(Has tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty], GroupedBy tab col bys) => IsQualified tab col (Selection ('Grouped bys) lat with db params from row1) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

(!) :: Alias tab -> Alias col -> Selection ('Grouped bys) lat with db params from row1 #

(HasUnique tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty]) => IsLabel col (Selection 'Ungrouped lat with db params from row1) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

fromLabel :: Selection 'Ungrouped lat with db params from row1 #

(HasUnique tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty], GroupedBy tab col bys) => IsLabel col (Selection ('Grouped bys) lat with db params from row1) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

fromLabel :: Selection ('Grouped bys) lat with db params from row1 #

(KnownSymbol col, row ~ '[col ::: ty]) => Aliasable col (Expression grp lat with db params from ty) (Selection grp lat with db params from row) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

as :: Expression grp lat with db params from ty -> Alias col -> Selection grp lat with db params from row #

Additional (Selection grp lat with db params from :: RowType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

also :: forall (ys :: [a]) (xs :: [a]). Selection grp lat with db params from ys -> Selection grp lat with db params from xs -> Selection grp lat with db params from (Join xs ys) #

IsString (Selection grp lat with db params from '["fromOnly" ::: 'NotNull 'PGtext]) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

fromString :: String -> Selection grp lat with db params from '["fromOnly" ::: 'NotNull 'PGtext] #

RenderSQL (Selection grp lat with db params from row) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

renderSQL :: Selection grp lat with db params from row -> ByteString #

nthValue :: forall (null :: PGType -> NullType) (ty :: PGType). '[null ty, 'NotNull 'PGint4] --#-> 'Null ty #

returns value evaluated at the row that is the nth row of the window frame (counting from 1); null if no such row

lastValue :: forall (ty :: NullType). ty -#-> ty #

returns value evaluated at the row that is the last row of the window frame

firstValue :: forall (ty :: NullType). ty -#-> ty #

returns value evaluated at the row that is the first row of the window frame

lead :: forall (ty :: NullType). '[ty, 'NotNull 'PGint4, ty] --#-> ty #

returns value evaluated at the row that is offset rows after the current row within the partition; if there is no such row, instead return default (which must be of the same type as value). Both offset and default are evaluated with respect to the current row.

lag :: forall (ty :: NullType). '[ty, 'NotNull 'PGint4, ty] --#-> ty #

returns value evaluated at the row that is offset rows before the current row within the partition; if there is no such row, instead return default (which must be of the same type as value). Both offset and default are evaluated with respect to the current row.

ntile :: 'NotNull 'PGint4 -#-> 'NotNull 'PGint4 #

integer ranging from 1 to the argument value, dividing the partition as equally as possible

>>> printSQL $ ntile (Window 5)
ntile((5 :: int4))

cumeDist :: WinFun0 ('NotNull 'PGfloat8) #

cumulative distribution: (number of partition rows preceding or peer with current row) / total partition rows

>>> printSQL cumeDist
cume_dist()

percentRank :: WinFun0 ('NotNull 'PGfloat8) #

relative rank of the current row: (rank - 1) / (total partition rows - 1)

>>> printSQL percentRank
percent_rank()

denseRank :: WinFun0 ('NotNull 'PGint8) #

rank of the current row without gaps; this function counts peer groups

>>> printSQL denseRank
dense_rank()

rowNumber :: WinFun0 ('NotNull 'PGint8) #

number of the current row within its partition, counting from 1

>>> printSQL rowNumber
row_number()

rank :: WinFun0 ('NotNull 'PGint8) #

rank of the current row with gaps; same as rowNumber of its first peer

>>> printSQL rank
rank()

unsafeWindowFunctionN :: forall (xs :: [NullType]) (y :: NullType). SListI xs => ByteString -> xs --#-> y #

escape hatch for defining multi-argument window functions

unsafeWindowFunction1 :: forall (x :: NullType) (y :: NullType). ByteString -> x -#-> y #

escape hatch for defining window functions

partitionBy #

Arguments

:: forall (bys :: [NullType]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). SListI bys 
=> NP (Expression grp lat with db params from) bys

partitions

-> WindowDefinition grp lat with db params from 

The partitionBy clause within Over divides the rows into groups, or partitions, that share the same values of the partitionBy Expression(s). For each row, the window function is computed across the rows that fall into the same partition as the current row.

pattern Window #

Arguments

:: forall grp lat with db params from (arg :: NullType). Expression grp lat with db params from arg

argument

-> WindowArg grp '[arg] lat with db params from 

Window invokes a WindowFunction on a single argument.

pattern Windows #

Arguments

:: NP (Expression grp lat with db params from) args

arguments

-> WindowArg grp args lat with db params from 

Windows invokes a WindowFunction on multiple argument.

data WindowDefinition (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) where #

A WindowDefinition is a set of table rows that are somehow related to the current row

Constructors

WindowDefinition 

Fields

Instances

Instances details
OrderBy (WindowDefinition grp) grp 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from] -> WindowDefinition grp lat with db params from -> WindowDefinition grp lat with db params from #

RenderSQL (WindowDefinition grp lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

renderSQL :: WindowDefinition grp lat with db params from -> ByteString #

newtype WindowFunction (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) #

A window function performs a calculation across a set of table rows that are somehow related to the current row. This is comparable to the type of calculation that can be done with an aggregate function. However, window functions do not cause rows to become grouped into a single output row like non-window aggregate calls would. Instead, the rows retain their separate identities. Behind the scenes, the window function is able to access more than just the current row of the query result.

Instances

Instances details
Aggregate (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (WindowFunction grp :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowFunction grp lat with db params from ('NotNull 'PGint8) #

count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('NotNull 'PGint8) #

sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGSum ty)) #

arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ('PGvararray ty)) #

jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjson) #

jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjsonb) #

bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) #

bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) #

boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) #

min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) #

avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGint8) #

regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

Eq (WindowFunction grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

(==) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool #

(/=) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool #

Ord (WindowFunction grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

compare :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Ordering #

(<) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool #

(<=) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool #

(>) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool #

(>=) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool #

max :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty #

min :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty #

Show (WindowFunction grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

showsPrec :: Int -> WindowFunction grp lat with db params from ty -> ShowS #

show :: WindowFunction grp lat with db params from ty -> String #

showList :: [WindowFunction grp lat with db params from ty] -> ShowS #

Generic (WindowFunction grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Associated Types

type Rep (WindowFunction grp lat with db params from ty) :: Type -> Type #

Methods

from :: WindowFunction grp lat with db params from ty -> Rep (WindowFunction grp lat with db params from ty) x #

to :: Rep (WindowFunction grp lat with db params from ty) x -> WindowFunction grp lat with db params from ty #

NFData (WindowFunction grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

rnf :: WindowFunction grp lat with db params from ty -> () #

RenderSQL (WindowFunction grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

renderSQL :: WindowFunction grp lat with db params from ty -> ByteString #

type Rep (WindowFunction grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

type Rep (WindowFunction grp lat with db params from ty) = D1 ('MetaData "WindowFunction" "Squeal.PostgreSQL.Expression.Window" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeWindowFunction" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderWindowFunction") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

data WindowArg (grp :: Grouping) (args :: [NullType]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) #

WindowArgs are used for the input of WindowFunctions.

Constructors

WindowArg 

Fields

Instances

Instances details
Aggregate (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (WindowFunction grp :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowFunction grp lat with db params from ('NotNull 'PGint8) #

count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('NotNull 'PGint8) #

sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGSum ty)) #

arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ('PGvararray ty)) #

jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjson) #

jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjsonb) #

bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) #

bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) #

boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) #

min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) #

avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGint8) #

regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

FilterWhere (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) grp 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition grp lat with db params from -> WindowArg grp xs lat with db params from -> WindowArg grp xs lat with db params from #

Generic (WindowArg grp args lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Associated Types

type Rep (WindowArg grp args lat with db params from) :: Type -> Type #

Methods

from :: WindowArg grp args lat with db params from -> Rep (WindowArg grp args lat with db params from) x #

to :: Rep (WindowArg grp args lat with db params from) x -> WindowArg grp args lat with db params from #

SListI args => RenderSQL (WindowArg grp args lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

renderSQL :: WindowArg grp args lat with db params from -> ByteString #

type Rep (WindowArg grp args lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

type Rep (WindowArg grp args lat with db params from) = D1 ('MetaData "WindowArg" "Squeal.PostgreSQL.Expression.Window" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) (C1 ('MetaCons "WindowArg" 'PrefixI 'True) (S1 ('MetaSel ('Just "windowArgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NP (Expression grp lat with db params from) args)) :*: S1 ('MetaSel ('Just "windowFilter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Condition grp lat with db params from])))

type WinFun0 (x :: NullType) #

Arguments

 = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). WindowFunction grp lat with db params from x

cannot reference aliases

A RankNType for window functions with no arguments.

type (-#->) (x :: NullType) (y :: NullType) #

Arguments

 = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). WindowArg grp '[x] lat with db params from

input

-> WindowFunction grp lat with db params from y

output

A RankNType for window functions with 1 argument.

type (--#->) (xs :: [NullType]) (y :: NullType) #

Arguments

 = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). WindowArg grp xs lat with db params from

inputs

-> WindowFunction grp lat with db params from y

output

A RankNType for window functions with a fixed-length list of heterogeneous arguments. Use the *: operator to end your argument lists.

distinctNotNull #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (x :: PGType). Expression 'Ungrouped lat with db params from ('Null x)

argument

-> AggregateArg '['NotNull x] lat with db params from 

distinctNotNull invokes the aggregate once for each distinct, not null value of the expression found in the input.

allNotNull #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (x :: PGType). Expression 'Ungrouped lat with db params from ('Null x)

argument

-> AggregateArg '['NotNull x] lat with db params from 

allNotNull invokes the aggregate on a single argument once for each input row where the argument is not null

pattern All #

Arguments

:: forall lat with db params from (x :: NullType). Expression 'Ungrouped lat with db params from x

argument

-> AggregateArg '[x] lat with db params from 

All invokes the aggregate on a single argument once for each input row.

pattern Alls #

Arguments

:: NP (Expression 'Ungrouped lat with db params from) xs

arguments

-> AggregateArg xs lat with db params from 

All invokes the aggregate on multiple arguments once for each input row.

pattern Distinct #

Arguments

:: forall lat with db params from (x :: NullType). Expression 'Ungrouped lat with db params from x

argument

-> AggregateArg '[x] lat with db params from 

Distinct invokes the aggregate once for each distinct value of the expression found in the input.

pattern Distincts #

Arguments

:: NP (Expression 'Ungrouped lat with db params from) xs

arguments

-> AggregateArg xs lat with db params from 

Distincts invokes the aggregate once for each distinct set of values, for multiple expressions, found in the input.

class Aggregate (arg :: [NullType] -> k -> k1 -> k2 -> k3 -> k4 -> Type) (expr :: k -> k1 -> k2 -> k3 -> k4 -> NullType -> Type) | expr -> arg where #

Aggregate functions compute a single result from a set of input values. Aggregate functions can be used as Grouped Expressions as well as WindowFunctions.

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). expr lat with db params from ('NotNull 'PGint8) #

A special aggregation that does not require an input

>>> :{
let
  expression :: Expression ('Grouped bys) '[] with db params from ('NotNull 'PGint8)
  expression = countStar
in printSQL expression
:}
count(*)

count #

Arguments

:: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from

argument

-> expr lat with db params from ('NotNull 'PGint8) 
>>> :{
let
  expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: null ty]] ('NotNull 'PGint8)
  expression = count (All #col)
in printSQL expression
:}
count(ALL "col")

sum_ #

Arguments

:: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from

argument

-> expr lat with db params from ('Null (PGSum ty)) 
>>> :{
let
  expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
  expression = sum_ (Distinct #col & filterWhere (#col .< 100))
in printSQL expression
:}
sum(DISTINCT "col") FILTER (WHERE ("col" < (100.0 :: numeric)))

arrayAgg #

Arguments

:: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from

argument

-> expr lat with db params from ('Null ('PGvararray ty)) 

input values, including nulls, concatenated into an array

>>> :{
let
  expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null ('PGvararray ('Null 'PGnumeric)))
  expression = arrayAgg (All #col & orderBy [AscNullsFirst #col] & filterWhere (#col .< 100))
in printSQL expression
:}
array_agg(ALL "col" ORDER BY "col" ASC NULLS FIRST) FILTER (WHERE ("col" < (100.0 :: numeric)))

jsonAgg #

Arguments

:: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from

argument

-> expr lat with db params from ('Null 'PGjson) 

aggregates values as a JSON array

jsonbAgg #

Arguments

:: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from

argument

-> expr lat with db params from ('Null 'PGjsonb) 

aggregates values as a JSON array

bitAnd #

Arguments

:: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral 
=> arg '[null int] lat with db params from

argument

-> expr lat with db params from ('Null int) 

the bitwise AND of all non-null input values, or null if none

>>> :{
let
  expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4)
  expression = bitAnd (Distinct #col)
in printSQL expression
:}
bit_and(DISTINCT "col")

bitOr #

Arguments

:: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral 
=> arg '[null int] lat with db params from

argument

-> expr lat with db params from ('Null int) 

the bitwise OR of all non-null input values, or null if none

>>> :{
let
  expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4)
  expression = bitOr (All #col)
in printSQL expression
:}
bit_or(ALL "col")

boolAnd #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGbool] lat with db params from

argument

-> expr lat with db params from ('Null 'PGbool) 

true if all input values are true, otherwise false

>>> :{
let
  winFun :: WindowFunction  'Ungrouped '[] with db params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
  winFun = boolAnd (Window #col)
in printSQL winFun
:}
bool_and("col")

boolOr #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGbool] lat with db params from

argument

-> expr lat with db params from ('Null 'PGbool) 

true if at least one input value is true, otherwise false

>>> :{
let
  expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
  expression = boolOr (All #col)
in printSQL expression
:}
bool_or(ALL "col")

every #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGbool] lat with db params from

argument

-> expr lat with db params from ('Null 'PGbool) 

equivalent to boolAnd

>>> :{
let
  expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
  expression = every (Distinct #col)
in printSQL expression
:}
every(DISTINCT "col")

max_ #

Arguments

:: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from

argument

-> expr lat with db params from ('Null ty) 

maximum value of expression across all input values

min_ #

Arguments

:: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from

argument

-> expr lat with db params from ('Null ty) 

minimum value of expression across all input values

avg #

Arguments

:: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from

argument

-> expr lat with db params from ('Null (PGAvg ty)) 

the average (arithmetic mean) of all input values

corr #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

correlation coefficient

>>> :{
let
  expression :: Expression ('Grouped g) '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
  expression = corr (Alls (#y *: #x))
in printSQL expression
:}
corr(ALL "y", "x")

covarPop #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

population covariance

>>> :{
let
  expression :: Expression ('Grouped g) '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
  expression = covarPop (Alls (#y *: #x))
in printSQL expression
:}
covar_pop(ALL "y", "x")

covarSamp #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

sample covariance

>>> :{
let
  winFun :: WindowFunction  'Ungrouped '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
  winFun = covarSamp (Windows (#y *: #x))
in printSQL winFun
:}
covar_samp("y", "x")

regrAvgX #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

average of the independent variable (sum(X)/N)

>>> :{
let
  expression :: Expression ('Grouped g) '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
  expression = regrAvgX (Alls (#y *: #x))
in printSQL expression
:}
regr_avgx(ALL "y", "x")

regrAvgY #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

average of the dependent variable (sum(Y)/N)

>>> :{
let
  winFun :: WindowFunction  'Ungrouped '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
  winFun = regrAvgY (Windows (#y *: #x))
in printSQL winFun
:}
regr_avgy("y", "x")

regrCount #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGint8) 

number of input rows in which both expressions are nonnull

>>> :{
let
  winFun :: WindowFunction  'Ungrouped '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGint8)
  winFun = regrCount (Windows (#y *: #x))
in printSQL winFun
:}
regr_count("y", "x")

regrIntercept #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

y-intercept of the least-squares-fit linear equation determined by the (X, Y) pairs

>>> :{
let
  expression :: Expression ('Grouped g) '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
  expression = regrIntercept (Alls (#y *: #x))
in printSQL expression
:}
regr_intercept(ALL "y", "x")

regrR2 #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

regr_r2(Y, X), square of the correlation coefficient

regrSlope #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

regr_slope(Y, X), slope of the least-squares-fit linear equation determined by the (X, Y) pairs

regrSxx #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

regr_sxx(Y, X), sum(X^2) - sum(X)^2/N (“sum of squares” of the independent variable)

regrSxy #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

regr_sxy(Y, X), sum(X*Y) - sum(X) * sum(Y)/N (“sum of products” of independent times dependent variable)

regrSyy #

Arguments

:: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from

arguments

-> expr lat with db params from ('Null 'PGfloat8) 

regr_syy(Y, X), sum(Y^2) - sum(Y)^2/N (“sum of squares” of the dependent variable)

stddev #

Arguments

:: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from

argument

-> expr lat with db params from ('Null (PGAvg ty)) 

historical alias for stddevSamp

stddevPop #

Arguments

:: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from

argument

-> expr lat with db params from ('Null (PGAvg ty)) 

population standard deviation of the input values

stddevSamp #

Arguments

:: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from

argument

-> expr lat with db params from ('Null (PGAvg ty)) 

sample standard deviation of the input values

variance #

Arguments

:: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from

argument

-> expr lat with db params from ('Null (PGAvg ty)) 

historical alias for varSamp

varPop #

Arguments

:: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from

argument

-> expr lat with db params from ('Null (PGAvg ty)) 

population variance of the input values (square of the population standard deviation)

varSamp #

Arguments

:: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from

argument

-> expr lat with db params from ('Null (PGAvg ty)) 

sample variance of the input values (square of the sample standard deviation)

Instances

Instances details
Aggregate AggregateArg (Expression ('Grouped bys) :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) #

count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) #

sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGSum ty)) #

arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ('PGvararray ty)) #

jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjson) #

jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjsonb) #

bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) #

bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) #

boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) #

min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) #

avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGint8) #

regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

Aggregate (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (WindowFunction grp :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowFunction grp lat with db params from ('NotNull 'PGint8) #

count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('NotNull 'PGint8) #

sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGSum ty)) #

arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ('PGvararray ty)) #

jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjson) #

jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjsonb) #

bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) #

bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) #

boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) #

min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) #

avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGint8) #

regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

data AggregateArg (xs :: [NullType]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) #

AggregateArgs are used for the input of Aggregate Expressions.

Constructors

AggregateAll 

Fields

AggregateDistinct 

Fields

Instances

Instances details
Aggregate AggregateArg (Expression ('Grouped bys) :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) #

count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) #

sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGSum ty)) #

arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ('PGvararray ty)) #

jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjson) #

jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjsonb) #

bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) #

bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) #

boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) #

min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) #

avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGint8) #

regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

OrderBy (AggregateArg xs) 'Ungrouped 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression 'Ungrouped lat with db params from] -> AggregateArg xs lat with db params from -> AggregateArg xs lat with db params from #

FilterWhere AggregateArg 'Ungrouped 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition 'Ungrouped lat with db params from -> AggregateArg xs lat with db params from -> AggregateArg xs lat with db params from #

SListI xs => RenderSQL (AggregateArg xs lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

renderSQL :: AggregateArg xs lat with db params from -> ByteString #

class FilterWhere (arg :: k -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (grp :: Grouping) | arg -> grp where #

Permits filtering WindowArgs and AggregateArgs

Methods

filterWhere #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition grp lat with db params from

include rows which evaluate to true

-> arg xs lat with db params from 
-> arg xs lat with db params from 

If filterWhere is specified, then only the input rows for which the Condition evaluates to true are fed to the aggregate function; other rows are discarded.

Instances

Instances details
FilterWhere AggregateArg 'Ungrouped 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition 'Ungrouped lat with db params from -> AggregateArg xs lat with db params from -> AggregateArg xs lat with db params from #

FilterWhere (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) grp 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition grp lat with db params from -> WindowArg grp xs lat with db params from -> WindowArg grp xs lat with db params from #

type family PGSum (ty :: PGType) :: PGType where ... #

A type family that calculates PGSum PGType of a given argument PGType.

Equations

PGSum 'PGint2 = 'PGint8 
PGSum 'PGint4 = 'PGint8 
PGSum 'PGint8 = 'PGnumeric 
PGSum 'PGfloat4 = 'PGfloat4 
PGSum 'PGfloat8 = 'PGfloat8 
PGSum 'PGnumeric = 'PGnumeric 
PGSum 'PGinterval = 'PGinterval 
PGSum 'PGmoney = 'PGmoney 
PGSum pg = TypeError ('Text "Squeal type error: Cannot sum with argument type " :<>: 'ShowType pg) :: PGType 

type family PGAvg (ty :: PGType) :: PGType where ... #

A type family that calculates PGAvg type of a PGType.

Equations

PGAvg 'PGint2 = 'PGnumeric 
PGAvg 'PGint4 = 'PGnumeric 
PGAvg 'PGint8 = 'PGnumeric 
PGAvg 'PGnumeric = 'PGnumeric 
PGAvg 'PGfloat4 = 'PGfloat8 
PGAvg 'PGfloat8 = 'PGfloat8 
PGAvg 'PGinterval = 'PGinterval 
PGAvg pg = TypeError ('Text "Squeal type error: No average for " :<>: 'ShowType pg) :: PGType 

inlineColumns #

Arguments

:: forall hask (xs :: RecordCode) (columns :: [(Symbol, ColumnType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask xs, AllZip InlineColumn xs columns) 
=> hask

record

-> NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)])))) columns 

Inline a Haskell record as a list of columns.

inlineFields #

Arguments

:: forall hask (fields :: RecordCode) (row :: [(Symbol, NullType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask fields, AllZip InlineField fields row) 
=> hask

record

-> NP (Aliased (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)]))) row 

Inline a Haskell record as a row of expressions.

class Inline x where #

The Inline class allows embedding a Haskell value directly as an Expression using inline.

>>> printSQL (inline 'a')
(E'a' :: char(1))
>>> printSQL (inline (1 :: Double))
(1.0 :: float8)
>>> printSQL (inline (Json ([1, 2] :: [Double])))
('[1.0,2.0]' :: json)
>>> printSQL (inline (Enumerated GT))
'GT'

Methods

inline :: forall (null :: PGType -> NullType). x -> Expr (null (PG x)) #

Instances

Instances details
Inline Bool 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Bool -> Expr (null (PG Bool)) #

Inline Char 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Char -> Expr (null (PG Char)) #

Inline Double 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Double -> Expr (null (PG Double)) #

Inline Float 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Float -> Expr (null (PG Float)) #

Inline Int16 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Int16 -> Expr (null (PG Int16)) #

Inline Int32 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Int32 -> Expr (null (PG Int32)) #

Inline Int64 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Int64 -> Expr (null (PG Int64)) #

Inline Scientific 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Scientific -> Expr (null (PG Scientific)) #

Inline String 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). String -> Expr (null (PG String)) #

Inline Text 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Text -> Expr (null (PG Text)) #

Inline UTCTime 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). UTCTime -> Expr (null (PG UTCTime)) #

Inline Text 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Text -> Expr (null (PG Text)) #

Inline UUID 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). UUID -> Expr (null (PG UUID)) #

Inline Day 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Day -> Expr (null (PG Day)) #

Inline DiffTime 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). DiffTime -> Expr (null (PG DiffTime)) #

Inline TimeOfDay 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). TimeOfDay -> Expr (null (PG TimeOfDay)) #

Inline LocalTime 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). LocalTime -> Expr (null (PG LocalTime)) #

Inline Oid 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Oid -> Expr (null (PG Oid)) #

Inline Money 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Money -> Expr (null (PG Money)) #

Inline (Range Int32) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range Int32 -> Expr (null (PG (Range Int32))) #

Inline (Range Int64) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range Int64 -> Expr (null (PG (Range Int64))) #

Inline (Range Scientific) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range Scientific -> Expr (null (PG (Range Scientific))) #

Inline (Range UTCTime) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range UTCTime -> Expr (null (PG (Range UTCTime))) #

Inline (Range Day) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range Day -> Expr (null (PG (Range Day))) #

Inline (Range LocalTime) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range LocalTime -> Expr (null (PG (Range LocalTime))) #

ToJSON x => Inline (Json x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Json x -> Expr (null (PG (Json x))) #

ToJSON x => Inline (Jsonb x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Jsonb x -> Expr (null (PG (Jsonb x))) #

(IsRecord x xs, AllZip InlineField xs (RowPG x)) => Inline (Composite x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Composite x -> Expr (null (PG (Composite x))) #

(IsEnumType x, HasDatatypeInfo x) => Inline (Enumerated x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Enumerated x -> Expr (null (PG (Enumerated x))) #

InlineParam x (NullPG x) => Inline (VarArray [x]) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). VarArray [x] -> Expr (null (PG (VarArray [x]))) #

InlineParam x (NullPG x) => Inline (VarArray (Vector x)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). VarArray (Vector x) -> Expr (null (PG (VarArray (Vector x)))) #

(KnownNat n, 1 <= n) => Inline (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). VarChar n -> Expr (null (PG (VarChar n))) #

(KnownNat n, 1 <= n) => Inline (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). FixChar n -> Expr (null (PG (FixChar n))) #

Inline (TimeOfDay, TimeZone) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). (TimeOfDay, TimeZone) -> Expr (null (PG (TimeOfDay, TimeZone))) #

class InlineParam x (ty :: NullType) where #

Lifts Inline to NullTypes.

Methods

inlineParam :: x -> Expr ty #

Instances

Instances details
(Inline x, pg ~ PG x) => InlineParam x ('NotNull pg) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineParam :: x -> Expr ('NotNull pg) #

(Inline x, pg ~ PG x) => InlineParam (Maybe x) ('Null pg) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineParam :: Maybe x -> Expr ('Null pg) #

class InlineField (field :: (Symbol, Type)) (fieldpg :: (Symbol, NullType)) where #

Lifts Inline to fields.

Methods

inlineField :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P field -> Aliased (Expression grp lat with db params from) fieldpg #

Instances

Instances details
(KnownSymbol alias, InlineParam x ty) => InlineField (alias ::: x) (alias ::: ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineField :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (alias ::: x) -> Aliased (Expression grp lat with db params from) (alias ::: ty) #

class InlineColumn (field :: (Symbol, Type)) (column :: (Symbol, ColumnType)) where #

Lifts Inline to a column entry

Methods

inlineColumn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P field -> Aliased (Optional (Expression grp lat with db params from)) column #

Haskell record field as a inline column

Instances

Instances details
(KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: x) (col ::: ('NoDef :=> ty)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineColumn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (col ::: x) -> Aliased (Optional (Expression grp lat with db params from)) (col ::: ('NoDef :=> ty)) #

(KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: Optional I ('Def :=> x)) (col ::: ('Def :=> ty)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineColumn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (col ::: Optional I ('Def :=> x)) -> Aliased (Optional (Expression grp lat with db params from)) (col ::: ('Def :=> ty)) #

arrAny #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType). Expression grp lat with db params from ty1

expression

-> Operator ty1 ty2 ('Null 'PGbool)

operator

-> Expression grp lat with db params from ('Null ('PGvararray ty2))

array

-> Condition grp lat with db params from 

The right-hand side is a parenthesized expression, which must yield an array value. The left-hand expression is evaluated and compared to each element of the array using the given Operator, which must yield a Boolean result. The result of arrAny is true if any true result is obtained. The result is false if no true result is found (including the case where the array has zero elements).

If the array expression yields a null array, the result of arrAny will be null. If the left-hand expression yields null, the result of arrAny is ordinarily null (though a non-strict comparison Operator could possibly yield a different result). Also, if the right-hand array contains any null elements and no true comparison result is obtained, the result of arrAny will be null, not false (again, assuming a strict comparison Operator). This is in accordance with SQL's normal rules for Boolean combinations of null values.

>>> printSQL $ arrAny true (.==) (array [true, false, null_])
(TRUE = ANY (ARRAY[TRUE, FALSE, NULL]))
>>> printSQL $ arrAny "hi" like (array ["bi","hi"])
((E'hi' :: text) LIKE ANY (ARRAY[(E'bi' :: text), (E'hi' :: text)]))

arrAll #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType). Expression grp lat with db params from ty1

expression

-> Operator ty1 ty2 ('Null 'PGbool)

operator

-> Expression grp lat with db params from ('Null ('PGvararray ty2))

array

-> Condition grp lat with db params from 

The right-hand side is a parenthesized expression, which must yield an array value. The left-hand expression is evaluated and compared to each element of the array using the given Operator, which must yield a Boolean result. The result of arrAll is true if all comparisons yield true (including the case where the array has zero elements). The result is false if any false result is found.

If the array expression yields a null array, the result of arrAll will be null. If the left-hand expression yields null, the result of arrAll is ordinarily null (though a non-strict comparison Operator could possibly yield a different result). Also, if the right-hand array contains any null elements and no false comparison result is obtained, the result of arrAll will be null, not true (again, assuming a strict comparison Operator). This is in accordance with SQL's normal rules for Boolean combinations of null values.

>>> printSQL $ arrAll true (.==) (array [true, false, null_])
(TRUE = ALL (ARRAY[TRUE, FALSE, NULL]))
>>> printSQL $ arrAll "hi" like (array ["bi","hi"])
((E'hi' :: text) LIKE ALL (ARRAY[(E'bi' :: text), (E'hi' :: text)]))

unnest :: forall (null :: PGType -> NullType) (ty :: NullType). null ('PGvararray ty) -|-> ("unnest" ::: '["unnest" ::: ty]) #

Expand an array to a set of rows

>>> printSQL $ unnest (array [null_, false, true])
unnest(ARRAY[NULL, FALSE, TRUE])

index2 #

Arguments

:: forall (i :: Nat) (j :: Nat) (m :: Nat) (n :: Nat) (ty :: NullType). (1 <= i, i <= m, KnownNat i, 1 <= j, j <= n, KnownNat j) 
=> 'NotNull ('PGfixarray '[m, n] ty) --> ty

matrix index

Typesafe indexing of fixed size matrices.

>>> printSQL $ array2 ((true *: false) *: (false *: true)) & index2 @1 @2
(ARRAY[[TRUE, FALSE], [FALSE, TRUE]])[1][2]

index1 #

Arguments

:: forall (i :: Nat) (n :: Nat) (ty :: NullType). (1 <= i, i <= n, KnownNat i) 
=> 'NotNull ('PGfixarray '[n] ty) --> ty

vector index

Typesafe indexing of fixed length arrays.

>>> printSQL $ array1 (true *: false) & index1 @1
(ARRAY[TRUE, FALSE])[1]

index #

Arguments

:: forall (null :: PGType -> NullType) (ty :: NullType). Word64

index

-> null ('PGvararray ty) --> NullifyType ty 
>>> printSQL $ array [null_, false, true] & index 2
(ARRAY[NULL, FALSE, TRUE])[2]

cardinality :: forall (null :: PGType -> NullType) (ty :: NullType). null ('PGvararray ty) --> null 'PGint8 #

>>> printSQL $ cardinality (array [null_, false, true])
cardinality(ARRAY[NULL, FALSE, TRUE])

array2 #

Arguments

:: forall (tys :: [NullType]) (tyss :: [[NullType]]) (n1 :: Nat) (ty :: NullType) (n2 :: Nat) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). (All ([NullType] ~ tys) tyss, All (SListI :: [NullType] -> Constraint) tyss, Length tyss ~ n1, All (NullType ~ ty) tys, Length tys ~ n2) 
=> NP (NP (Expression grp lat with db params from)) tyss

matrix elements

-> Expression grp lat with db params from (null ('PGfixarray '[n1, n2] ty)) 

Construct a fixed size matrix.

>>> printSQL $ array2 ((null_ :* false *: true) *: (false :* null_ *: true))
ARRAY[[NULL, FALSE, TRUE], [FALSE, NULL, TRUE]]
>>> :type array2 ((null_ :* false *: true) *: (false :* null_ *: true))
array2 ((null_ :* false *: true) *: (false :* null_ *: true))
  :: Expression
       grp
       lat
       with
       db
       params
       from
       (null ('PGfixarray '[2, 3] ('Null 'PGbool)))

array1 #

Arguments

:: forall (n :: Nat) (tys :: [NullType]) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). (n ~ Length tys, All (NullType ~ ty) tys) 
=> NP (Expression grp lat with db params from) tys

array elements

-> Expression grp lat with db params from (null ('PGfixarray '[n] ty)) 

Construct a fixed length array.

>>> printSQL $ array1 (null_ :* false *: true)
ARRAY[NULL, FALSE, TRUE]
>>> :type array1 (null_ :* false *: true)
array1 (null_ :* false *: true)
  :: Expression
       grp
       lat
       with
       db
       params
       from
       (null ('PGfixarray '[3] ('Null 'PGbool)))

array0 :: forall (db :: SchemasType) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). TypeExpression db ty -> Expression grp lat with db params from (null ('PGvararray ty)) #

Safely construct an empty array.

>>> printSQL $ array0 text
(ARRAY[] :: text[])

array #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) (null :: PGType -> NullType). [Expression grp lat with db params from ty]

array elements

-> Expression grp lat with db params from (null ('PGvararray ty)) 

Construct an array.

>>> printSQL $ array [null_, false, true]
ARRAY[NULL, FALSE, TRUE]

isNotUnknown :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #

is true or false

>>> printSQL $ true & isNotUnknown
(TRUE IS NOT UNKNOWN)

isUnknown :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #

is unknown

>>> printSQL $ true & isUnknown
(TRUE IS UNKNOWN)

isNotFalse :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #

is true or unknown

>>> printSQL $ true & isNotFalse
(TRUE IS NOT FALSE)

isFalse :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #

is false

>>> printSQL $ true & isFalse
(TRUE IS FALSE)

isNotTrue :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #

is false or unknown

>>> printSQL $ true & isNotTrue
(TRUE IS NOT TRUE)

isTrue :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #

is true

>>> printSQL $ true & isTrue
(TRUE IS TRUE)

isNotDistinctFrom :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('NotNull 'PGbool) #

equal, treating null like an ordinary value

>>> printSQL $ true `isNotDistinctFrom` null_
(TRUE IS NOT DISTINCT FROM NULL)

isDistinctFrom :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) #

not equal, treating null like an ordinary value

>>> printSQL $ true `isDistinctFrom` null_
(TRUE IS DISTINCT FROM NULL)

notBetweenSymmetric :: BetweenExpr #

not between, after sorting the comparison values

>>> printSQL $ true `notBetweenSymmetric` (null_, false)
TRUE NOT BETWEEN SYMMETRIC NULL AND FALSE

betweenSymmetric :: BetweenExpr #

between, after sorting the comparison values

>>> printSQL $ true `betweenSymmetric` (null_, false)
TRUE BETWEEN SYMMETRIC NULL AND FALSE

notBetween :: BetweenExpr #

>>> printSQL $ true `notBetween` (null_, false)
TRUE NOT BETWEEN NULL AND FALSE

between :: BetweenExpr #

>>> printSQL $ true `between` (null_, false)
TRUE BETWEEN NULL AND FALSE

least :: forall (ty :: NullType). FunctionVar ty ty ty #

>>> printSQL $ least [null_] currentTimestamp
LEAST(NULL, CURRENT_TIMESTAMP)

greatest :: forall (ty :: NullType). FunctionVar ty ty ty #

>>> let expr = greatest [param @1] currentTimestamp
>>> printSQL expr
GREATEST(($1 :: timestamp with time zone), CURRENT_TIMESTAMP)

(.>) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #

>>> printSQL $ true .> null_
(TRUE > NULL)

(.<=) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #

>>> printSQL $ true .<= null_
(TRUE <= NULL)

(.<) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #

>>> printSQL $ true .< null_
(TRUE < NULL)

(.>=) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #

>>> printSQL $ true .>= null_
(TRUE >= NULL)

(./=) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #

>>> printSQL $ true ./= null_
(TRUE <> NULL)

(.==) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #

Comparison operations like .==, ./=, .>, .>=, .< and .<= will produce NULLs if one of their arguments is NULL.

>>> printSQL $ true .== null_
(TRUE = NULL)

type BetweenExpr #

Arguments

 = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType). Expression grp lat with db params from ty 
-> (Expression grp lat with db params from ty, Expression grp lat with db params from ty)

bounds

-> Condition grp lat with db params from 

A RankNType for comparison expressions like between.

field #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tydef :: Symbol) (row :: RowType) (field :: Symbol) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). (Has sch db schema, Has tydef schema ('Typedef ('PGcomposite row)), Has field row ty) 
=> QualifiedAlias sch tydef

row type

-> Alias field

field name

-> Expression grp lat with db params from ('NotNull ('PGcomposite row)) 
-> Expression grp lat with db params from ty 
>>> :{
type Complex = 'PGcomposite
  '[ "real"      ::: 'NotNull 'PGfloat8
   , "imaginary" ::: 'NotNull 'PGfloat8 ]
type Schema = '["complex" ::: 'Typedef Complex]
:}
>>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression lat '[] grp (Public Schema) from params ('NotNull Complex)
>>> printSQL $ i & field #complex #imaginary
(ROW((0.0 :: float8), (1.0 :: float8))::"complex")."imaginary"

rowStar :: forall (tab :: Symbol) (from :: [(Symbol, RowType)]) (row :: RowType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (null :: PGType -> NullType). Has tab from row => Alias tab -> Expression grp lat with db params from (null ('PGcomposite row)) #

A row constructor on all columns in a table expression.

row #

Arguments

:: forall (row :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). SListI row 
=> NP (Aliased (Expression grp lat with db params from)) row

zero or more expressions for the row field values

-> Expression grp lat with db params from (null ('PGcomposite row)) 

A row constructor is an expression that builds a row value (also called a composite value) using values for its member fields.

>>> :{
type Complex = 'PGcomposite
  '[ "real"      ::: 'NotNull 'PGfloat8
   , "imaginary" ::: 'NotNull 'PGfloat8 ]
:}
>>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression grp lat with db params from ('NotNull Complex)
>>> printSQL i
ROW((0.0 :: float8), (1.0 :: float8))

jsonbToRecordSet :: JsonToRecordFunction 'PGjsonb #

Builds an arbitrary set of records from a binary JSON array of objects.

jsonToRecordSet :: JsonToRecordFunction 'PGjson #

Builds an arbitrary set of records from a JSON array of objects.

jsonbToRecord :: JsonToRecordFunction 'PGjsonb #

Builds an arbitrary record from a binary JSON object.

jsonToRecord :: JsonToRecordFunction 'PGjson #

Builds an arbitrary record from a JSON object.

jsonbPopulateRecordSet :: JsonPopulateFunction "jsonb_populate_record_set" 'PGjsonb #

Expands the outermost array of objects in the given binary JSON expression to a set of rows whose columns match the record type defined by the given table.

jsonPopulateRecordSet :: JsonPopulateFunction "json_populate_record_set" 'PGjson #

Expands the outermost array of objects in the given JSON expression to a set of rows whose columns match the record type defined by the given table.

jsonbPopulateRecord :: JsonPopulateFunction "jsonb_populate_record" 'PGjsonb #

Expands the binary JSON expression to a row whose columns match the record type defined by the given table.

jsonPopulateRecord :: JsonPopulateFunction "json_populate_record" 'PGjson #

Expands the JSON expression to a row whose columns match the record type defined by the given table.

jsonbObjectKeys :: forall (null :: PGType -> NullType). null 'PGjsonb -|-> ("jsonb_object_keys" ::: '["jsonb_object_keys" ::: 'NotNull 'PGtext]) #

Returns set of keys in the outermost JSON object.

>>> printSQL (jsonbObjectKeys (inline (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))
jsonb_object_keys(('{"a":"foo","b":"bar"}' :: jsonb))

jsonObjectKeys :: forall (null :: PGType -> NullType). null 'PGjson -|-> ("json_object_keys" ::: '["json_object_keys" ::: 'NotNull 'PGtext]) #

Returns set of keys in the outermost JSON object.

>>> printSQL (jsonObjectKeys (inline (Json (object ["a" .= "foo", "b" .= "bar"]))))
json_object_keys(('{"a":"foo","b":"bar"}' :: json))

jsonbEachText :: forall (null :: PGType -> NullType). null 'PGjsonb -|-> ("jsonb_each_text" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]) #

Expands the outermost binary JSON object into a set of key/value pairs.

>>> printSQL (select Star (from (jsonbEachText (inline (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))))
SELECT * FROM jsonb_each_text(('{"a":"foo","b":"bar"}' :: jsonb))

jsonEachText :: forall (null :: PGType -> NullType). null 'PGjson -|-> ("json_each_text" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]) #

Expands the outermost JSON object into a set of key/value pairs.

>>> printSQL (select Star (from (jsonEachText (inline (Json (object ["a" .= "foo", "b" .= "bar"]))))))
SELECT * FROM json_each_text(('{"a":"foo","b":"bar"}' :: json))

jsonbEach :: forall (null :: PGType -> NullType). null 'PGjsonb -|-> ("jsonb_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]) #

Expands the outermost binary JSON object into a set of key/value pairs.

>>> printSQL (select Star (from (jsonbEach (inline (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))))
SELECT * FROM jsonb_each(('{"a":"foo","b":"bar"}' :: jsonb))

jsonEach :: forall (null :: PGType -> NullType). null 'PGjson -|-> ("json_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]) #

Expands the outermost JSON object into a set of key/value pairs.

>>> printSQL (select Star (from (jsonEach (inline (Json (object ["a" .= "foo", "b" .= "bar"]))))))
SELECT * FROM json_each(('{"a":"foo","b":"bar"}' :: json))

jsonbPretty :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGtext #

Returns its argument as indented JSON text.

jsonbInsert :: forall (null :: PGType -> NullType). '[null 'PGjsonb, null ('PGvararray ('NotNull 'PGtext)), null 'PGjsonb, null 'PGbool] ---> null 'PGjsonb #

 jsonbInsert target path new_value insert_after

Returns target with new_value inserted. If target section designated by path is in a JSONB array, new_value will be inserted before target or after if insert_after is true. If target section designated by path is in JSONB object, new_value will be inserted only if target does not exist. As with the path orientated operators, negative integers that appear in path count from the end of JSON arrays.

jsonbSet :: forall (null :: PGType -> NullType). '[null 'PGjsonb, null ('PGvararray ('NotNull 'PGtext)), null 'PGjsonb, null 'PGbool] ---> null 'PGjsonb #

 jsonbSet target path new_value create_missing

Returns target with the section designated by path replaced by new_value, or with new_value added if create_missing is true and the item designated by path does not exist. As with the path orientated operators, negative integers that appear in path count from the end of JSON arrays.

jsonbStripNulls :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGjsonb #

Returns its argument with all object fields that have null values omitted. Other null values are untouched.

jsonStripNulls :: forall (null :: PGType -> NullType). null 'PGjson --> null 'PGjson #

Returns its argument with all object fields that have null values omitted. Other null values are untouched.

jsonbTypeof :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGtext #

Returns the type of the outermost binary JSON value as a text string. Possible types are object, array, string, number, boolean, and null.

jsonTypeof :: forall (null :: PGType -> NullType). null 'PGjson --> null 'PGtext #

Returns the type of the outermost JSON value as a text string. Possible types are object, array, string, number, boolean, and null.

jsonbArrayLength :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGint4 #

Returns the number of elements in the outermost binary JSON array.

jsonArrayLength :: forall (null :: PGType -> NullType). null 'PGjson --> null 'PGint4 #

Returns the number of elements in the outermost JSON array.

jsonbZipObject :: forall (null :: PGType -> NullType). '[null ('PGvararray ('NotNull 'PGtext)), null ('PGvararray ('NotNull 'PGtext))] ---> null 'PGjsonb #

This is an alternate form of jsonbObject that takes two arrays; one for keys and one for values, that are zipped pairwise to create a binary JSON object.

jsonZipObject :: forall (null :: PGType -> NullType). '[null ('PGvararray ('NotNull 'PGtext)), null ('PGvararray ('NotNull 'PGtext))] ---> null 'PGjson #

This is an alternate form of jsonObject that takes two arrays; one for keys and one for values, that are zipped pairwise to create a JSON object.

jsonbObject :: forall (null :: PGType -> NullType) (n :: Nat). null ('PGfixarray '[n, 2] ('NotNull 'PGtext)) --> null 'PGjsonb #

Builds a binary JSON object out of a text array. The array must have two dimensions such that each inner array has exactly two elements, which are taken as a key/value pair.

jsonObject :: forall (null :: PGType -> NullType) (n :: Nat). null ('PGfixarray '[n, 2] ('NotNull 'PGtext)) --> null 'PGjson #

Builds a JSON object out of a text array. The array must have two dimensions such that each inner array has exactly two elements, which are taken as a key/value pair.

jsonbBuildArray :: forall (tuple :: [NullType]) (null :: PGType -> NullType). SListI tuple => tuple ---> null 'PGjsonb #

Builds a possibly-heterogeneously-typed (binary) JSON array out of a variadic argument list.

jsonBuildArray :: forall (tuple :: [NullType]) (null :: PGType -> NullType). SListI tuple => tuple ---> null 'PGjson #

Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list.

rowToJson :: forall (null :: PGType -> NullType) (ty :: RowType). null ('PGcomposite ty) --> null 'PGjson #

Returns the row as a JSON object.

arrayToJson :: forall (null :: PGType -> NullType) (ty :: NullType). null ('PGvararray ty) --> null 'PGjson #

Returns the array as a JSON array. A PostgreSQL multidimensional array becomes a JSON array of arrays.

toJsonb :: forall (null :: PGType -> NullType) (ty :: PGType). null ty --> null 'PGjsonb #

Returns the value as jsonb. Arrays and composites are converted (recursively) to arrays and objects; otherwise, if there is a cast from the type to json, the cast function will be used to perform the conversion; otherwise, a scalar value is produced. For any scalar type other than a number, a Boolean, or a null value, the text representation will be used, in such a fashion that it is a valid jsonb value.

toJson :: forall (null :: PGType -> NullType) (ty :: PGType). null ty --> null 'PGjson #

Returns the value as json. Arrays and composites are converted (recursively) to arrays and objects; otherwise, if there is a cast from the type to json, the cast function will be used to perform the conversion; otherwise, a scalar value is produced. For any scalar type other than a number, a Boolean, or a null value, the text representation will be used, in such a fashion that it is a valid json value.

(#-.) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null ('PGvararray ('NotNull 'PGtext))) (null 'PGjsonb) infixl 6 #

Delete the field or element with specified path (for JSON arrays, negative integers count from the end)

(.-.) :: forall (key :: PGType) (null :: PGType -> NullType). In key '['PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2] => Operator (null 'PGjsonb) (null key) (null 'PGjsonb) infixl 6 #

Delete a key or keys from a JSON object, or remove an array element.

If the right operand is

text : Delete key / value pair or string element from left operand. Key / value pairs are matched based on their key value,

text[] : Delete multiple key / value pairs or string elements from left operand. Key / value pairs are matched based on their key value,

integer : Delete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.

(.?&) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null ('PGvararray ('NotNull 'PGtext))) ('Null 'PGbool) infixl 9 #

Do all of these array strings exist as top-level keys?

(.?|) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null ('PGvararray ('NotNull 'PGtext))) ('Null 'PGbool) infixl 9 #

Do any of these array strings exist as top-level keys?

(.?) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null 'PGtext) ('Null 'PGbool) infixl 9 #

Does the string exist as a top-level key within the JSON value?

(.#>>) :: forall (json :: PGType) (null :: PGType -> NullType). In json PGJsonType => Operator (null json) (null ('PGvararray ('NotNull 'PGtext))) ('Null 'PGtext) infixl 8 #

Get JSON value at a specified path as text.

(.#>) :: forall (json :: PGType) (null :: PGType -> NullType). In json PGJsonType => Operator (null json) (null ('PGvararray ('NotNull 'PGtext))) ('Null json) infixl 8 #

Get JSON value at a specified path.

(.->>) :: forall (json :: PGType) (key :: PGType) (null :: PGType -> NullType). (In json PGJsonType, In key PGJsonKey) => Operator (null json) (null key) ('Null 'PGtext) infixl 8 #

Get JSON value (object field or array element) at a key, as text.

(.->) :: forall (json :: PGType) (key :: PGType) (null :: PGType -> NullType). (In json PGJsonType, In key PGJsonKey) => Operator (null json) (null key) ('Null json) infixl 8 #

Get JSON value (object field or array element) at a key.

class SListI tys => JsonBuildObject (tys :: [NullType]) where #

Builds a possibly-heterogeneously-typed JSON object out of a variadic argument list. The elements of the argument list must alternate between text and values.

Minimal complete definition

Nothing

Methods

jsonBuildObject :: forall (null :: PGType -> NullType). tys ---> null 'PGjson #

jsonbBuildObject :: forall (null :: PGType -> NullType). tys ---> null 'PGjsonb #

Instances

Instances details
JsonBuildObject ('[] :: [NullType]) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Json

Methods

jsonBuildObject :: forall (null :: PGType -> NullType). '[] ---> null 'PGjson #

jsonbBuildObject :: forall (null :: PGType -> NullType). '[] ---> null 'PGjsonb #

(JsonBuildObject tys, In key PGJsonKey) => JsonBuildObject ('NotNull key ': (value ': tys)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Json

Methods

jsonBuildObject :: forall (null :: PGType -> NullType). ('NotNull key ': (value ': tys)) ---> null 'PGjson #

jsonbBuildObject :: forall (null :: PGType -> NullType). ('NotNull key ': (value ': tys)) ---> null 'PGjsonb #

type JsonPopulateFunction (fun :: Symbol) (json :: PGType) #

Arguments

 = forall (db :: SchemasType) (row :: RowType) (lat :: FromType) (with :: FromType) (params :: [NullType]). In json PGJsonType 
=> TypeExpression db ('NotNull ('PGcomposite row))

row type

-> Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]) ('NotNull json)

json type

-> FromClause lat with db params '[fun ::: row] 

Build rows from Json types.

type JsonToRecordFunction (json :: PGType) #

Arguments

 = forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (tab :: Symbol) (row :: [(Symbol, NullType)]). (SListI row, In json PGJsonType) 
=> Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]) ('NotNull json)

json type

-> Aliased (NP (Aliased (TypeExpression db))) (tab ::: row)

row type

-> FromClause lat with db params '[tab ::: row] 

Build rows from Json types.

nullIf :: forall (ty :: PGType). '['NotNull ty, 'NotNull ty] ---> 'Null ty #

right inverse to fromNull, if its arguments are equal then nullIf gives NULL.

>>> :set -XTypeApplications
>>> printSQL (nullIf (false *: param @1))
NULLIF(FALSE, ($1 :: bool))

matchNull #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (nullty :: NullType) (ty :: PGType). Expression grp lat with db params from nullty

what to convert NULL to

-> (Expression grp lat with db params from ('NotNull ty) -> Expression grp lat with db params from nullty)

function to perform when NULL is absent

-> Expression grp lat with db params from ('Null ty) 
-> Expression grp lat with db params from nullty 

analagous to maybe using IS NULL

>>> printSQL $ matchNull true not_ null_
CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END

isNotNull :: forall (ty :: PGType) (null :: PGType -> NullType). 'Null ty --> null 'PGbool #

>>> printSQL $ null_ & isNotNull
NULL IS NOT NULL

isNull :: forall (ty :: PGType) (null :: PGType -> NullType). 'Null ty --> null 'PGbool #

>>> printSQL $ null_ & isNull
NULL IS NULL

fromNull #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). Expression grp lat with db params from ('NotNull ty)

what to convert NULL to

-> Expression grp lat with db params from ('Null ty) 
-> Expression grp lat with db params from ('NotNull ty) 

analagous to fromMaybe using COALESCE

>>> printSQL $ fromNull true null_
COALESCE(NULL, TRUE)

coalesce :: forall (ty :: PGType) (null :: PGType -> NullType). FunctionVar ('Null ty) (null ty) (null ty) #

return the leftmost value which is not NULL

>>> printSQL $ coalesce [null_, true] false
COALESCE(NULL, TRUE, FALSE)

monoNotNull #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). (forall (null :: PGType -> NullType). Expression grp lat with db params from (null ty))

null polymorphic

-> Expression grp lat with db params from ('NotNull ty) 

Some expressions are null polymorphic which may raise inference issues. Use monoNotNull to fix their nullity as NotNull.

unsafeNotNull :: forall (ty :: PGType). 'Null ty --> 'NotNull ty #

Analagous to fromJust inverse to notNull, useful when you know an Expression is NotNull, because, for instance, you've filtered out NULL values in a column.

notNull :: forall (ty :: PGType). 'NotNull ty --> 'Null ty #

analagous to Just

>>> printSQL $ notNull true
TRUE

null_ :: forall (ty :: PGType). Expr ('Null ty) #

analagous to Nothing

>>> printSQL null_
NULL

notIn #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) (null :: PGType -> NullType). Expression grp lat with db params from ty

expression

-> [Expression grp lat with db params from ty] 
-> Expression grp lat with db params from (null 'PGbool) 

The result is true if the left-hand expression's result is not equal to any of the right-hand expressions.

>>> printSQL $ true `notIn` [false, null_]
TRUE NOT IN (FALSE, NULL)

in_ #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) (null :: PGType -> NullType). Expression grp lat with db params from ty

expression

-> [Expression grp lat with db params from ty] 
-> Expression grp lat with db params from (null 'PGbool) 

The result is true if the left-hand expression's result is equal to any of the right-hand expressions.

>>> printSQL $ true `in_` [true, false, null_]
TRUE IN (TRUE, FALSE, NULL)

subAny #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType) (col :: Symbol). Expression grp lat with db params from ty1

expression

-> Operator ty1 ty2 ('Null 'PGbool)

operator

-> Query (Join lat from) with db params '[col ::: ty2]

subquery

-> Condition grp lat with db params from 

The right-hand side is a parenthesized subquery, which must return exactly one column. The left-hand expression is evaluated and compared to each row of the subquery result using the given Operator, which must yield a Boolean result. The result of subAny is true if any true result is obtained. The result is false if no true result is found (including the case where the subquery returns no rows).

>>> printSQL $ subAny "foo" like (values_ ("foobar" `as` #foo))
((E'foo' :: text) LIKE ANY (SELECT * FROM (VALUES ((E'foobar' :: text))) AS t ("foo")))

subAll #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType) (col :: Symbol). Expression grp lat with db params from ty1

expression

-> Operator ty1 ty2 ('Null 'PGbool)

operator

-> Query (Join lat from) with db params '[col ::: ty2]

subquery

-> Condition grp lat with db params from 

The right-hand side is a parenthesized subquery, which must return exactly one column. The left-hand expression is evaluated and compared to each row of the subquery result using the given Operator, which must yield a Boolean result. The result of subAll is true if all rows yield true (including the case where the subquery returns no rows). The result is false if any false result is found. The result is null_ if no comparison with a subquery row returns false, and at least one comparison returns null_.

>>> printSQL $ subAll true (.==) (values_ (true `as` #foo))
(TRUE = ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo")))

exists #

Arguments

:: forall (lat :: [(Symbol, RowType)]) (from :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (row :: RowType) (grp :: Grouping) (null :: PGType -> NullType). Query (Join lat from) with db params row

subquery

-> Expression grp lat with db params from (null 'PGbool) 

The argument of exists is an arbitrary subquery. The subquery is evaluated to determine whether it returns any rows. If it returns at least one row, the result of exists is true; if the subquery returns no rows, the result of exists is false.

The subquery can refer to variables from the surrounding query, which will act as constants during any one evaluation of the subquery.

The subquery will generally only be executed long enough to determine whether at least one row is returned, not all the way to completion.

fullOuterJoinLateral #

Arguments

:: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query

right subquery

-> Condition 'Ungrouped lat with db params (Join left '[query])

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (NullifyFrom (Join left '[query])) 

Like fullOuterJoin with a subquery but allowed to reference columns provided by preceding FromClause items.

fullOuterJoin #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right

right

-> Condition 'Ungrouped lat with db params (Join left right)

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (NullifyFrom (Join left right)) 

left & fullOuterJoin right on. First, an inner join is performed. Then, for each row in left that does not satisfy the on condition with any row in right, a joined row is added with null values in columns of right. Also, for each row of right that does not satisfy the join condition with any row in left, a joined row with null values in the columns of left is added.

fullOuter #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right

right

-> Condition 'Ungrouped lat with db params (Join left right)

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (NullifyFrom (Join left right)) 

left & fullOuter (Join right) on. First, an inner join is performed. Then, for each row in left that does not satisfy the on condition with any row in right, a joined row is added with null values in columns of right. Also, for each row of right that does not satisfy the join condition with any row in left, a joined row with null values in the columns of left is added.

rightOuterJoinLateral #

Arguments

:: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query

right subquery

-> Condition 'Ungrouped lat with db params (Join left '[query])

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join (NullifyFrom left) '[query]) 

Like rightOuterJoin with a subquery but allowed to reference columns provided by preceding FromClause items.

rightOuterJoin #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right

right

-> Condition 'Ungrouped lat with db params (Join left right)

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join (NullifyFrom left) right) 

left & rightOuterJoin right on. First, an inner join is performed. Then, for each row in right that does not satisfy the on condition with any row in left, a joined row is added with null values in columns of left. This is the converse of a left join: the result table will always have a row for each row in right.

rightOuter #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right

right

-> Condition 'Ungrouped lat with db params (Join left right)

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join (NullifyFrom left) right) 

left & rightOuter (Join right) on. First, an inner join is performed. Then, for each row in right that does not satisfy the on condition with any row in left, a joined row is added with null values in columns of left. This is the converse of a left join: the result table will always have a row for each row in right.

leftOuterJoinLateral #

Arguments

:: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query

right subquery

-> Condition 'Ungrouped lat with db params (Join left '[query])

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join left (NullifyFrom '[query])) 

Like leftOuterJoin with a subquery but allowed to reference columns provided by preceding FromClause items.

leftOuterJoin #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right

right

-> Condition 'Ungrouped lat with db params (Join left right)

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join left (NullifyFrom right)) 

left & leftOuterJoin right on. First, an inner join is performed. Then, for each row in left that does not satisfy the on condition with any row in right, a joined row is added with null values in columns of right. Thus, the joined table always has at least one row for each row in left.

leftOuter #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right

right

-> Condition 'Ungrouped lat with db params (Join left right)

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join left (NullifyFrom right)) 

left & leftOuter (Join right) on. First, an inner join is performed. Then, for each row in left that does not satisfy the on condition with any row in right, a joined row is added with null values in columns of right. Thus, the joined table always has at least one row for each row in left.

innerJoinLateral #

Arguments

:: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query

right subquery

-> Condition 'Ungrouped lat with db params (Join left '[query])

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join left '[query]) 

Like innerJoin with a subquery but allowed to reference columns provided by preceding FromClause items.

innerJoin #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right

right

-> Condition 'Ungrouped lat with db params (Join left right)

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join left right) 

left & innerJoin right on. The joined table is filtered by the on condition.

inner #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right

right

-> Condition 'Ungrouped lat with db params (Join left right)

ON condition

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join left right) 

left & inner (Join right) on. The joined table is filtered by the on condition.

crossJoinLateral #

Arguments

:: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query

right subquery

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join left '[query]) 

Like crossJoin with a subquery but allowed to reference columns provided by preceding FromClause items.

crossJoin #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: FromType). FromClause lat with db params right

right

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join left right) 

left & crossJoin right. For every possible combination of rows from left and right (i.e., a Cartesian product), the joined table will contain a row consisting of all columns in left followed by all columns in right. If the tables have n and m rows respectively, the joined table will have n * m rows.

cross #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right

right

-> FromClause lat with db params left

left

-> FromClause lat with db params (Join left right) 

left & cross (Join right). For every possible combination of rows from left and right (i.e., a Cartesian product), the joined table will contain a row consisting of all columns in left followed by all columns in right. If the tables have n and m rows respectively, the joined table will have n * m rows.

data JoinItem (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType) where #

A JoinItem is the right hand side of a cross, inner, leftOuter, rightOuter, fullOuter join of FromClauses.

Constructors

Join 

Fields

JoinLateral 

Fields

JoinFunction 

Fields

JoinFunctionN 

Fields

Instances

Instances details
RenderSQL (JoinItem lat with db params left right) 
Instance details

Defined in Squeal.PostgreSQL.Query.From.Join

Methods

renderSQL :: JoinItem lat with db params left right -> ByteString #

lockRows #

Arguments

:: forall (from :: [(Symbol, RowType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). LockingClause from

row-level lock

-> TableExpression grp lat with db params from 
-> TableExpression grp lat with db params from 

Add a LockingClause to a TableExpression. Multiple LockingClauses can be written if it is necessary to specify different locking behavior for different tables. If the same table is mentioned (or implicitly affected) by more than one locking clause, then it is processed as if it was only specified by the strongest one. Similarly, a table is processed as NoWait if that is specified in any of the clauses affecting it. Otherwise, it is processed as SkipLocked if that is specified in any of the clauses affecting it.

offset #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Word64

offset parameter

-> TableExpression grp lat with db params from 
-> TableExpression grp lat with db params from 

An offset is an endomorphism of TableExpressions which adds to the offsetClause.

limit #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Word64

limit parameter

-> TableExpression grp lat with db params from 
-> TableExpression grp lat with db params from 

A limit is an endomorphism of TableExpressions which adds to the limitClause.

having #

Arguments

:: forall (bys :: [(Symbol, Symbol)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Condition ('Grouped bys) lat with db params from

having condition

-> TableExpression ('Grouped bys) lat with db params from 
-> TableExpression ('Grouped bys) lat with db params from 

A having is an endomorphism of TableExpressions which adds a search condition to the havingClause.

groupBy #

Arguments

:: forall (bys :: [(Symbol, Symbol)]) (from :: FromType) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI bys 
=> NP (By from) bys

grouped columns

-> TableExpression 'Ungrouped lat with db params from 
-> TableExpression ('Grouped bys) lat with db params from 

A groupBy is a transformation of TableExpressions which switches its Grouping from Ungrouped to Grouped. Use groupBy Nil to perform a "grand total" aggregation query.

where_ #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (grp :: Grouping). Condition 'Ungrouped lat with db params from

filtering condition

-> TableExpression grp lat with db params from 
-> TableExpression grp lat with db params from 

A where_ is an endomorphism of TableExpressions which adds a search condition to the whereClause.

from #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). FromClause lat with db params from

table reference

-> TableExpression 'Ungrouped lat with db params from 

A from generates a TableExpression from a table reference that can be a table name, or a derived table such as a subquery, a JOIN construct, or complex combinations of these. A from may be transformed by where_, groupBy, having, orderBy, limit and offset, using the & operator to match the left-to-right sequencing of their placement in SQL.

data TableExpression (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) #

A TableExpression computes a table. The table expression contains a fromClause that is optionally followed by a whereClause, groupByClause, havingClause, orderByClause, limitClause offsetClause and lockingClauses. Trivial table expressions simply refer to a table on disk, a so-called base table, but more complex expressions can be used to modify or combine base tables in various ways.

Constructors

TableExpression 

Fields

  • fromClause :: FromClause lat with db params from

    A table reference that can be a table name, or a derived table such as a subquery, a JOIN construct, or complex combinations of these.

  • whereClause :: [Condition 'Ungrouped lat with db params from]

    optional search coditions, combined with .&&. After the processing of the fromClause is done, each row of the derived virtual table is checked against the search condition. If the result of the condition is true, the row is kept in the output table, otherwise it is discarded. The search condition typically references at least one column of the table generated in the fromClause; this is not required, but otherwise the WHERE clause will be fairly useless.

  • groupByClause :: GroupByClause grp from

    The groupByClause is used to group together those rows in a table that have the same values in all the columns listed. The order in which the columns are listed does not matter. The effect is to combine each set of rows having common values into one group row that represents all rows in the group. This is done to eliminate redundancy in the output and/or compute aggregates that apply to these groups.

  • havingClause :: HavingClause grp lat with db params from

    If a table has been grouped using groupBy, but only certain groups are of interest, the havingClause can be used, much like a whereClause, to eliminate groups from the result. Expressions in the havingClause can refer both to grouped expressions and to ungrouped expressions (which necessarily involve an aggregate function).

  • orderByClause :: [SortExpression grp lat with db params from]

    The orderByClause is for optional sorting. When more than one SortExpression is specified, the later (right) values are used to sort rows that are equal according to the earlier (left) values.

  • limitClause :: [Word64]

    The limitClause is combined with min to give a limit count if nonempty. If a limit count is given, no more than that many rows will be returned (but possibly fewer, if the query itself yields fewer rows).

  • offsetClause :: [Word64]

    The offsetClause is combined with + to give an offset count if nonempty. The offset count says to skip that many rows before beginning to return rows. The rows are skipped before the limit count is applied.

  • lockingClauses :: [LockingClause from]

    lockingClauses can be added to a table expression with lockRows.

Instances

Instances details
OrderBy (TableExpression grp) grp 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from] -> TableExpression grp lat with db params from -> TableExpression grp lat with db params from #

Generic (TableExpression grp lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Associated Types

type Rep (TableExpression grp lat with db params from) :: Type -> Type #

Methods

from :: TableExpression grp lat with db params from -> Rep (TableExpression grp lat with db params from) x #

to :: Rep (TableExpression grp lat with db params from) x -> TableExpression grp lat with db params from #

RenderSQL (TableExpression grp lat with db params from)

Render a TableExpression

Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

renderSQL :: TableExpression grp lat with db params from -> ByteString #

type Rep (TableExpression grp lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

type Rep (TableExpression grp lat with db params from) = D1 ('MetaData "TableExpression" "Squeal.PostgreSQL.Query.Table" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) (C1 ('MetaCons "TableExpression" 'PrefixI 'True) (((S1 ('MetaSel ('Just "fromClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FromClause lat with db params from)) :*: S1 ('MetaSel ('Just "whereClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Condition 'Ungrouped lat with db params from])) :*: (S1 ('MetaSel ('Just "groupByClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (GroupByClause grp from)) :*: S1 ('MetaSel ('Just "havingClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (HavingClause grp lat with db params from)))) :*: ((S1 ('MetaSel ('Just "orderByClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [SortExpression grp lat with db params from]) :*: S1 ('MetaSel ('Just "limitClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Word64])) :*: (S1 ('MetaSel ('Just "offsetClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Word64]) :*: S1 ('MetaSel ('Just "lockingClauses") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [LockingClause from])))))

data By (from :: FromType) (by :: (Symbol, Symbol)) where #

Bys are used in groupBy to reference a list of columns which are then used to group together those rows in a table that have the same values in all the columns listed. By #col will reference an unambiguous column col; otherwise By2 (#tab ! #col) will reference a table qualified column tab.col.

Constructors

By1 :: forall (table :: Symbol) (from :: FromType) (columns :: [(Symbol, NullType)]) (column :: Symbol) (ty :: NullType). (HasUnique table from columns, Has column columns ty) => Alias column -> By from '(table, column) 
By2 :: forall (table :: Symbol) (from :: FromType) (columns :: [(Symbol, NullType)]) (column :: Symbol) (ty :: NullType). (Has table from columns, Has column columns ty) => Alias table -> Alias column -> By from '(table, column) 

Instances

Instances details
(Has rel rels cols, Has col cols ty, by ~ '(rel, col)) => IsQualified rel col (By rels by) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

(!) :: Alias rel -> Alias col -> By rels by #

(Has rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsQualified rel col (NP (By rels) bys) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

(!) :: Alias rel -> Alias col -> NP (By rels) bys #

(HasUnique rel rels cols, Has col cols ty, by ~ '(rel, col)) => IsLabel col (By rels by) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

fromLabel :: By rels by #

(HasUnique rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsLabel col (NP (By rels) bys) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

fromLabel :: NP (By rels) bys #

Eq (By from by) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

(==) :: By from by -> By from by -> Bool #

(/=) :: By from by -> By from by -> Bool #

Ord (By from by) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

compare :: By from by -> By from by -> Ordering #

(<) :: By from by -> By from by -> Bool #

(<=) :: By from by -> By from by -> Bool #

(>) :: By from by -> By from by -> Bool #

(>=) :: By from by -> By from by -> Bool #

max :: By from by -> By from by -> By from by #

min :: By from by -> By from by -> By from by #

Show (By from by) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

showsPrec :: Int -> By from by -> ShowS #

show :: By from by -> String #

showList :: [By from by] -> ShowS #

RenderSQL (By from by) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

renderSQL :: By from by -> ByteString #

newtype GroupByClause (grp :: k) (from :: k1) #

A GroupByClause indicates the Grouping of a TableExpression.

Instances

Instances details
Eq (GroupByClause grp from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

(==) :: GroupByClause grp from -> GroupByClause grp from -> Bool #

(/=) :: GroupByClause grp from -> GroupByClause grp from -> Bool #

Ord (GroupByClause grp from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

compare :: GroupByClause grp from -> GroupByClause grp from -> Ordering #

(<) :: GroupByClause grp from -> GroupByClause grp from -> Bool #

(<=) :: GroupByClause grp from -> GroupByClause grp from -> Bool #

(>) :: GroupByClause grp from -> GroupByClause grp from -> Bool #

(>=) :: GroupByClause grp from -> GroupByClause grp from -> Bool #

max :: GroupByClause grp from -> GroupByClause grp from -> GroupByClause grp from #

min :: GroupByClause grp from -> GroupByClause grp from -> GroupByClause grp from #

Show (GroupByClause grp from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

showsPrec :: Int -> GroupByClause grp from -> ShowS #

show :: GroupByClause grp from -> String #

showList :: [GroupByClause grp from] -> ShowS #

Generic (GroupByClause grp from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Associated Types

type Rep (GroupByClause grp from) :: Type -> Type #

Methods

from :: GroupByClause grp from -> Rep (GroupByClause grp from) x #

to :: Rep (GroupByClause grp from) x -> GroupByClause grp from #

NFData (GroupByClause grp from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

rnf :: GroupByClause grp from -> () #

RenderSQL (GroupByClause grp from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

renderSQL :: GroupByClause grp from -> ByteString #

type Rep (GroupByClause grp from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

type Rep (GroupByClause grp from) = D1 ('MetaData "GroupByClause" "Squeal.PostgreSQL.Query.Table" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeGroupByClause" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderGroupByClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

data HavingClause (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) where #

A HavingClause is used to eliminate groups that are not of interest. An Ungrouped TableExpression may only use NoHaving while a Grouped TableExpression must use Having whose conditions are combined with .&&.

Constructors

NoHaving :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). HavingClause 'Ungrouped lat with db params from 
Having :: forall (bys :: [(Symbol, Symbol)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [Condition ('Grouped bys) lat with db params from] -> HavingClause ('Grouped bys) lat with db params from 

Instances

Instances details
Eq (HavingClause grp lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

(==) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool #

(/=) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool #

Ord (HavingClause grp lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

compare :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Ordering #

(<) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool #

(<=) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool #

(>) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool #

(>=) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool #

max :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> HavingClause grp lat with db params from #

min :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> HavingClause grp lat with db params from #

Show (HavingClause grp lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

showsPrec :: Int -> HavingClause grp lat with db params from -> ShowS #

show :: HavingClause grp lat with db params from -> String #

showList :: [HavingClause grp lat with db params from] -> ShowS #

RenderSQL (HavingClause grp lat with db params from)

Render a HavingClause.

Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

renderSQL :: HavingClause grp lat with db params from -> ByteString #

data LockingClause (from :: [(Symbol, kind)]) where #

If specific tables are named in a locking clause, then only rows coming from those tables are locked; any other tables used in the select are simply read as usual. A locking clause with a Nil table list affects all tables used in the statement. If a locking clause is applied to a view or subquery, it affects all tables used in the view or subquery. However, these clauses do not apply to with queries referenced by the primary query. If you want row locking to occur within a with query, specify a LockingClause within the with query.

Constructors

For 

Fields

Instances

Instances details
RenderSQL (LockingClause from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

data LockStrength #

Row-level locks, which are listed as below with the contexts in which they are used automatically by PostgreSQL. Note that a transaction can hold conflicting locks on the same row, even in different subtransactions; but other than that, two transactions can never hold conflicting locks on the same row. Row-level locks do not affect data querying; they block only writers and lockers to the same row. Row-level locks are released at transaction end or during savepoint rollback.

Constructors

Update

For Update causes the rows retrieved by the select statement to be locked as though for update. This prevents them from being locked, modified or deleted by other transactions until the current transaction ends. That is, other transactions that attempt update, deleteFrom, select For Update, select For NoKeyUpdate, select For Share or select For KeyShare of these rows will be blocked until the current transaction ends; conversely, select For Update will wait for a concurrent transaction that has run any of those commands on the same row, and will then lock and return the updated row (or no row, if the row was deleted). Within a RepeatableRead or Serializable transaction, however, an error will be thrown if a row to be locked has changed since the transaction started.

The For Update lock mode is also acquired by any deleteFrom a row, and also by an Update that modifies the values on certain columns. Currently, the set of columns considered for the update case are those that have a unique index on them that can be used in a foreign key (so partial indexes and expressional indexes are not considered), but this may change in the future.

NoKeyUpdate 
Share

Behaves similarly to For Update, except that the lock acquired is weaker: this lock will not block select For KeyShare commands that attempt to acquire a lock on the same rows. This lock mode is also acquired by any update that does not acquire a For Update lock.

KeyShare

Behaves similarly to For Share, except that the lock is weaker: select For Update is blocked, but not select For NoKeyUpdate. A key-shared lock blocks other transactions from performing deleteFrom or any update that changes the key values, but not other Update, and neither does it prevent select For NoKeyUpdate, select For Share, or select For KeyShare.

Instances

Instances details
Enum LockStrength 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Eq LockStrength 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Ord LockStrength 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Read LockStrength 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Show LockStrength 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Generic LockStrength 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Associated Types

type Rep LockStrength :: Type -> Type #

RenderSQL LockStrength 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

type Rep LockStrength 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

type Rep LockStrength = D1 ('MetaData "LockStrength" "Squeal.PostgreSQL.Query.Table" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) ((C1 ('MetaCons "Update" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NoKeyUpdate" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Share" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KeyShare" 'PrefixI 'False) (U1 :: Type -> Type)))

data Waiting #

To prevent the operation from Waiting for other transactions to commit, use either the NoWait or SkipLocked option.

Constructors

Wait

wait for other transactions to commit

NoWait

reports an error, rather than waiting

SkipLocked

any selected rows that cannot be immediately locked are skipped

Instances

Instances details
Enum Waiting 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Eq Waiting 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

(==) :: Waiting -> Waiting -> Bool #

(/=) :: Waiting -> Waiting -> Bool #

Ord Waiting 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Read Waiting 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Show Waiting 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Generic Waiting 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Associated Types

type Rep Waiting :: Type -> Type #

Methods

from :: Waiting -> Rep Waiting x #

to :: Rep Waiting x -> Waiting #

RenderSQL Waiting 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

type Rep Waiting 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

type Rep Waiting = D1 ('MetaData "Waiting" "Squeal.PostgreSQL.Query.Table" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) (C1 ('MetaCons "Wait" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NoWait" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SkipLocked" 'PrefixI 'False) (U1 :: Type -> Type)))

ifThenElse #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType). Condition grp lat with db params from 
-> Expression grp lat with db params from ty

then

-> Expression grp lat with db params from ty

else

-> Expression grp lat with db params from ty 
>>> :{
let
  expression :: Expression grp lat with db params from (null 'PGint2)
  expression = ifThenElse true 1 0
in printSQL expression
:}
CASE WHEN TRUE THEN (1 :: int2) ELSE (0 :: int2) END

caseWhenThenElse #

Arguments

:: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType). [(Condition grp lat with db params from, Expression grp lat with db params from ty)]

whens and thens

-> Expression grp lat with db params from ty

else

-> Expression grp lat with db params from ty 
>>> :{
let
  expression :: Expression grp lat with db params from (null 'PGint2)
  expression = caseWhenThenElse [(true, 1), (false, 2)] 3
in printSQL expression
:}
CASE WHEN TRUE THEN (1 :: int2) WHEN FALSE THEN (2 :: int2) ELSE (3 :: int2) END

(.||) :: forall (null :: PGType -> NullType). Operator (null 'PGbool) (null 'PGbool) (null 'PGbool) infixr 2 #

>>> printSQL $ true .|| false
(TRUE OR FALSE)

(.&&) :: forall (null :: PGType -> NullType). Operator (null 'PGbool) (null 'PGbool) (null 'PGbool) infixr 3 #

>>> printSQL $ true .&& false
(TRUE AND FALSE)

not_ :: forall (null :: PGType -> NullType). null 'PGbool --> null 'PGbool #

>>> printSQL $ not_ true
(NOT TRUE)

false :: forall (null :: PGType -> NullType). Expr (null 'PGbool) #

>>> printSQL false
FALSE

true :: forall (null :: PGType -> NullType). Expr (null 'PGbool) #

>>> printSQL true
TRUE

type Condition (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) = Expression grp lat with db params from ('Null 'PGbool) #

A Condition is an Expression, which can evaluate to true, false or null_. This is because SQL uses a three valued logic.

ceiling_ :: forall (frac :: PGType) (null :: PGType -> NullType). In frac PGFloating => null frac --> null frac #

>>> :{
let
  expression :: Expression grp lat with db params from (null 'PGfloat4)
  expression = ceiling_ pi
in printSQL expression
:}
ceiling(pi())

round_ :: forall (frac :: PGType) (null :: PGType -> NullType). In frac PGFloating => null frac --> null frac #

>>> :{
let
  expression :: Expression grp lat with db params from (null 'PGfloat4)
  expression = round_ pi
in printSQL expression
:}
round(pi())

trunc :: forall (frac :: PGType) (null :: PGType -> NullType). In frac PGFloating => null frac --> null frac #

>>> :{
let
  expression :: Expression grp lat with db params from (null 'PGfloat4)
  expression = trunc pi
in printSQL expression
:}
trunc(pi())

rem_ :: forall (int :: PGType) (null :: PGType -> NullType). In int PGIntegral => Operator (null int) (null int) (null int) #

remainder upon integer division

>>> :{
let
  expression :: Expression grp lat with db params from (null 'PGint2)
  expression = 5 `rem_` 2
in printSQL expression
:}
((5 :: int2) % (2 :: int2))

quot_ :: forall (int :: PGType) (null :: PGType -> NullType). In int PGIntegral => Operator (null int) (null int) (null int) #

integer division, truncates the result

>>> :{
let
  expression :: Expression grp lat with db params from (null 'PGint2)
  expression = 5 `quot_` 2
in printSQL expression
:}
((5 :: int2) / (2 :: int2))

atan2_ :: forall (float :: PGType) (null :: PGType -> NullType). In float PGFloating => '[null float, null float] ---> null float #

>>> :{
let
  expression :: Expr (null 'PGfloat4)
  expression = atan2_ (pi *: 2)
in printSQL expression
:}
atan2(pi(), (2.0 :: float4))

param #

Arguments

:: forall (n :: Nat) (ty :: NullType) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (grp :: Grouping). (NullTyped db ty, HasParameter n params ty) 
=> Expression grp lat with db params from ty

param

param takes a Nat using type application and for basic types, infers a TypeExpression.

>>> printSQL (param @1 @('Null 'PGint4))
($1 :: int4)

class KnownNat n => HasParameter (n :: Nat) (params :: [NullType]) (ty :: NullType) | n params -> ty where #

A HasParameter constraint is used to indicate a value that is supplied externally to a SQL statement. manipulateParams, queryParams and traversePrepared support specifying data values separately from the SQL command string, in which case params are used to refer to the out-of-line data values.

Minimal complete definition

Nothing

Methods

parameter :: forall (db :: SchemasType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (from :: FromType). TypeExpression db ty -> Expression grp lat with db params from ty #

parameter takes a Nat using type application and a TypeExpression.

>>> printSQL (parameter @1 int4)
($1 :: int4)

Instances

Instances details
(KnownNat n, HasParameter (n - 1) xs x, params ~ (y ': xs)) => HasParameter n params x 
Instance details

Defined in Squeal.PostgreSQL.Expression.Parameter

Methods

parameter :: forall (db :: SchemasType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (from :: FromType). TypeExpression db x -> Expression grp lat with db params from x #

params ~ (x ': xs) => HasParameter 1 params x 
Instance details

Defined in Squeal.PostgreSQL.Expression.Parameter

Methods

parameter :: forall (db :: SchemasType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (from :: FromType). TypeExpression db x -> Expression grp lat with db params from x #

cmdTuples :: MonadIO io => Result y -> io (Maybe Row) #

Returns the number of rows affected by the SQL command. This function returns Just the number of rows affected by the SQL statement that generated the Result. This function can only be used following the execution of a SELECT, CREATE TABLE AS, INSERT, UPDATE, DELETE, MOVE, FETCH, or COPY statement,or an EXECUTE of a prepared query that contains an INSERT, UPDATE, or DELETE statement. If the command that generated the PGresult was anything else, cmdTuples returns Nothing.

cmdStatus :: MonadIO io => Result y -> io Text #

Returns the command status tag from the SQL command that generated the Result. Commonly this is just the name of the command, but it might include additional data such as the number of rows processed.

liftResult :: MonadIO io => (Result -> IO x) -> Result y -> io x #

Lifts actions on results from LibPQ.

data Result y where #

Results are generated by executing Statements in a MonadPQ.

They contain an underlying Result and a DecodeRow.

Constructors

Result :: forall (row :: [(Symbol, NullType)]) y. SListI row => DecodeRow row y -> Result -> Result y 

Instances

Instances details
Functor Result 
Instance details

Defined in Squeal.PostgreSQL.Session.Result

Methods

fmap :: (a -> b) -> Result a -> Result b #

(<$) :: a -> Result b -> Result a #

enumValue :: forall (labels :: [Symbol]) y. (All KnownSymbol labels, PG y ~ 'PGenum labels) => NP (K y :: Symbol -> Type) labels -> StateT ByteString (Except Text) y #

>>> :{
data Dir = North | East | South | West
instance IsPG Dir where
  type PG Dir = 'PGenum '["north", "south", "east", "west"]
instance FromPG Dir where
  fromPG = enumValue $
    label @"north" North :*
    label @"south" South :*
    label @"east" East :*
    label @"west" West
:}

genericRow :: forall (row :: [(Symbol, NullType)]) y (ys :: RecordCode). (IsRecord y ys, AllZip FromField row ys) => DecodeRow row y #

Row decoder for Generic records.

>>> import qualified GHC.Generics as GHC
>>> import qualified Generics.SOP as SOP
>>> data Two = Two {frst :: Int16, scnd :: String} deriving (Show, GHC.Generic, SOP.Generic, SOP.HasDatatypeInfo)
>>> :{
let
  decode :: DecodeRow '[ "frst" ::: 'NotNull 'PGint2, "scnd" ::: 'NotNull 'PGtext] Two
  decode = genericRow
in runDecodeRow decode (SOP.K (Just "\NUL\STX") :* SOP.K (Just "two") :* Nil)
:}
Right (Two {frst = 2, scnd = "two"})

decodeRow :: forall (row :: [(Symbol, NullType)]) y. (NP (K (Maybe ByteString) :: (Symbol, NullType) -> Type) row -> Either Text y) -> DecodeRow row y #

Smart constructor for a DecodeRow.

consRow #

Arguments

:: forall (head :: NullType) h t z (col :: Symbol) (tail :: RowType). FromValue head h 
=> (h -> t -> z)

combining function

-> Alias col

alias of head

-> DecodeRow tail t

tail decoder

-> DecodeRow ((col ::: head) ': tail) z 

Cons a column and a row decoder with a combining function.

>>> :{
let
  decode :: DecodeRow
    '["fst" ::: 'NotNull 'PGtext, "snd" ::: 'NotNull 'PGint2, "thrd" ::: 'NotNull ('PGchar 1)]
    (String, (Int16, Char))
  decode = consRow (,) #fst (consRow (,) #snd #thrd)
in runDecodeRow decode (SOP.K (Just "hi") :* SOP.K (Just "\NUL\SOH") :* SOP.K (Just "a") :* Nil)
:}
Right ("hi",(1,'a'))

appendRows #

Arguments

:: forall (left :: [(Symbol, NullType)]) l r z (right :: RowType). SListI left 
=> (l -> r -> z)

combining function

-> DecodeRow left l

left decoder

-> DecodeRow right r

right decoder

-> DecodeRow (Join left right) z 

Append two row decoders with a combining function.

>>> import GHC.Generics as GHC
>>> :{
data L = L {fst :: Int16, snd :: Char}
  deriving stock (GHC.Generic, Show)
  deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
data R = R {thrd :: Bool, frth :: Bool}
  deriving stock (GHC.Generic, Show)
  deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
type Row = '[
  "fst" ::: 'NotNull 'PGint2,
  "snd" ::: 'NotNull ('PGchar 1),
  "thrd" ::: 'NotNull 'PGbool,
  "frth" ::: 'NotNull 'PGbool]
:}
>>> :{
let
  decode :: DecodeRow Row (L,R)
  decode = appendRows (,) genericRow genericRow
  row4 =
    SOP.K (Just "\NUL\SOH") :*
    SOP.K (Just "a") :*
    SOP.K (Just "\NUL") :*
    SOP.K (Just "\NUL") :* Nil
in runDecodeRow decode row4
:}
Right (L {fst = 1, snd = 'a'},R {thrd = False, frth = False})

runDecodeRow :: forall (row :: RowType) y. DecodeRow row y -> NP (K (Maybe ByteString) :: (Symbol, NullType) -> Type) row -> Either Text y #

Run a DecodeRow.

rowValue :: forall y (row :: RowType). (PG y ~ 'PGcomposite row, SListI row) => DecodeRow row y -> StateT ByteString (Except Text) y #

>>> :set -XTypeFamilies
>>> :{
data Complex = Complex
  { real :: Double
  , imaginary :: Double
  }
instance IsPG Complex where
  type PG Complex = 'PGcomposite '[
    "re" ::: 'NotNull 'PGfloat8,
    "im" ::: 'NotNull 'PGfloat8]
instance FromPG Complex where
  fromPG = rowValue $ do
    re <- #re
    im <- #im
    return Complex {real = re, imaginary = im}
:}

devalue :: Value x -> StateT ByteString (Except Text) x #

Converts a Value type from postgresql-binary for use in the fromPG method of FromPG.

class IsPG y => FromPG y where #

A FromPG constraint gives a parser from the binary format of a PostgreSQL PGType into a Haskell Type.

Methods

fromPG :: StateT ByteString (Except Text) y #

>>> :set -XMultiParamTypeClasses -XGeneralizedNewtypeDeriving -XDerivingStrategies -XDerivingVia -XUndecidableInstances
>>> import GHC.Generics as GHC
>>> :{
newtype UserId = UserId { getId :: Int64 }
  deriving newtype (IsPG, FromPG)
:}
>>> :{
data Complex = Complex
  { real :: Double
  , imaginary :: Double
  } deriving stock GHC.Generic
    deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
    deriving (IsPG, FromPG) via Composite Complex
:}
>>> :{
data Direction = North | South | East | West
  deriving stock GHC.Generic
  deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
  deriving (IsPG, FromPG) via Enumerated Direction
:}

Instances

Instances details
FromPG Bool 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Char 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Double 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Float 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Int16 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Int32 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Int64 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG ByteString 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG ByteString 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Scientific 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG String 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Text 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG UTCTime 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Value 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Text 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG UUID 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Day 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG DiffTime 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG TimeOfDay 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG LocalTime 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Oid 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG Money 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG (NetAddr IP) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG y => FromPG (Range y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromJSON x => FromPG (Json x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromJSON x => FromPG (Jsonb x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

(IsRecord y ys, AllZip FromField row ys, RowPG y ~ row) => FromPG (Composite y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

(IsEnumType y, HasDatatypeInfo y, LabelsPG y ~ labels) => FromPG (Enumerated y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

(FromArray ('[] :: [Nat]) ty y, ty ~ NullPG y) => FromPG (VarArray [y]) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

(FromArray ('[] :: [Nat]) ty y, ty ~ NullPG y) => FromPG (VarArray (Vector y)) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromArray dims ty y => FromPG (FixArray y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

KnownNat n => FromPG (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

KnownNat n => FromPG (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

FromPG (TimeOfDay, TimeZone) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

class FromValue (ty :: NullType) y where #

A FromValue constraint lifts the FromPG parser to a decoding of a NullityType to a Type, decoding Nulls to Maybes. You should not define instances for FromValue, just use the provided instances.

Instances

Instances details
(FromPG y, pg ~ PG y) => FromValue ('NotNull pg) y 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

(FromPG y, pg ~ PG y) => FromValue ('Null pg) (Maybe y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

class FromField (field :: (Symbol, NullType)) (y :: (Symbol, Type)) where #

A FromField constraint lifts the FromPG parser to a decoding of a (Symbol, NullityType) to a Type, decoding Nulls to Maybes. You should not define instances for FromField, just use the provided instances.

Instances

Instances details
(FromValue ty y, fld0 ~ fld1) => FromField (fld0 ::: ty) (fld1 ::: y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromField :: Maybe ByteString -> Either Text (P (fld1 ::: y)) #

class FromArray (dims :: [Nat]) (ty :: NullType) y where #

A FromArray constraint gives a decoding to a Haskell Type from the binary format of a PostgreSQL fixed-length array. You should not define instances for FromArray, just use the provided instances.

Methods

fromArray :: Array y #

Instances

Instances details
(FromPG y, pg ~ PG y) => FromArray ('[] :: [Nat]) ('NotNull pg) y 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromArray :: Array y #

(FromPG y, pg ~ PG y) => FromArray ('[] :: [Nat]) ('Null pg) (Maybe y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromArray :: Array (Maybe y) #

(IsProductType product ys, Length ys ~ dim, All (Type ~ y) ys, FromArray dims ty y) => FromArray (dim ': dims) ty product 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromArray :: Array product #

newtype DecodeRow (row :: RowType) y #

DecodeRow describes a decoding of a PostgreSQL RowType into a Haskell Type.

DecodeRow has an interface given by the classes Functor, Applicative, Alternative, Monad, MonadPlus, MonadError Text, and IsLabel.

>>> :set -XOverloadedLabels
>>> :{
let
  decode :: DecodeRow
    '[ "fst" ::: 'NotNull 'PGint2, "snd" ::: 'NotNull ('PGchar 1)]
    (Int16, Char)
  decode = (,) <$> #fst <*> #snd
in runDecodeRow decode (SOP.K (Just "\NUL\SOH") :* SOP.K (Just "a") :* Nil)
:}
Right (1,'a')

There is also an IsLabel instance for MaybeT DecodeRows, useful for decoding outer joined rows.

>>> :{
let
  decode :: DecodeRow
    '[ "fst" ::: 'Null 'PGint2, "snd" ::: 'Null ('PGchar 1)]
    (Maybe (Int16, Char))
  decode = runMaybeT $ (,) <$> #fst <*> #snd
in runDecodeRow decode (SOP.K (Just "\NUL\SOH") :* SOP.K (Just "a") :* Nil)
:}
Right (Just (1,'a'))

Constructors

DecodeRow 

Fields

Instances

Instances details
MonadError Text (DecodeRow row) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

throwError :: Text -> DecodeRow row a #

catchError :: DecodeRow row a -> (Text -> DecodeRow row a) -> DecodeRow row a #

FromValue ty (Maybe y) => IsLabel fld (MaybeT (DecodeRow ((fld ::: ty) ': row)) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: MaybeT (DecodeRow ((fld ::: ty) ': row)) y #

IsLabel fld (MaybeT (DecodeRow row) y) => IsLabel fld (MaybeT (DecodeRow (field ': row)) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: MaybeT (DecodeRow (field ': row)) y #

FromValue ty y => IsLabel fld (DecodeRow ((fld ::: ty) ': row) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: DecodeRow ((fld ::: ty) ': row) y #

IsLabel fld (DecodeRow row y) => IsLabel fld (DecodeRow (field ': row) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: DecodeRow (field ': row) y #

Monad (DecodeRow row) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

(>>=) :: DecodeRow row a -> (a -> DecodeRow row b) -> DecodeRow row b #

(>>) :: DecodeRow row a -> DecodeRow row b -> DecodeRow row b #

return :: a -> DecodeRow row a #

Functor (DecodeRow row) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fmap :: (a -> b) -> DecodeRow row a -> DecodeRow row b #

(<$) :: a -> DecodeRow row b -> DecodeRow row a #

MonadFail (DecodeRow row) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fail :: String -> DecodeRow row a #

Applicative (DecodeRow row) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

pure :: a -> DecodeRow row a #

(<*>) :: DecodeRow row (a -> b) -> DecodeRow row a -> DecodeRow row b #

liftA2 :: (a -> b -> c) -> DecodeRow row a -> DecodeRow row b -> DecodeRow row c #

(*>) :: DecodeRow row a -> DecodeRow row b -> DecodeRow row b #

(<*) :: DecodeRow row a -> DecodeRow row b -> DecodeRow row a #

Alternative (DecodeRow row) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

empty :: DecodeRow row a #

(<|>) :: DecodeRow row a -> DecodeRow row a -> DecodeRow row a #

some :: DecodeRow row a -> DecodeRow row [a] #

many :: DecodeRow row a -> DecodeRow row [a] #

MonadPlus (DecodeRow row) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

mzero :: DecodeRow row a #

mplus :: DecodeRow row a -> DecodeRow row a -> DecodeRow row a #

appendParams #

Arguments

:: forall (db :: SchemasType) (params0 :: [NullType]) x (params1 :: [NullType]). EncodeParams db params0 x

left

-> EncodeParams db params1 x

right

-> EncodeParams db (Join params0 params1) x 

Append parameter encodings.

>>> conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres"
>>> :{
let
  encode :: EncodeParams '[]
    '[ 'NotNull 'PGint4, 'NotNull 'PGint2]
    (Int32, Int16)
  encode = contramap fst aParam `appendParams` contramap snd aParam
in runReaderT (runEncodeParams encode (1776, 2)) conn
:}
K (Just "\NUL\NUL\ACK\240") :* K (Just "\NUL\STX") :* Nil
>>> finish conn

aParam :: forall (db :: SchemasType) x. ToParam db (NullPG x) x => EncodeParams db '[NullPG x] x #

Encode 1 parameter.

>>> conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres"
>>> :{
let
  encode :: EncodeParams '[] '[ 'NotNull 'PGint4] Int32
  encode = aParam
in runReaderT (runEncodeParams encode 1776) conn
:}
K (Just "\NUL\NUL\ACK\240") :* Nil
>>> finish conn

(*.) infixl 8 #

Arguments

:: forall (db :: SchemasType) x x0 (ty0 :: NullType) x1 (ty1 :: NullType). (ToParam db ty0 x0, ToParam db ty1 x1) 
=> (x -> x0)

second to last

-> (x -> x1)

last

-> EncodeParams db '[ty0, ty1] x 

End a parameter encoding.

>>> conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres"
>>> :{
let
  encode :: EncodeParams '[]
    '[ 'Null 'PGint4, 'NotNull 'PGtext, 'NotNull ('PGchar 1)]
    (Maybe Int32, String, Char)
  encode = (\(x,_,_) -> x) .* (\(_,y,_) -> y) *. (\(_,_,z) -> z)
in runReaderT (runEncodeParams encode (Nothing, "foo", 'z')) conn
:}
K Nothing :* K (Just "foo") :* K (Just "z") :* Nil
>>> finish conn

(.*) infixr 5 #

Arguments

:: forall (db :: SchemasType) x0 (ty :: NullType) x (tys :: [NullType]). ToParam db ty x0 
=> (x -> x0)

head

-> EncodeParams db tys x

tail

-> EncodeParams db (ty ': tys) x 

Cons a parameter encoding.

>>> conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres"
>>> :{
let
  encode :: EncodeParams '[]
    '[ 'Null 'PGint4, 'NotNull 'PGtext]
    (Maybe Int32, String)
  encode = fst .* snd .* nilParams
in runReaderT (runEncodeParams encode (Nothing, "foo")) conn
:}
K Nothing :* K (Just "foo") :* Nil
>>> finish conn

nilParams :: forall (db :: SchemasType) x. EncodeParams db ('[] :: [NullType]) x #

Encode 0 parameters.

genericParams :: forall (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]). (IsProductType x xs, AllZip (ToParam db) params xs) => EncodeParams db params x #

Parameter encoding for Generic tuples and records.

>>> import qualified GHC.Generics as GHC
>>> import qualified Generics.SOP as SOP
>>> data Two = Two Int16 String deriving (GHC.Generic, SOP.Generic)
>>> conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres"
>>> :{
let
  encode :: EncodeParams '[] '[ 'NotNull 'PGint2, 'NotNull 'PGtext] Two
  encode = genericParams
in runReaderT (runEncodeParams encode (Two 2 "two")) conn
:}
K (Just "\NUL\STX") :* K (Just "two") :* Nil
>>> :{
let
  encode :: EncodeParams '[] '[ 'NotNull 'PGint2, 'NotNull 'PGtext] (Int16, String)
  encode = genericParams
in runReaderT (runEncodeParams encode (2, "two")) conn
:}
K (Just "\NUL\STX") :* K (Just "two") :* Nil
>>> finish conn

class IsPG x => ToPG (db :: SchemasType) x where #

A ToPG constraint gives an encoding of a Haskell Type into into the binary format of a PostgreSQL PGType.

Methods

toPG :: x -> ReaderT (K Connection db) IO Encoding #

>>> :set -XTypeApplications -XDataKinds
>>> conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres"
>>> runReaderT (toPG @'[] False) conn
"\NUL"
>>> runReaderT (toPG @'[] (0 :: Int16)) conn
"\NUL\NUL"
>>> runReaderT (toPG @'[] (0 :: Int32)) conn
"\NUL\NUL\NUL\NUL"
>>> :set -XMultiParamTypeClasses -XGeneralizedNewtypeDeriving
>>> newtype UserId = UserId { getUserId :: Int64 } deriving newtype (IsPG, ToPG db)
>>> runReaderT (toPG @'[] (UserId 0)) conn
"\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL"
>>> finish conn

Instances

Instances details
ToPG db String 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db Value 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db UUID 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: UUID -> ReaderT (K Connection db) IO Encoding #

ToPG db UTCTime 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db TimeOfDay 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db Text 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Text -> ReaderT (K Connection db) IO Encoding #

ToPG db Text 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Text -> ReaderT (K Connection db) IO Encoding #

ToPG db Scientific 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db Oid 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Oid -> ReaderT (K Connection db) IO Encoding #

ToPG db Money 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db LocalTime 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db Int64 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db Int32 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db Int16 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db Float 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db Double 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db DiffTime 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db Day 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Day -> ReaderT (K Connection db) IO Encoding #

ToPG db Char 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Char -> ReaderT (K Connection db) IO Encoding #

ToPG db ByteString 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db ByteString 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db Bool 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Bool -> ReaderT (K Connection db) IO Encoding #

ToPG db (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: VarChar n -> ReaderT (K Connection db) IO Encoding #

(NullPG x ~ ty, ToArray db ('[] :: [Nat]) ty x, OidOfNull db ty) => ToPG db (VarArray [x]) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: VarArray [x] -> ReaderT (K Connection db) IO Encoding #

(NullPG x ~ ty, ToArray db ('[] :: [Nat]) ty x, OidOfNull db ty) => ToPG db (VarArray (Vector x)) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db x => ToPG db (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Range x -> ReaderT (K Connection db) IO Encoding #

ToPG db (NetAddr IP) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToJSON x => ToPG db (Jsonb x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Jsonb x -> ReaderT (K Connection db) IO Encoding #

ToJSON x => ToPG db (Json x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Json x -> ReaderT (K Connection db) IO Encoding #

ToPG db (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: FixChar n -> ReaderT (K Connection db) IO Encoding #

(ToArray db dims ty x, OidOfNull db ty) => ToPG db (FixArray x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

(IsEnumType x, HasDatatypeInfo x, LabelsPG x ~ labels) => ToPG db (Enumerated x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

(SListI fields, IsRecord x xs, AllZip (ToField db) fields xs, All (OidOfField db) fields, RowPG x ~ fields) => ToPG db (Composite x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

ToPG db (TimeOfDay, TimeZone) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

class ToParam (db :: SchemasType) (ty :: NullType) x where #

A ToParam constraint gives an encoding of a Haskell Type into into the binary format of a PostgreSQL NullType. You should not define instances for ToParam, just use the provided instances.

Methods

toParam :: x -> ReaderT (K Connection db) IO (Maybe Encoding) #

Instances

Instances details
(ToPG db x, pg ~ PG x) => ToParam db ('NotNull pg) x 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toParam :: x -> ReaderT (K Connection db) IO (Maybe Encoding) #

(ToPG db x, pg ~ PG x) => ToParam db ('Null pg) (Maybe x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

class ToField (db :: SchemasType) (field :: (Symbol, NullType)) (x :: (Symbol, Type)) where #

A ToField constraint lifts the ToPG parser to an encoding of a (Symbol, Type) to a (Symbol, NullityType), encoding Nulls to Maybes. You should not define instances for ToField, just use the provided instances.

Methods

toField :: P x -> ReaderT (K Connection db) IO (K (Maybe Encoding) field) #

Instances

Instances details
(fld0 ~ fld1, ToParam db ty x) => ToField db (fld0 ::: ty) (fld1 ::: x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toField :: P (fld1 ::: x) -> ReaderT (K Connection db) IO (K (Maybe Encoding) (fld0 ::: ty)) #

class ToArray (db :: SchemasType) (dims :: [Nat]) (ty :: NullType) x where #

A ToArray constraint gives an encoding of a Haskell Type into the binary format of a PostgreSQL fixed-length array. You should not define instances for ToArray, just use the provided instances.

Instances

Instances details
(ToPG db x, pg ~ PG x) => ToArray db ('[] :: [Nat]) ('NotNull pg) x 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

(ToPG db x, pg ~ PG x) => ToArray db ('[] :: [Nat]) ('Null pg) (Maybe x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

(IsProductType tuple xs, Length xs ~ dim, All (Type ~ x) xs, ToArray db dims ty x, KnownNat dim) => ToArray db (dim ': dims) ty tuple 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

newtype EncodeParams (db :: SchemasType) (tys :: [NullType]) x #

EncodeParams describes an encoding of a Haskell Type into a list of parameter NullTypes.

>>> conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres"
>>> :{
let
  encode :: EncodeParams '[]
    '[ 'NotNull 'PGint2, 'NotNull ('PGchar 1), 'NotNull 'PGtext]
    (Int16, (Char, String))
  encode = fst .* fst.snd *. snd.snd
in runReaderT (runEncodeParams encode (1,('a',"foo"))) conn
:}
K (Just "\NUL\SOH") :* K (Just "a") :* K (Just "foo") :* Nil
>>> finish conn

Constructors

EncodeParams 

Fields

Instances

Instances details
Contravariant (EncodeParams db tys) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

contramap :: (a -> b) -> EncodeParams db tys b -> EncodeParams db tys a #

(>$) :: b -> EncodeParams db tys b -> EncodeParams db tys a #

rangeMerge :: forall (null :: PGType -> NullType) (ty :: PGType). '[null ('PGrange ty), null ('PGrange ty)] ---> null ('PGrange ty) #

the smallest range which includes both of the given ranges

upperInf :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool #

is the upper bound infinite?

upperInc :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool #

is the upper bound inclusive?

lowerInf :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool #

is the lower bound infinite?

lowerInc :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool #

is the lower bound inclusive?

isEmpty :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool #

is the range empty?

upperBound :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null ty #

upper bound of range

lowerBound :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null ty #

lower bound of range

(@-) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty)) #

difference, will fail if the resulting range would need to contain two disjoint sub-ranges

(@*) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty)) #

intersection

(@+) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty)) #

union, will fail if the resulting range would need to contain two disjoint sub-ranges

(-|-) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool) #

is adjacent to, return false when an empty range is involved

(&>) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool) #

does not extend to the left of, return false when an empty range is involved

(&<) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool) #

does not extend to the right of, return false when an empty range is involved

(@>>) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool) #

strictly right of, return false when an empty range is involved

(<<@) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool) #

strictly left of, return false when an empty range is involved

(@>.) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) ('NotNull ty) ('Null 'PGbool) #

contains range

(.<@) :: forall (ty :: PGType) (null :: PGType -> NullType). Operator ('NotNull ty) (null ('PGrange ty)) ('Null 'PGbool) #

range is contained by

whole :: Range x #

The whole line

singleton :: x -> Range x #

A point on the line

atMost :: x -> Range x #

Half-infinite Range constructor

lessThan :: x -> Range x #

Half-infinite Range constructor

atLeast :: x -> Range x #

Half-infinite Range constructor

moreThan :: x -> Range x #

Half-infinite Range constructor

(<..<=) :: x -> x -> Range x infix 4 #

Finite Range constructor

(<=..<) :: x -> x -> Range x infix 4 #

Finite Range constructor

(<..<) :: x -> x -> Range x infix 4 #

Finite Range constructor

(<=..<=) :: x -> x -> Range x infix 4 #

Finite Range constructor

range #

Arguments

:: forall (db :: SchemasType) (null :: PGType -> NullType) (ty :: PGType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). TypeExpression db (null ('PGrange ty))

range type

-> Range (Expression grp lat with db params from ('NotNull ty))

range of values

-> Expression grp lat with db params from (null ('PGrange ty)) 

Construct a range

>>> printSQL $ range tstzrange (atLeast now)
tstzrange(now(), NULL, '[)')
>>> printSQL $ range numrange (0 <=..< 2*pi)
numrange((0.0 :: numeric), ((2.0 :: numeric) * pi()), '[)')
>>> printSQL $ range int4range Empty
('empty' :: int4range)

data Bound x #

The type of Bound for a Range.

Constructors

Infinite

unbounded

Closed x

inclusive

Open x

exclusive

Instances

Instances details
Functor Bound 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

fmap :: (a -> b) -> Bound a -> Bound b #

(<$) :: a -> Bound b -> Bound a #

Foldable Bound 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

fold :: Monoid m => Bound m -> m #

foldMap :: Monoid m => (a -> m) -> Bound a -> m #

foldMap' :: Monoid m => (a -> m) -> Bound a -> m #

foldr :: (a -> b -> b) -> b -> Bound a -> b #

foldr' :: (a -> b -> b) -> b -> Bound a -> b #

foldl :: (b -> a -> b) -> b -> Bound a -> b #

foldl' :: (b -> a -> b) -> b -> Bound a -> b #

foldr1 :: (a -> a -> a) -> Bound a -> a #

foldl1 :: (a -> a -> a) -> Bound a -> a #

toList :: Bound a -> [a] #

null :: Bound a -> Bool #

length :: Bound a -> Int #

elem :: Eq a => a -> Bound a -> Bool #

maximum :: Ord a => Bound a -> a #

minimum :: Ord a => Bound a -> a #

sum :: Num a => Bound a -> a #

product :: Num a => Bound a -> a #

Traversable Bound 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

traverse :: Applicative f => (a -> f b) -> Bound a -> f (Bound b) #

sequenceA :: Applicative f => Bound (f a) -> f (Bound a) #

mapM :: Monad m => (a -> m b) -> Bound a -> m (Bound b) #

sequence :: Monad m => Bound (m a) -> m (Bound a) #

Eq x => Eq (Bound x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

(==) :: Bound x -> Bound x -> Bool #

(/=) :: Bound x -> Bound x -> Bool #

Ord x => Ord (Bound x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

compare :: Bound x -> Bound x -> Ordering #

(<) :: Bound x -> Bound x -> Bool #

(<=) :: Bound x -> Bound x -> Bool #

(>) :: Bound x -> Bound x -> Bool #

(>=) :: Bound x -> Bound x -> Bool #

max :: Bound x -> Bound x -> Bound x #

min :: Bound x -> Bound x -> Bound x #

Read x => Read (Bound x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Show x => Show (Bound x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

showsPrec :: Int -> Bound x -> ShowS #

show :: Bound x -> String #

showList :: [Bound x] -> ShowS #

Generic (Bound x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Associated Types

type Rep (Bound x) :: Type -> Type #

Methods

from :: Bound x -> Rep (Bound x) x0 #

to :: Rep (Bound x) x0 -> Bound x #

type Rep (Bound x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

type Rep (Bound x) = D1 ('MetaData "Bound" "Squeal.PostgreSQL.Expression.Range" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) (C1 ('MetaCons "Infinite" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Closed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 x)) :+: C1 ('MetaCons "Open" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 x))))

data Range x #

A Range datatype that comprises connected subsets of the real line.

Constructors

Empty 
NonEmpty (Bound x) (Bound x) 

Instances

Instances details
Functor Range 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

fmap :: (a -> b) -> Range a -> Range b #

(<$) :: a -> Range b -> Range a #

Foldable Range 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

fold :: Monoid m => Range m -> m #

foldMap :: Monoid m => (a -> m) -> Range a -> m #

foldMap' :: Monoid m => (a -> m) -> Range a -> m #

foldr :: (a -> b -> b) -> b -> Range a -> b #

foldr' :: (a -> b -> b) -> b -> Range a -> b #

foldl :: (b -> a -> b) -> b -> Range a -> b #

foldl' :: (b -> a -> b) -> b -> Range a -> b #

foldr1 :: (a -> a -> a) -> Range a -> a #

foldl1 :: (a -> a -> a) -> Range a -> a #

toList :: Range a -> [a] #

null :: Range a -> Bool #

length :: Range a -> Int #

elem :: Eq a => a -> Range a -> Bool #

maximum :: Ord a => Range a -> a #

minimum :: Ord a => Range a -> a #

sum :: Num a => Range a -> a #

product :: Num a => Range a -> a #

Traversable Range 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

traverse :: Applicative f => (a -> f b) -> Range a -> f (Range b) #

sequenceA :: Applicative f => Range (f a) -> f (Range a) #

mapM :: Monad m => (a -> m b) -> Range a -> m (Range b) #

sequence :: Monad m => Range (m a) -> m (Range a) #

ToPG db x => ToPG db (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Range x -> ReaderT (K Connection db) IO Encoding #

Eq x => Eq (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

(==) :: Range x -> Range x -> Bool #

(/=) :: Range x -> Range x -> Bool #

Ord x => Ord (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

compare :: Range x -> Range x -> Ordering #

(<) :: Range x -> Range x -> Bool #

(<=) :: Range x -> Range x -> Bool #

(>) :: Range x -> Range x -> Bool #

(>=) :: Range x -> Range x -> Bool #

max :: Range x -> Range x -> Range x #

min :: Range x -> Range x -> Range x #

Read x => Read (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Show x => Show (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Methods

showsPrec :: Int -> Range x -> ShowS #

show :: Range x -> String #

showList :: [Range x] -> ShowS #

Generic (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Associated Types

type Rep (Range x) :: Type -> Type #

Methods

from :: Range x -> Rep (Range x) x0 #

to :: Rep (Range x) x0 -> Range x #

Generic (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Associated Types

type Code (Range x) :: [[Type]] #

Methods

from :: Range x -> Rep (Range x) #

to :: Rep (Range x) -> Range x #

HasDatatypeInfo (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Associated Types

type DatatypeInfoOf (Range x) :: DatatypeInfo #

Methods

datatypeInfo :: proxy (Range x) -> DatatypeInfo (Code (Range x)) #

Inline (Range Int32) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range Int32 -> Expr (null (PG (Range Int32))) #

Inline (Range Int64) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range Int64 -> Expr (null (PG (Range Int64))) #

Inline (Range Scientific) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range Scientific -> Expr (null (PG (Range Scientific))) #

Inline (Range UTCTime) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range UTCTime -> Expr (null (PG (Range UTCTime))) #

Inline (Range Day) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range Day -> Expr (null (PG (Range Day))) #

Inline (Range LocalTime) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Range LocalTime -> Expr (null (PG (Range LocalTime))) #

FromPG y => FromPG (Range y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG hask => IsPG (Range hask)

PGrange (PG hask)

Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Associated Types

type PG (Range hask) :: PGType #

type Rep (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

type Rep (Range x) = D1 ('MetaData "Range" "Squeal.PostgreSQL.Expression.Range" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) (C1 ('MetaCons "Empty" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NonEmpty" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Bound x)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Bound x))))
type Code (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

type Code (Range x) = GCode (Range x)
type DatatypeInfoOf (Range x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

type PG (Range hask) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

type PG (Range hask) = 'PGrange (PG hask)

data SortExpression (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) where #

SortExpressions are used by orderBy to optionally sort the results of a Query. Asc or Desc set the sort direction of a NotNull result column to ascending or descending. Ascending order puts smaller values first, where "smaller" is defined in terms of the .< operator. Similarly, descending order is determined with the .> operator. AscNullsFirst, AscNullsLast, DescNullsFirst and DescNullsLast options are used to determine whether nulls appear before or after non-null values in the sort ordering of a Null result column.

Constructors

Asc 

Fields

Desc 

Fields

AscNullsFirst 

Fields

AscNullsLast 

Fields

DescNullsFirst 

Fields

DescNullsLast 

Fields

Instances

Instances details
RenderSQL [SortExpression grp lat with db params from] 
Instance details

Defined in Squeal.PostgreSQL.Expression.Sort

Methods

renderSQL :: [SortExpression grp lat with db params from] -> ByteString #

Show (SortExpression grp lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Sort

Methods

showsPrec :: Int -> SortExpression grp lat with db params from -> ShowS #

show :: SortExpression grp lat with db params from -> String #

showList :: [SortExpression grp lat with db params from] -> ShowS #

RenderSQL (SortExpression grp lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Sort

Methods

renderSQL :: SortExpression grp lat with db params from -> ByteString #

class OrderBy (expr :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (grp :: Grouping) | expr -> grp where #

The orderBy clause causes the result rows of a TableExpression to be sorted according to the specified SortExpression(s). If two rows are equal according to the leftmost expression, they are compared according to the next expression and so on. If they are equal according to all specified expressions, they are returned in an implementation-dependent order.

You can also control the order in which rows are processed by window functions using orderBy within Over.

Methods

orderBy #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from]

sorts

-> expr lat with db params from 
-> expr lat with db params from 

Instances

Instances details
OrderBy (WindowDefinition grp) grp 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from] -> WindowDefinition grp lat with db params from -> WindowDefinition grp lat with db params from #

OrderBy (AggregateArg xs) 'Ungrouped 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression 'Ungrouped lat with db params from] -> AggregateArg xs lat with db params from -> AggregateArg xs lat with db params from #

OrderBy (TableExpression grp) grp 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from] -> TableExpression grp lat with db params from -> TableExpression grp lat with db params from #

ilike :: forall (null :: PGType -> NullType). Operator (null 'PGtext) (null 'PGtext) ('Null 'PGbool) #

The key word ILIKE can be used instead of LIKE to make the match case-insensitive according to the active locale.

>>> printSQL $ "abc" `ilike` "a%"
((E'abc' :: text) ILIKE (E'a%' :: text))

like :: forall (null :: PGType -> NullType). Operator (null 'PGtext) (null 'PGtext) ('Null 'PGbool) #

The like expression returns true if the string matches the supplied pattern. If pattern does not contain percent signs or underscores, then the pattern only represents the string itself; in that case like acts like the equals operator. An underscore (_) in pattern stands for (matches) any single character; a percent sign (%) matches any sequence of zero or more characters.

>>> printSQL $ "abc" `like` "a%"
((E'abc' :: text) LIKE (E'a%' :: text))

charLength :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGint4 #

>>> printSQL $ charLength "four"
char_length((E'four' :: text))

upper :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtext #

>>> printSQL $ upper "eeee"
upper((E'eeee' :: text))

lower :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtext #

>>> printSQL $ lower "ARRRGGG"
lower((E'ARRRGGG' :: text))

tsHeadline :: forall (document :: PGType) (null :: PGType -> NullType). In document '['PGtext, 'PGjson, 'PGjsonb] => '[null document, null 'PGtsquery] ---> null 'PGtext #

display a tsquery match

tsFilter :: forall (null :: PGType -> NullType). '[null 'PGtsvector, null ('PGvararray ('NotNull ('PGchar 1)))] ---> null 'PGtsvector #

select only elements with given weights from tsvector

tsDelete :: forall (null :: PGType -> NullType). '[null 'PGtsvector, null ('PGvararray ('NotNull 'PGtext))] ---> null 'PGtsvector #

remove given lexeme from tsvector

jsonbToTSvector :: forall (null :: PGType -> NullType). '[null 'PGjsonb, null 'PGjsonb] ---> null 'PGtsvector #

jsonbToTSvector (document *: filter) reduce each value in the document, specified by filter to a tsvector, and then concatenate those in document order to produce a single tsvector. filter is a jsonb array, that enumerates what kind of elements need to be included into the resulting tsvector. Possible values for filter are "string" (to include all string values), "numeric" (to include all numeric values in the string format), "boolean" (to include all Boolean values in the string format "true"/"false"), "key" (to include all keys) or "all" (to include all above). These values can be combined together to include, e.g. all string and numeric values.

jsonToTSvector :: forall (null :: PGType -> NullType). '[null 'PGjson, null 'PGjson] ---> null 'PGtsvector #

jsonToTSvector (document *: filter) reduce each value in the document, specified by filter to a tsvector, and then concatenate those in document order to produce a single tsvector. filter is a json array, that enumerates what kind of elements need to be included into the resulting tsvector. Possible values for filter are "string" (to include all string values), "numeric" (to include all numeric values in the string format), "boolean" (to include all Boolean values in the string format "true"/"false"), "key" (to include all keys) or "all" (to include all above). These values can be combined together to include, e.g. all string and numeric values.

strip :: forall (null :: PGType -> NullType). null 'PGtsvector --> null 'PGtsvector #

remove positions and weights from tsvector

setWeight :: forall (null :: PGType -> NullType). '[null 'PGtsvector, null ('PGchar 1)] ---> null 'PGtsvector #

assign weight to each element of tsvector

toTSvector :: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGtext, 'PGjson, 'PGjsonb] => null ty --> null 'PGtsvector #

reduce document text to tsvector

toTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery #

normalize words and convert to tsquery

queryTree :: forall (null :: PGType -> NullType). null 'PGtsquery --> null 'PGtext #

get indexable part of a tsquery

websearchToTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery #

produce tsquery from a web search style query

phraseToTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery #

produce tsquery that searches for a phrase, ignoring punctuation

plainToTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery #

produce tsquery ignoring punctuation

numnode :: forall (null :: PGType -> NullType). null 'PGtsquery --> null 'PGint4 #

number of lexemes plus operators in tsquery

tsvectorLength :: forall (null :: PGType -> NullType). null 'PGtsvector --> null 'PGint4 #

number of lexemes in tsvector

arrayToTSvector :: forall (null :: PGType -> NullType). null ('PGvararray ('NotNull 'PGtext)) --> null 'PGtsvector #

convert array of lexemes to tsvector

(<->) :: forall (null :: PGType -> NullType). Operator (null 'PGtsquery) (null 'PGtsquery) (null 'PGtsquery) #

tsquery followed by tsquery

(.!) :: forall (null :: PGType -> NullType). null 'PGtsquery --> null 'PGtsquery #

negate a tsquery

(.|) :: forall (null :: PGType -> NullType). Operator (null 'PGtsquery) (null 'PGtsquery) (null 'PGtsquery) #

OR tsquerys together

(.&) :: forall (null :: PGType -> NullType). Operator (null 'PGtsquery) (null 'PGtsquery) (null 'PGtsquery) #

AND tsquerys together

(@@) :: forall (null :: PGType -> NullType). Operator (null 'PGtsvector) (null 'PGtsquery) ('Null 'PGbool) #

tsvector matches tsquery ?

interval_ :: forall (null :: PGType -> NullType). Milli -> TimeUnit -> Expr (null 'PGinterval) #

>>> printSQL $ interval_ 7 Days
(INTERVAL '7.000 days')

makeTimestamptz :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGfloat8] ---> null 'PGtimestamptz #

Create timestamp with time zone from year, month, day, hour, minute and seconds fields; the current time zone is used

>>> printSQL (makeTimestamptz (2013 :* 7 :* 15 :* 8 :* 15 *: 23.5))
make_timestamptz((2013 :: int4), (7 :: int4), (15 :: int4), (8 :: int4), (15 :: int4), (23.5 :: float8))

makeTimestamp :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGfloat8] ---> null 'PGtimestamp #

Create timestamp from year, month, day, hour, minute and seconds fields

>>> printSQL (makeTimestamp (2013 :* 7 :* 15 :* 8 :* 15 *: 23.5))
make_timestamp((2013 :: int4), (7 :: int4), (15 :: int4), (8 :: int4), (15 :: int4), (23.5 :: float8))

makeTime :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGfloat8] ---> null 'PGtime #

Create time from hour, minute and seconds fields

>>> printSQL (makeTime (8 :* 15 *: 23.5))
make_time((8 :: int4), (15 :: int4), (23.5 :: float8))

makeDate :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGint4] ---> null 'PGdate #

Create date from year, month and day fields

>>> printSQL (makeDate (1984 :* 7 *: 3))
make_date((1984 :: int4), (7 :: int4), (3 :: int4))

now :: forall (null :: PGType -> NullType). Expr (null 'PGtimestamptz) #

Current date and time (equivalent to currentTimestamp)

>>> printSQL now
now()

localTimestamp :: forall (null :: PGType -> NullType). Expr (null 'PGtimestamp) #

>>> printSQL localTimestamp
LOCALTIMESTAMP

localTime :: forall (null :: PGType -> NullType). Expr (null 'PGtime) #

>>> printSQL localTime
LOCALTIME

currentTimestamp :: forall (null :: PGType -> NullType). Expr (null 'PGtimestamptz) #

>>> printSQL currentTimestamp
CURRENT_TIMESTAMP

currentTime :: forall (null :: PGType -> NullType). Expr (null 'PGtimetz) #

>>> printSQL currentTime
CURRENT_TIME

currentDate :: forall (null :: PGType -> NullType). Expr (null 'PGdate) #

>>> printSQL currentDate
CURRENT_DATE

class TimeOp (time :: k) (diff :: k) | time -> diff where #

Affine space operations on time types.

Minimal complete definition

Nothing

Methods

(!+) :: forall (null :: k -> NullType). Operator (null time) (null diff) (null time) infixl 6 #

>>> printSQL (makeDate (1984 :* 7 *: 3) !+ 365)
(make_date((1984 :: int4), (7 :: int4), (3 :: int4)) + (365 :: int4))

(+!) :: forall (null :: k -> NullType). Operator (null diff) (null time) (null time) infixl 6 #

>>> printSQL (365 +! makeDate (1984 :* 7 *: 3))
((365 :: int4) + make_date((1984 :: int4), (7 :: int4), (3 :: int4)))

(!-) :: forall (null :: k -> NullType). Operator (null time) (null diff) (null time) infixl 6 #

>>> printSQL (makeDate (1984 :* 7 *: 3) !- 365)
(make_date((1984 :: int4), (7 :: int4), (3 :: int4)) - (365 :: int4))

(!-!) :: forall (null :: k -> NullType). Operator (null time) (null time) (null diff) infixl 6 #

>>> printSQL (makeDate (1984 :* 7 *: 3) !-! currentDate)
(make_date((1984 :: int4), (7 :: int4), (3 :: int4)) - CURRENT_DATE)

Instances

Instances details
TimeOp 'PGinterval 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGinterval) (null 'PGinterval) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGinterval) (null 'PGinterval) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGinterval) (null 'PGinterval) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGinterval) (null 'PGinterval) #

TimeOp 'PGtimetz 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGtimetz) (null 'PGinterval) (null 'PGtimetz) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGtimetz) (null 'PGtimetz) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGtimetz) (null 'PGinterval) (null 'PGtimetz) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGtimetz) (null 'PGtimetz) (null 'PGinterval) #

TimeOp 'PGtime 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGtime) (null 'PGinterval) (null 'PGtime) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGtime) (null 'PGtime) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGtime) (null 'PGinterval) (null 'PGtime) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGtime) (null 'PGtime) (null 'PGinterval) #

TimeOp 'PGdate 'PGint4 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGdate) (null 'PGint4) (null 'PGdate) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGint4) (null 'PGdate) (null 'PGdate) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGdate) (null 'PGint4) (null 'PGdate) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGdate) (null 'PGdate) (null 'PGint4) #

TimeOp 'PGtimestamptz 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGtimestamptz) (null 'PGinterval) (null 'PGtimestamptz) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGtimestamptz) (null 'PGtimestamptz) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGtimestamptz) (null 'PGinterval) (null 'PGtimestamptz) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGtimestamptz) (null 'PGtimestamptz) (null 'PGinterval) #

TimeOp 'PGtimestamp 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGtimestamp) (null 'PGinterval) (null 'PGtimestamp) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGtimestamp) (null 'PGtimestamp) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGtimestamp) (null 'PGinterval) (null 'PGtimestamp) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGtimestamp) (null 'PGtimestamp) (null 'PGinterval) #

data TimeUnit #

A TimeUnit to use in interval_ construction.

Instances

Instances details
Enum TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Eq TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Ord TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Read TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Show TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Generic TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Associated Types

type Rep TimeUnit :: Type -> Type #

Methods

from :: TimeUnit -> Rep TimeUnit x #

to :: Rep TimeUnit x -> TimeUnit #

Generic TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Associated Types

type Code TimeUnit :: [[Type]] #

HasDatatypeInfo TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Associated Types

type DatatypeInfoOf TimeUnit :: DatatypeInfo #

RenderSQL TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

type Rep TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

type Rep TimeUnit = D1 ('MetaData "TimeUnit" "Squeal.PostgreSQL.Expression.Time" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) (((C1 ('MetaCons "Years" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Months" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Weeks" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Days" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Hours" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Minutes" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "Seconds" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Microseconds" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Milliseconds" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Decades" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Centuries" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Millennia" 'PrefixI 'False) (U1 :: Type -> Type)))))
type Code TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

type DatatypeInfoOf TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

columntypeFrom :: forall hask (db :: SchemasType). ColumnTyped db ('NoDef :=> NullPG hask) => ColumnTypeExpression db ('NoDef :=> NullPG hask) #

Specify ColumnTypeExpression from a Haskell type.

>>> printSQL $ columntypeFrom @(Maybe String)
text NULL
>>> printSQL $ columntypeFrom @Double
float8 NOT NULL

nulltypeFrom :: forall hask (db :: SchemasType). NullTyped db (NullPG hask) => TypeExpression db (NullPG hask) #

Specify null TypeExpression from a Haskell type.

>>> printSQL $ nulltypeFrom @(Maybe String)
text
>>> printSQL $ nulltypeFrom @Double
float8

bigserial :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint8) #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint8

serial8 :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint8) #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint8

serial :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint4) #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint4

serial4 :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint4) #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint4

smallserial :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint2) #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint2

serial2 :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint2) #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint2

default_ #

Arguments

:: forall (db :: SchemasType) (ty :: NullType). Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) ('[] :: [(Symbol, RowType)]) ty

default value

-> ColumnTypeExpression db ('NoDef :=> ty)

column type

-> ColumnTypeExpression db ('Def :=> ty) 

used in createTable commands as a column constraint to give a default

notNullable #

Arguments

:: forall (db :: SchemasType) (null :: PGType -> NullType) (ty :: PGType). TypeExpression db (null ty)

type

-> ColumnTypeExpression db ('NoDef :=> 'NotNull ty) 

used in createTable commands as a column constraint to ensure NULL is not present in a column

nullable #

Arguments

:: forall (db :: SchemasType) (null :: PGType -> NullType) (ty :: PGType). TypeExpression db (null ty)

type

-> ColumnTypeExpression db ('NoDef :=> 'Null ty) 

used in createTable commands as a column constraint to note that NULL may be present in a column

pgtypeFrom :: forall hask (db :: SchemasType) (null :: PGType -> NullType). PGTyped db (PG hask) => TypeExpression db (null (PG hask)) #

Specify TypeExpression from a Haskell type.

>>> printSQL $ pgtypeFrom @String
text
>>> printSQL $ pgtypeFrom @Double
float8

record :: forall (db :: SchemasType) (null :: PGType -> NullType) (record :: RowType). TypeExpression db (null ('PGcomposite record)) #

Anonymous composite record

daterange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGdate)) #

Range of date

tstzrange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGtimestamptz)) #

Range of timestamp with time zone

tsrange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGtimestamp)) #

Range of timestamp without time zone

numrange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGnumeric)) #

Range of numeric

int8range :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGint8)) #

Range of bigint

int4range :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGint4)) #

Range of integer

oid :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGoid) #

Object identifiers (OIDs) are used internally by PostgreSQL as primary keys for various system tables.

tsquery :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtsquery) #

text search document

tsvector :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtsvector) #

text search query

fixarray :: forall (dims :: [Nat]) (db :: SchemasType) (null :: PGType -> NullType) (pg :: NullType). All KnownNat dims => TypeExpression db pg -> TypeExpression db (null ('PGfixarray dims pg)) #

fixed length array

>>> renderSQL (fixarray @'[2] json)
"json[2]"

vararray :: forall (db :: SchemasType) (pg :: NullType) (null :: PGType -> NullType). TypeExpression db pg -> TypeExpression db (null ('PGvararray pg)) #

variable length array

jsonb :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGjsonb) #

binary JSON data, decomposed

json :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGjson) #

textual JSON data

inet :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGinet) #

IPv4 or IPv6 host address

uuid :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGuuid) #

universally unique identifier

interval :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGinterval) #

time span

timetz :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimetz) #

time of day, including time zone

timeWithTimeZone :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimetz) #

time of day, including time zone

time :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtime) #

time of day (no time zone)

date :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGdate) #

calendar date (year, month, day)

timestamptz :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamptz) #

date and time, including time zone

timestampWithTimeZone :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamptz) #

date and time, including time zone

timestamp :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamp) #

date and time (no time zone)

bytea :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGbytea) #

binary data ("byte array")

characterVarying :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGvarchar n)) #

variable-length character string

varchar :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGvarchar n)) #

variable-length character string

character :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGchar n)) #

fixed-length character string

char :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGchar n)) #

fixed-length character string

text :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtext) #

variable-length character string

money :: forall (schema :: SchemasType) (null :: PGType -> NullType). TypeExpression schema (null 'PGmoney) #

currency amount

doublePrecision :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat8) #

double precision floating-point number (8 bytes)

float8 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat8) #

double precision floating-point number (8 bytes)

real :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat4) #

single precision floating-point number (4 bytes)

float4 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat4) #

single precision floating-point number (4 bytes)

numeric :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGnumeric) #

arbitrary precision numeric type

bigint :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint8) #

signed eight-byte integer

int8 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint8) #

signed eight-byte integer

integer :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint4) #

signed four-byte integer

int :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint4) #

signed four-byte integer

int4 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint4) #

signed four-byte integer

smallint :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint2) #

signed two-byte integer

int2 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint2) #

signed two-byte integer

bool :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGbool) #

logical Boolean (true/false)

typeview #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (vw :: Symbol) (view :: RowType) (null :: PGType -> NullType). (Has sch db schema, Has vw schema ('View view)) 
=> QualifiedAlias sch vw

view alias

-> TypeExpression db (null ('PGcomposite view)) 

The composite type corresponding to a View definition can be expressed by its alias.

typetable #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (null :: PGType -> NullType). (Has sch db schema, Has tab schema ('Table table)) 
=> QualifiedAlias sch tab

table alias

-> TypeExpression db (null ('PGcomposite (TableToRow table))) 

The composite type corresponding to a Table definition can be expressed by its alias.

typedef #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (td :: Symbol) (ty :: PGType) (null :: PGType -> NullType). (Has sch db schema, Has td schema ('Typedef ty)) 
=> QualifiedAlias sch td

type alias

-> TypeExpression db (null ty) 

The enum or composite type in a Typedef can be expressed by its alias.

inferredtype #

Arguments

:: forall (db :: SchemasType) (ty :: NullType) (lat :: Grouping) (common :: FromType) (grp :: FromType) (params :: [NullType]) (from :: FromType). NullTyped db ty 
=> Expression lat common grp db params from ty

value

-> Expression lat common grp db params from ty 

inferredtype will add a type annotation to an Expression which can be useful for fixing the storage type of a value.

>>> printSQL (inferredtype true)
(TRUE :: bool)

astype #

Arguments

:: forall (db :: SchemasType) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). TypeExpression db ty

type to specify as

-> Expression grp lat with db params from ty

value

-> Expression grp lat with db params from ty 

A safe version of cast which just matches a value with its type.

>>> printSQL (1 & astype int)
((1 :: int4) :: int)

cast #

Arguments

:: forall (db :: SchemasType) (ty1 :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType) (ty0 :: NullType). TypeExpression db ty1

type to cast as

-> Expression grp lat with db params from ty0

value to convert

-> Expression grp lat with db params from ty1 
>>> printSQL $ true & cast int4
(TRUE :: int4)

newtype TypeExpression (db :: SchemasType) (ty :: NullType) #

TypeExpressions are used in casts and createTable commands.

Instances

Instances details
Eq (TypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

(==) :: TypeExpression db ty -> TypeExpression db ty -> Bool #

(/=) :: TypeExpression db ty -> TypeExpression db ty -> Bool #

Ord (TypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

compare :: TypeExpression db ty -> TypeExpression db ty -> Ordering #

(<) :: TypeExpression db ty -> TypeExpression db ty -> Bool #

(<=) :: TypeExpression db ty -> TypeExpression db ty -> Bool #

(>) :: TypeExpression db ty -> TypeExpression db ty -> Bool #

(>=) :: TypeExpression db ty -> TypeExpression db ty -> Bool #

max :: TypeExpression db ty -> TypeExpression db ty -> TypeExpression db ty #

min :: TypeExpression db ty -> TypeExpression db ty -> TypeExpression db ty #

Show (TypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

showsPrec :: Int -> TypeExpression db ty -> ShowS #

show :: TypeExpression db ty -> String #

showList :: [TypeExpression db ty] -> ShowS #

Generic (TypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Associated Types

type Rep (TypeExpression db ty) :: Type -> Type #

Methods

from :: TypeExpression db ty -> Rep (TypeExpression db ty) x #

to :: Rep (TypeExpression db ty) x -> TypeExpression db ty #

NFData (TypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

rnf :: TypeExpression db ty -> () #

RenderSQL (TypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

type Rep (TypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

type Rep (TypeExpression db ty) = D1 ('MetaData "TypeExpression" "Squeal.PostgreSQL.Expression.Type" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeTypeExpression" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderTypeExpression") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

class PGTyped (db :: SchemasType) (ty :: PGType) where #

pgtype is a demoted version of a PGType

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ty) #

Instances

Instances details
PGTyped db 'PGuuid 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGuuid) #

PGTyped db 'PGtsvector 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGtsvector) #

PGTyped db 'PGtsquery 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGtsquery) #

PGTyped db 'PGtimetz 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGtimetz) #

PGTyped db 'PGtimestamptz 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamptz) #

PGTyped db 'PGtimestamp 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamp) #

PGTyped db 'PGtime 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGtime) #

PGTyped db 'PGtext 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGtext) #

PGTyped db 'PGoid 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGoid) #

PGTyped db 'PGnumeric 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGnumeric) #

PGTyped db 'PGmoney 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGmoney) #

PGTyped db 'PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGjsonb) #

PGTyped db 'PGjson 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGjson) #

PGTyped db 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGinterval) #

PGTyped db 'PGint8 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGint8) #

PGTyped db 'PGint4 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGint4) #

PGTyped db 'PGint2 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGint2) #

PGTyped db 'PGinet 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGinet) #

PGTyped db 'PGfloat8 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGfloat8) #

PGTyped db 'PGfloat4 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGfloat4) #

PGTyped db 'PGdate 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGdate) #

PGTyped db 'PGbytea 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGbytea) #

PGTyped db 'PGbool 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null 'PGbool) #

(KnownNat n, 1 <= n) => PGTyped db ('PGvarchar n) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ('PGvarchar n)) #

PGTyped db pg => PGTyped db ('PGvararray (null pg)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null0 :: PGType -> NullType). TypeExpression db (null0 ('PGvararray (null pg))) #

PGTyped db ('PGrange 'PGint4) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGint4)) #

PGTyped db ('PGrange 'PGint8) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGint8)) #

PGTyped db ('PGrange 'PGnumeric) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGnumeric)) #

PGTyped db ('PGrange 'PGtimestamp) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGtimestamp)) #

PGTyped db ('PGrange 'PGtimestamptz) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGtimestamptz)) #

PGTyped db ('PGrange 'PGdate) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGdate)) #

(UserType db ('PGenum labels) ~ '(sch, td), Has sch db schema, Has td schema ('Typedef ('PGenum labels))) => PGTyped db ('PGenum labels) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ('PGenum labels)) #

(UserType db ('PGcomposite row) ~ '(sch, td), Has sch db schema, Has td schema ('Typedef ('PGcomposite row))) => PGTyped db ('PGcomposite row) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ('PGcomposite row)) #

(KnownNat n, 1 <= n) => PGTyped db ('PGchar n) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ('PGchar n)) #

(All KnownNat dims, PGTyped db pg) => PGTyped db ('PGfixarray dims (null pg)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: forall (null0 :: PGType -> NullType). TypeExpression db (null0 ('PGfixarray dims (null pg))) #

class FieldTyped (db :: SchemasType) (ty :: (Symbol, NullType)) where #

Lift PGTyped to a field

Methods

fieldtype :: Aliased (TypeExpression db) ty #

Instances

Instances details
(KnownSymbol alias, NullTyped db ty) => FieldTyped db (alias ::: ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

fieldtype :: Aliased (TypeExpression db) (alias ::: ty) #

newtype ColumnTypeExpression (db :: SchemasType) (ty :: ColumnType) #

ColumnTypeExpressions are used in createTable commands.

Instances

Instances details
Eq (ColumnTypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Ord (ColumnTypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Show (ColumnTypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Generic (ColumnTypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Associated Types

type Rep (ColumnTypeExpression db ty) :: Type -> Type #

NFData (ColumnTypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

rnf :: ColumnTypeExpression db ty -> () #

RenderSQL (ColumnTypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

type Rep (ColumnTypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

type Rep (ColumnTypeExpression db ty) = D1 ('MetaData "ColumnTypeExpression" "Squeal.PostgreSQL.Expression.Type" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeColumnTypeExpression" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderColumnTypeExpression") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

class NullTyped (db :: SchemasType) (ty :: NullType) where #

Like PGTyped but also accounts for null.

Methods

nulltype :: TypeExpression db ty #

Instances

Instances details
PGTyped db ty => NullTyped db (null ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

nulltype :: TypeExpression db (null ty) #

class ColumnTyped (db :: SchemasType) (column :: ColumnType) where #

Like PGTyped but also accounts for null.

Methods

columntype :: ColumnTypeExpression db column #

Instances

Instances details
NullTyped db ('Null ty) => ColumnTyped db ('NoDef :=> 'Null ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

NullTyped db ('NotNull ty) => ColumnTyped db ('NoDef :=> 'NotNull ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

generateSeriesTimestamp #

Arguments

:: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGtimestamp, 'PGtimestamptz] 
=> '[null ty, null ty, null 'PGinterval] --|-> ("generate_series" ::: '["generate_series" ::: null ty])

set returning function

generateSeriesTimestamp (start :* stop *: step)

Generate a series of timestamps, from start to stop with a step size of step

>>> :{
let
  start = now
  stop = now !+ interval_ 10 Years
  step = interval_ 1 Months
in printSQL (generateSeriesTimestamp (start :* stop *: step))
:}
generate_series(now(), (now() + (INTERVAL '10.000 years')), (INTERVAL '1.000 months'))

generateSeriesStep #

Arguments

:: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGint4, 'PGint8, 'PGnumeric] 
=> '[null ty, null ty, null ty] --|-> ("generate_series" ::: '["generate_series" ::: null ty])

set returning function

generateSeriesStep (start :* stop *: step)

Generate a series of values, from start to stop with a step size of step

>>> printSQL (generateSeriesStep @'PGint8 (2 :* 100 *: 2))
generate_series((2 :: int8), (100 :: int8), (2 :: int8))

generateSeries #

Arguments

:: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGint4, 'PGint8, 'PGnumeric] 
=> '[null ty, null ty] --|-> ("generate_series" ::: '["generate_series" ::: null ty])

set returning function

generateSeries (start :* stop)

Generate a series of values, from start to stop with a step size of one

>>> printSQL (generateSeries @'PGint4 (1 *: 10))
generate_series((1 :: int4), (10 :: int4))

setFunctionN #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (tys :: [NullType]) (row :: RowType). (Has sch db schema, Has fun schema ('Function (tys :=> 'ReturnsTable row)), SListI tys) 
=> QualifiedAlias sch fun

function alias

-> SetFunN db tys (fun ::: row) 

Call a user defined multivariable set returning function

>>> type Fn = '[ 'Null 'PGbool, 'Null 'PGtext] :=> 'ReturnsTable '["ret" ::: 'NotNull 'PGnumeric]
>>> type Schema = '["fn" ::: 'Function Fn]
>>> :{
let
  fn :: SetFunN (Public Schema)
    '[ 'Null 'PGbool, 'Null 'PGtext]
    ("fn" ::: '["ret" ::: 'NotNull 'PGnumeric])
  fn = setFunctionN #fn
in
  printSQL (fn (true *: "hi"))
:}
"fn"(TRUE, (E'hi' :: text))

unsafeSetFunctionN #

Arguments

:: forall (fun :: Symbol) (tys :: [NullType]) (row :: RowType). (SListI tys, KnownSymbol fun) 
=> ByteString 
-> tys --|-> (fun ::: row)

set returning function

Escape hatch for a multivariable set returning function

setFunction #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (ty :: NullType) (row :: RowType). (Has sch db schema, Has fun schema ('Function ('[ty] :=> 'ReturnsTable row))) 
=> QualifiedAlias sch fun

function alias

-> SetFun db ty (fun ::: row) 

Call a user defined set returning function of a single variable

>>> type Fn = '[ 'Null 'PGbool] :=> 'ReturnsTable '["ret" ::: 'NotNull 'PGnumeric]
>>> type Schema = '["fn" ::: 'Function Fn]
>>> :{
let
  fn :: SetFun (Public Schema) ('Null 'PGbool) ("fn" ::: '["ret" ::: 'NotNull 'PGnumeric])
  fn = setFunction #fn
in
  printSQL (fn true)
:}
"fn"(TRUE)

unsafeSetFunction #

Arguments

:: forall (fun :: Symbol) (ty :: NullType) (row :: RowType). KnownSymbol fun 
=> ByteString 
-> ty -|-> (fun ::: row)

set returning function

Escape hatch for a set returning function of a single variable

type (-|->) (arg :: NullType) (set :: (Symbol, RowType)) = forall (db :: SchemasType). SetFun db arg set #

A RankNType for set returning functions with 1 argument.

type (--|->) (arg :: [NullType]) (set :: (Symbol, RowType)) #

Arguments

 = forall (db :: SchemasType). SetFunN db arg set

output

A RankNType for set returning functions with multiple argument.

type SetFun (db :: SchemasType) (arg :: NullType) (row :: (Symbol, RowType)) #

Arguments

 = forall (lat :: FromType) (with :: FromType) (params :: [NullType]). Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]) arg

input

-> FromClause lat with db params '[row]

output

Like -|-> but depends on the schemas of the database

type SetFunN (db :: SchemasType) (args :: [NullType]) (set :: (Symbol, RowType)) #

Arguments

 = forall (lat :: FromType) (with :: FromType) (params :: [NullType]). NP (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)])) args

input

-> FromClause lat with db params '[set]

output

Like --|-> but depends on the schemas of the database

values_ #

Arguments

:: forall (cols :: [(Symbol, NullType)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI cols 
=> NP (Aliased (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]))) cols

one row of values

-> Query lat with db params cols 

values_ computes a row value or set of row values specified by value expressions.

values #

Arguments

:: forall (cols :: [(Symbol, NullType)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI cols 
=> NP (Aliased (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]))) cols 
-> [NP (Aliased (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]))) cols]

When more than one row is specified, all the rows must must have the same number of elements

-> Query lat with db params cols 

values computes a row value or set of row values specified by value expressions. It is most commonly used to generate a “constant table” within a larger command, but it can be used on its own.

>>> type Row = '["a" ::: 'NotNull 'PGint4, "b" ::: 'NotNull 'PGtext]
>>> let query = values (1 `as` #a :* "one" `as` #b) [] :: Query lat with db '[] Row
>>> printSQL query
SELECT * FROM (VALUES ((1 :: int4), (E'one' :: text))) AS t ("a", "b")

functionN #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (xs :: [NullType]) (y :: NullType). (Has sch db schema, Has fun schema ('Function (xs :=> 'Returns y)), SListI xs) 
=> QualifiedAlias sch fun

function alias

-> FunN db xs y 

Call a user defined multivariable function

>>> type Fn = '[ 'Null 'PGint4, 'Null 'PGbool] :=> 'Returns ('NotNull 'PGnumeric)
>>> type Schema = '["fn" ::: 'Function Fn]
>>> :{
let
  fn :: FunN (Public Schema) '[ 'Null 'PGint4, 'Null 'PGbool] ('NotNull 'PGnumeric)
  fn = functionN #fn
in
  printSQL (fn (1 *: true))
:}
"fn"((1 :: int4), TRUE)

unsafeFunctionN :: forall (xs :: [NullType]) (y :: NullType). SListI xs => ByteString -> xs ---> y #

>>> printSQL $ unsafeFunctionN "f" (currentTime :* localTimestamp :* false *: inline 'a')
f(CURRENT_TIME, LOCALTIMESTAMP, FALSE, (E'a' :: char(1)))

function #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (x :: NullType) (y :: NullType). (Has sch db schema, Has fun schema ('Function ('[x] :=> 'Returns y))) 
=> QualifiedAlias sch fun

function name

-> Fun db x y 

Call a user defined function of a single variable

>>> type Fn = '[ 'Null 'PGint4] :=> 'Returns ('NotNull 'PGnumeric)
>>> type Schema = '["fn" ::: 'Function Fn]
>>> :{
let
  fn :: Fun (Public Schema) ('Null 'PGint4) ('NotNull 'PGnumeric)
  fn = function #fn
in
  printSQL (fn 1)
:}
"fn"((1 :: int4))

unsafeFunction :: forall (x :: NullType) (y :: NullType). ByteString -> x --> y #

>>> printSQL $ unsafeFunction "f" true
f(TRUE)

unsafeRightOp :: forall (x :: NullType) (y :: NullType). ByteString -> x --> y #

>>> printSQL $ true & unsafeRightOp "IS NOT TRUE"
(TRUE IS NOT TRUE)

unsafeLeftOp :: forall (x :: NullType) (y :: NullType). ByteString -> x --> y #

>>> printSQL $ unsafeLeftOp "NOT" true
(NOT TRUE)

unsafeBinaryOp :: forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType). ByteString -> Operator ty0 ty1 ty2 #

>>> printSQL $ unsafeBinaryOp "OR" true false
(TRUE OR FALSE)

unsafeFunctionVar :: forall (x0 :: NullType) (x1 :: NullType) (y :: NullType). ByteString -> FunctionVar x0 x1 y #

>>> printSQL (unsafeFunctionVar "greatest" [true, null_] false)
greatest(TRUE, NULL, FALSE)

newtype Expression (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) #

Expressions are used in a variety of contexts, such as in the target List of the select command, as new column values in insertInto or update, or in search Conditions in a number of commands.

The expression syntax allows the calculation of values from primitive expression using arithmetic, logical, and other operations.

The type parameters of Expression are

Instances

Instances details
Aggregate AggregateArg (Expression ('Grouped bys) :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) #

count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) #

sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGSum ty)) #

arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ('PGvararray ty)) #

jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjson) #

jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjsonb) #

bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) #

bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) #

boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) #

min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) #

avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGint8) #

regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

(Has tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsQualified tab col (NP (Expression 'Ungrouped lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression 'Ungrouped lat with db params from) tys #

(Has tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression 'Ungrouped lat with db params from)) columns #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsQualified tab col (NP (Expression ('Grouped bys) lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression ('Grouped bys) lat with db params from) tys #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns #

(Has tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression 'Ungrouped lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression 'Ungrouped lat with db params from) column #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression ('Grouped bys) lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression ('Grouped bys) lat with db params from) column #

(Has tab (Join from lat) row, Has col row ty) => IsQualified tab col (Expression 'Ungrouped lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Expression 'Ungrouped lat with db params from ty #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys) => IsQualified tab col (Expression ('Grouped bys) lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Expression ('Grouped bys) lat with db params from ty #

(HasUnique tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsLabel col (NP (Expression 'Ungrouped lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Expression 'Ungrouped lat with db params from) tys #

(HasUnique tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression 'Ungrouped lat with db params from)) columns #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsLabel col (NP (Expression ('Grouped bys) lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Expression ('Grouped bys) lat with db params from) tys #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns #

(HasUnique tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression 'Ungrouped lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Aliased (Expression 'Ungrouped lat with db params from) column #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression ('Grouped bys) lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Aliased (Expression ('Grouped bys) lat with db params from) column #

(HasUnique tab (Join from lat) row, Has col row ty) => IsLabel col (Expression 'Ungrouped lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Expression 'Ungrouped lat with db params from ty #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys) => IsLabel col (Expression ('Grouped bys) lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Expression ('Grouped bys) lat with db params from ty #

(KnownSymbol label, In label labels) => IsPGlabel label (Expression grp lat with db params from (null ('PGenum labels))) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

label :: Expression grp lat with db params from (null ('PGenum labels)) #

(KnownSymbol col, row ~ '[col ::: ty]) => Aliasable col (Expression grp lat with db params from ty) (Selection grp lat with db params from row) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

as :: Expression grp lat with db params from ty -> Alias col -> Selection grp lat with db params from row #

Eq (Expression grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(==) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool #

(/=) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool #

Floating (Expression grp lat with db params from (null 'PGfloat4)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

pi :: Expression grp lat with db params from (null 'PGfloat4) #

exp :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

log :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

sqrt :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

(**) :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

logBase :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

sin :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

cos :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

tan :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

asin :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

acos :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

atan :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

sinh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

cosh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

tanh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

asinh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

acosh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

atanh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

log1p :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

expm1 :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

log1pexp :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

log1mexp :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

Floating (Expression grp lat with db params from (null 'PGfloat8)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

pi :: Expression grp lat with db params from (null 'PGfloat8) #

exp :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

log :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

sqrt :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

(**) :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

logBase :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

sin :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

cos :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

tan :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

asin :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

acos :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

atan :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

sinh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

cosh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

tanh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

asinh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

acosh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

atanh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

log1p :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

expm1 :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

log1pexp :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

log1mexp :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

Floating (Expression grp lat with db params from (null 'PGnumeric)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

pi :: Expression grp lat with db params from (null 'PGnumeric) #

exp :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

log :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

sqrt :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

(**) :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

logBase :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

sin :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

cos :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

tan :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

asin :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

acos :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

atan :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

sinh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

cosh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

tanh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

asinh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

acosh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

atanh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

log1p :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

expm1 :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

log1pexp :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

log1mexp :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

Fractional (Expression grp lat with db params from (null 'PGfloat4)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(/) :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

recip :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

fromRational :: Rational -> Expression grp lat with db params from (null 'PGfloat4) #

Fractional (Expression grp lat with db params from (null 'PGfloat8)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(/) :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

recip :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

fromRational :: Rational -> Expression grp lat with db params from (null 'PGfloat8) #

Fractional (Expression grp lat with db params from (null 'PGnumeric)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(/) :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

recip :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

fromRational :: Rational -> Expression grp lat with db params from (null 'PGnumeric) #

Num (Expression grp lat with db params from (null 'PGint2)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(+) :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) #

(-) :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) #

(*) :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) #

negate :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) #

abs :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) #

signum :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) #

fromInteger :: Integer -> Expression grp lat with db params from (null 'PGint2) #

Num (Expression grp lat with db params from (null 'PGint4)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(+) :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) #

(-) :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) #

(*) :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) #

negate :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) #

abs :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) #

signum :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) #

fromInteger :: Integer -> Expression grp lat with db params from (null 'PGint4) #

Num (Expression grp lat with db params from (null 'PGint8)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(+) :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) #

(-) :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) #

(*) :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) #

negate :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) #

abs :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) #

signum :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) #

fromInteger :: Integer -> Expression grp lat with db params from (null 'PGint8) #

Num (Expression grp lat with db params from (null 'PGfloat4)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(+) :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

(-) :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

(*) :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

negate :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

abs :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

signum :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) #

fromInteger :: Integer -> Expression grp lat with db params from (null 'PGfloat4) #

Num (Expression grp lat with db params from (null 'PGfloat8)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(+) :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

(-) :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

(*) :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

negate :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

abs :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

signum :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) #

fromInteger :: Integer -> Expression grp lat with db params from (null 'PGfloat8) #

Num (Expression grp lat with db params from (null 'PGnumeric)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(+) :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

(-) :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

(*) :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

negate :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

abs :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

signum :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) #

fromInteger :: Integer -> Expression grp lat with db params from (null 'PGnumeric) #

Ord (Expression grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

compare :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Ordering #

(<) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool #

(<=) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool #

(>) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool #

(>=) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool #

max :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Expression grp lat with db params from ty #

min :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Expression grp lat with db params from ty #

Show (Expression grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

showsPrec :: Int -> Expression grp lat with db params from ty -> ShowS #

show :: Expression grp lat with db params from ty -> String #

showList :: [Expression grp lat with db params from ty] -> ShowS #

IsString (Expression grp lat with db params from (null 'PGtext)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromString :: String -> Expression grp lat with db params from (null 'PGtext) #

IsString (Expression grp lat with db params from (null 'PGtsvector)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromString :: String -> Expression grp lat with db params from (null 'PGtsvector) #

IsString (Expression grp lat with db params from (null 'PGtsquery)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromString :: String -> Expression grp lat with db params from (null 'PGtsquery) #

Generic (Expression grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Associated Types

type Rep (Expression grp lat with db params from ty) :: Type -> Type #

Methods

from :: Expression grp lat with db params from ty -> Rep (Expression grp lat with db params from ty) x #

to :: Rep (Expression grp lat with db params from ty) x -> Expression grp lat with db params from ty #

Semigroup (Expression grp lat with db params from (null ('PGvararray ty))) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(<>) :: Expression grp lat with db params from (null ('PGvararray ty)) -> Expression grp lat with db params from (null ('PGvararray ty)) -> Expression grp lat with db params from (null ('PGvararray ty)) #

sconcat :: NonEmpty (Expression grp lat with db params from (null ('PGvararray ty))) -> Expression grp lat with db params from (null ('PGvararray ty)) #

stimes :: Integral b => b -> Expression grp lat with db params from (null ('PGvararray ty)) -> Expression grp lat with db params from (null ('PGvararray ty)) #

Semigroup (Expression grp lat with db params from (null 'PGjsonb)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(<>) :: Expression grp lat with db params from (null 'PGjsonb) -> Expression grp lat with db params from (null 'PGjsonb) -> Expression grp lat with db params from (null 'PGjsonb) #

sconcat :: NonEmpty (Expression grp lat with db params from (null 'PGjsonb)) -> Expression grp lat with db params from (null 'PGjsonb) #

stimes :: Integral b => b -> Expression grp lat with db params from (null 'PGjsonb) -> Expression grp lat with db params from (null 'PGjsonb) #

Semigroup (Expression grp lat with db params from (null 'PGtext)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(<>) :: Expression grp lat with db params from (null 'PGtext) -> Expression grp lat with db params from (null 'PGtext) -> Expression grp lat with db params from (null 'PGtext) #

sconcat :: NonEmpty (Expression grp lat with db params from (null 'PGtext)) -> Expression grp lat with db params from (null 'PGtext) #

stimes :: Integral b => b -> Expression grp lat with db params from (null 'PGtext) -> Expression grp lat with db params from (null 'PGtext) #

Semigroup (Expression grp lat with db params from (null 'PGtsvector)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(<>) :: Expression grp lat with db params from (null 'PGtsvector) -> Expression grp lat with db params from (null 'PGtsvector) -> Expression grp lat with db params from (null 'PGtsvector) #

sconcat :: NonEmpty (Expression grp lat with db params from (null 'PGtsvector)) -> Expression grp lat with db params from (null 'PGtsvector) #

stimes :: Integral b => b -> Expression grp lat with db params from (null 'PGtsvector) -> Expression grp lat with db params from (null 'PGtsvector) #

Monoid (Expression grp lat with db params from (null 'PGtext)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

mempty :: Expression grp lat with db params from (null 'PGtext) #

mappend :: Expression grp lat with db params from (null 'PGtext) -> Expression grp lat with db params from (null 'PGtext) -> Expression grp lat with db params from (null 'PGtext) #

mconcat :: [Expression grp lat with db params from (null 'PGtext)] -> Expression grp lat with db params from (null 'PGtext) #

Monoid (Expression grp lat with db params from (null 'PGtsvector)) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

mempty :: Expression grp lat with db params from (null 'PGtsvector) #

mappend :: Expression grp lat with db params from (null 'PGtsvector) -> Expression grp lat with db params from (null 'PGtsvector) -> Expression grp lat with db params from (null 'PGtsvector) #

mconcat :: [Expression grp lat with db params from (null 'PGtsvector)] -> Expression grp lat with db params from (null 'PGtsvector) #

NFData (Expression grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

rnf :: Expression grp lat with db params from ty -> () #

RenderSQL (Expression grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

renderSQL :: Expression grp lat with db params from ty -> ByteString #

type Rep (Expression grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

type Rep (Expression grp lat with db params from ty) = D1 ('MetaData "Expression" "Squeal.PostgreSQL.Expression" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeExpression" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderExpression") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

type Expr (x :: NullType) #

Arguments

 = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Expression grp lat with db params from x

cannot reference aliases

An Expr is a closed Expression. It is a FRankNType but don't be scared. Think of it as an expression which sees no namespaces, so you can't use parameters or alias references. It can be used as a simple piece of more complex Expressions.

type Operator (x1 :: NullType) (x2 :: NullType) (y :: NullType) = forall (db :: SchemasType). OperatorDB db x1 x2 y #

A RankNType for binary operators.

type OperatorDB (db :: SchemasType) (x1 :: NullType) (x2 :: NullType) (y :: NullType) #

Arguments

 = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). Expression grp lat with db params from x1

left input

-> Expression grp lat with db params from x2

right input

-> Expression grp lat with db params from y

output

Like Operator but depends on the schemas of the database

type (-->) (x :: NullType) (y :: NullType) = forall (db :: SchemasType). Fun db x y #

A RankNType for functions with a single argument. These could be either function calls or unary operators. This is a subtype of the usual Haskell function type ->, indeed a subcategory as it is closed under the usual . and id.

type Fun (db :: SchemasType) (x :: NullType) (y :: NullType) #

Arguments

 = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). Expression grp lat with db params from x

input

-> Expression grp lat with db params from y

output

Like --> but depends on the schemas of the database

type (--->) (xs :: [NullType]) (y :: NullType) = forall (db :: SchemasType). FunN db xs y #

A RankNType for functions with a fixed-length list of heterogeneous arguments. Use the *: operator to end your argument lists, like so.

>>> printSQL (unsafeFunctionN "fun" (true :* false :* localTime *: true))
fun(TRUE, FALSE, LOCALTIME, TRUE)

type FunN (db :: SchemasType) (xs :: [NullType]) (y :: NullType) #

Arguments

 = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). NP (Expression grp lat with db params from) xs

inputs

-> Expression grp lat with db params from y

output

Like ---> but depends on the schemas of the database

type FunctionVar (x0 :: NullType) (x1 :: NullType) (y :: NullType) #

Arguments

 = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [Expression grp lat with db params from x0]

inputs

-> Expression grp lat with db params from x1

must have at least 1 input

-> Expression grp lat with db params from y

output

A RankNType for functions with a variable-length list of homogeneous arguments and at least 1 more argument.

class PGSubset (ty :: k) where #

Contained by operators

Minimal complete definition

Nothing

Methods

(@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) #

(<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) #

Instances

Instances details
PGSubset 'PGtsquery 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 'PGtsquery) (null1 'PGtsquery) ('Null 'PGbool) #

(<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 'PGtsquery) (null1 'PGtsquery) ('Null 'PGbool) #

PGSubset 'PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 'PGjsonb) (null1 'PGjsonb) ('Null 'PGbool) #

(<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 'PGjsonb) (null1 'PGjsonb) ('Null 'PGbool) #

PGSubset ('PGrange ty :: PGType) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGrange ty)) (null1 ('PGrange ty)) ('Null 'PGbool) #

(<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGrange ty)) (null1 ('PGrange ty)) ('Null 'PGbool) #

PGSubset ('PGvararray ty :: PGType) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGvararray ty)) (null1 ('PGvararray ty)) ('Null 'PGbool) #

(<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGvararray ty)) (null1 ('PGvararray ty)) ('Null 'PGbool) #

class PGIntersect (ty :: k) where #

Intersection operator

Minimal complete definition

Nothing

Methods

(@&&) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) #

Instances

Instances details
PGIntersect ('PGrange ty :: PGType) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@&&) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGrange ty)) (null1 ('PGrange ty)) ('Null 'PGbool) #

PGIntersect ('PGvararray ty :: PGType) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@&&) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGvararray ty)) (null1 ('PGvararray ty)) ('Null 'PGbool) #

mapOptional :: forall k expr (x :: k) (y :: k) (def :: Optionality). (expr x -> expr y) -> Optional expr (def :=> x) -> Optional expr (def :=> y) #

Map a function over an Optional expression.

pattern NotDefault :: ty -> Optional I ('Def :=> ty) #

NotDefault pattern analagous to Just.

data Optional (expr :: k -> Type) (ty :: (Optionality, k)) where #

Optional is either Default or Setting of a value, parameterized by an appropriate Optionality.

Constructors

Default :: forall k (expr :: k -> Type) (ty1 :: k). Optional expr '('Def, ty1)

Use the Default value for a column.

Set :: forall k (expr :: k -> Type) (ty1 :: k) (def :: Optionality). expr ty1 -> Optional expr '(def, ty1)

Set a value for a column.

Instances

Instances details
(forall (x :: k). RenderSQL (expr x)) => RenderSQL (Optional expr ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Default

Methods

renderSQL :: Optional expr ty -> ByteString #

(KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: Optional I ('Def :=> x)) (col ::: ('Def :=> ty)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineColumn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (col ::: Optional I ('Def :=> x)) -> Aliased (Optional (Expression grp lat with db params from)) (col ::: ('Def :=> ty)) #

common #

Arguments

:: forall (cte :: Symbol) (with :: [(Symbol, RowType)]) (common :: RowType) (alias :: Symbol) (lat :: FromType) (db :: SchemasType) (params :: [NullType]). Has cte with common 
=> Aliased Alias (alias ::: cte)

(renamable) common table expression alias

-> FromClause lat with db params '[alias ::: common] 

common derives a table from a common table expression.

view #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (vw :: Symbol) (view :: RowType) (alias :: Symbol) (lat :: FromType) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has vw schema ('View view)) 
=> Aliased (QualifiedAlias sch) (alias ::: vw)

(renamable) view alias

-> FromClause lat with db params '[alias ::: view] 

view derives a table from a View.

subquery #

Arguments

:: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query lat with db params) query

aliased Query

-> FromClause lat with db params '[query] 

subquery derives a table from a Query. The subquery may not reference columns provided by preceding FromClause items. Use JoinLateral if the subquery must reference columns provided by preceding FromClause items.

table #

Arguments

:: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (alias :: Symbol) (lat :: FromType) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab schema ('Table table)) 
=> Aliased (QualifiedAlias sch) (alias ::: tab)

(renamable) table alias

-> FromClause lat with db params '[alias ::: TableToRow table] 

A real table is a table from the database.

newtype FromClause (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) #

A FromClause can be a table name, or a derived table such as a subquery, a JOIN construct, or complex combinations of these.

Instances

Instances details
Additional (FromClause lat with db params :: FromType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

Methods

also :: forall (ys :: [a]) (xs :: [a]). FromClause lat with db params ys -> FromClause lat with db params xs -> FromClause lat with db params (Join xs ys) #

Eq (FromClause lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

Methods

(==) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool #

(/=) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool #

Ord (FromClause lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

Methods

compare :: FromClause lat with db params from -> FromClause lat with db params from -> Ordering #

(<) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool #

(<=) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool #

(>) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool #

(>=) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool #

max :: FromClause lat with db params from -> FromClause lat with db params from -> FromClause lat with db params from #

min :: FromClause lat with db params from -> FromClause lat with db params from -> FromClause lat with db params from #

Show (FromClause lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

Methods

showsPrec :: Int -> FromClause lat with db params from -> ShowS #

show :: FromClause lat with db params from -> String #

showList :: [FromClause lat with db params from] -> ShowS #

Generic (FromClause lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

Associated Types

type Rep (FromClause lat with db params from) :: Type -> Type #

Methods

from :: FromClause lat with db params from -> Rep (FromClause lat with db params from) x #

to :: Rep (FromClause lat with db params from) x -> FromClause lat with db params from #

NFData (FromClause lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

Methods

rnf :: FromClause lat with db params from -> () #

RenderSQL (FromClause lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

Methods

renderSQL :: FromClause lat with db params from -> ByteString #

type Rep (FromClause lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

type Rep (FromClause lat with db params from) = D1 ('MetaData "FromClause" "Squeal.PostgreSQL.Query.From" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeFromClause" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderFromClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

withRecursive #

Arguments

:: forall (lat :: FromType) (recursive :: (Symbol, RowType)) (with :: [(Symbol, RowType)]) (db :: SchemasType) (params :: [NullType]) (row :: RowType). Aliased (Query lat (recursive ': with) db params) recursive

recursive query

-> Query lat (recursive ': with) db params row

larger query

-> Query lat with db params row 

A withRecursive Query can refer to its own output. A very simple example is this query to sum the integers from 1 through 100:

>>> import Data.Monoid (Sum (..))
>>> import Data.Int (Int64)
>>> :{
  let
    sum100 :: Statement db () (Sum Int64)
    sum100 = query $
      withRecursive
        ( values_ ((1 & astype int) `as` #n)
          `unionAll`
          select_ ((#n + 1) `as` #n)
            (from (common #t) & where_ (#n .< 100)) `as` #t )
        ( select_
            (fromNull 0 (sum_ (All #n)) `as` #getSum)
            (from (common #t) & groupBy Nil) )
  in printSQL sum100
:}
WITH RECURSIVE "t" AS ((SELECT * FROM (VALUES (((1 :: int4) :: int))) AS t ("n")) UNION ALL (SELECT ("n" + (1 :: int4)) AS "n" FROM "t" AS "t" WHERE ("n" < (100 :: int4)))) SELECT COALESCE(sum(ALL "n"), (0 :: int8)) AS "getSum" FROM "t" AS "t"

The general form of a recursive WITH query is always a non-recursive term, then union (or unionAll), then a recursive term, where only the recursive term can contain a reference to the query's own output.

class With (statement :: FromType -> SchemasType -> [NullType] -> RowType -> Type) where #

with provides a way to write auxiliary statements for use in a larger query. These statements, referred to as CommonTableExpressions, can be thought of as defining temporary tables that exist just for one query.

with can be used for a Query. Multiple CommonTableExpressions can be chained together with the Path constructor :>>, and each CommonTableExpression is constructed via overloaded as.

>>> type Columns = '["col1" ::: 'NoDef :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]
>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>> :{
let
  qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  qry = with (
    select Star (from (table #tab)) `as` #cte1 :>>
    select Star (from (common #cte1)) `as` #cte2
    ) (select Star (from (common #cte2)))
in printSQL qry
:}
WITH "cte1" AS (SELECT * FROM "tab" AS "tab"), "cte2" AS (SELECT * FROM "cte1" AS "cte1") SELECT * FROM "cte2" AS "cte2"

You can use data-modifying statements in with. This allows you to perform several different operations in the same query. An example is:

>>> type ProductsColumns = '["product" ::: 'NoDef :=> 'NotNull 'PGtext, "date" ::: 'Def :=> 'NotNull 'PGdate]
>>> type ProductsSchema = '["products" ::: 'Table ('[] :=> ProductsColumns), "products_deleted" ::: 'Table ('[] :=> ProductsColumns)]
>>> :{
let
  manp :: Manipulation with (Public ProductsSchema) '[ 'NotNull 'PGdate] '[]
  manp = with
    (deleteFrom #products NoUsing (#date .< param @1) (Returning Star) `as` #del)
    (insertInto_ #products_deleted (Subquery (select Star (from (common #del)))))
in printSQL manp
:}
WITH "del" AS (DELETE FROM "products" AS "products" WHERE ("date" < ($1 :: date)) RETURNING *) INSERT INTO "products_deleted" AS "products_deleted" SELECT * FROM "del" AS "del"

Methods

with #

Arguments

:: forall (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) (row :: RowType). Path (CommonTableExpression statement db params) with0 with1

common table expressions

-> statement with1 db params row

larger query

-> statement with0 db params row 

Instances

Instances details
With Manipulation 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

with :: forall (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) (row :: RowType). Path (CommonTableExpression Manipulation db params) with0 with1 -> Manipulation with1 db params row -> Manipulation with0 db params row #

With (Query lat) 
Instance details

Defined in Squeal.PostgreSQL.Query.With

Methods

with :: forall (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) (row :: RowType). Path (CommonTableExpression (Query lat) db params) with0 with1 -> Query lat with1 db params row -> Query lat with0 db params row #

data CommonTableExpression (statement :: FromType -> SchemasType -> [NullType] -> RowType -> Type) (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) where #

A CommonTableExpression is an auxiliary statement in a with clause.

Constructors

CommonTableExpression 

Fields

Instances

Instances details
(KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (Path (CommonTableExpression statement db params) with with1) 
Instance details

Defined in Squeal.PostgreSQL.Query.With

Methods

as :: statement with db params common -> Alias cte -> Path (CommonTableExpression statement db params) with with1 #

(KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (CommonTableExpression statement db params with with1) 
Instance details

Defined in Squeal.PostgreSQL.Query.With

Methods

as :: statement with db params common -> Alias cte -> CommonTableExpression statement db params with with1 #

(forall (c :: FromType) (s :: SchemasType) (p :: [NullType]) (r :: RowType). RenderSQL (statement c s p r)) => RenderSQL (CommonTableExpression statement db params with0 with1) 
Instance details

Defined in Squeal.PostgreSQL.Query.With

Methods

renderSQL :: CommonTableExpression statement db params with0 with1 -> ByteString #

exceptAll :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #

The results of two queries can be combined using the set operation exceptAll, the set difference. Duplicate rows are retained.

except :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #

The results of two queries can be combined using the set operation except, the set difference. Duplicate rows are eliminated.

intersectAll :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #

The results of two queries can be combined using the set operation intersectAll, the intersection. Duplicate rows are retained.

intersect :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #

The results of two queries can be combined using the set operation intersect, the intersection. Duplicate rows are eliminated.

unionAll :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #

The results of two queries can be combined using the set operation unionAll, the disjoint union. Duplicate rows are retained.

union :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #

The results of two queries can be combined using the set operation union. Duplicate rows are eliminated.

newtype Query (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (row :: RowType) #

The process of retrieving or the command to retrieve data from a database is called a Query.

The general Query type is parameterized by

  • lat :: FromType - scope for JoinLateral and subquery expressions,
  • with :: FromType - scope for all common table expressions,
  • db :: SchemasType - scope for all tables and views,
  • params :: [NullType] - scope for all parameters,
  • row :: RowType - return type of the Query.

Let's see some Query examples.

simple query:

>>> type Columns = '["col1" ::: 'NoDef :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]
>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>> :{
let
  qry :: Query lat with (Public Schema) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  qry = select Star (from (table #tab))
in printSQL qry
:}
SELECT * FROM "tab" AS "tab"

restricted query:

>>> :{
let
  qry :: Query '[] with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  qry =
    select_ ((#col1 + #col2) `as` #col1 :* #col1 `as` #col2)
      ( from (table #tab)
        & where_ (#col1 .> #col2)
        & where_ (#col2 .> 0) )
in printSQL qry
:}
SELECT ("col1" + "col2") AS "col1", "col1" AS "col2" FROM "tab" AS "tab" WHERE (("col1" > "col2") AND ("col2" > (0 :: int4)))

subquery:

>>> :{
let
  qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  qry = select Star (from (subquery (select Star (from (table #tab)) `as` #sub)))
in printSQL qry
:}
SELECT * FROM (SELECT * FROM "tab" AS "tab") AS "sub"

limits and offsets:

>>> :{
let
  qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  qry = select Star (from (table #tab) & limit 100 & offset 2 & limit 50 & offset 2)
in printSQL qry
:}
SELECT * FROM "tab" AS "tab" LIMIT 50 OFFSET 4

parameterized query:

>>> :{
let
  qry :: Query '[] with (Public Schema) '[ 'NotNull 'PGint4] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  qry = select Star (from (table #tab) & where_ (#col1 .> param @1))
in printSQL qry
:}
SELECT * FROM "tab" AS "tab" WHERE ("col1" > ($1 :: int4))

aggregation query:

>>> :{
let
  qry :: Query '[] with (Public Schema) params '["col1" ::: 'NotNull 'PGint8, "col2" ::: 'NotNull 'PGint4]
  qry =
    select_ ((fromNull 0 (sum_ (All #col2))) `as` #col1 :* #col1 `as` #col2)
    ( from (table (#tab `as` #table1))
      & groupBy #col1
      & having (sum_ (Distinct #col2) .> 1) )
in printSQL qry
:}
SELECT COALESCE(sum(ALL "col2"), (0 :: int8)) AS "col1", "col1" AS "col2" FROM "tab" AS "table1" GROUP BY "col1" HAVING (sum(DISTINCT "col2") > (1 :: int8))

sorted query:

>>> :{
let
  qry :: Query '[] with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  qry = select Star (from (table #tab) & orderBy [#col1 & Asc])
in printSQL qry
:}
SELECT * FROM "tab" AS "tab" ORDER BY "col1" ASC

joins:

>>> :{
type OrdersColumns =
  '[ "id"         ::: 'NoDef :=> 'NotNull 'PGint4
   , "price"       ::: 'NoDef :=> 'NotNull 'PGfloat4
   , "customer_id" ::: 'NoDef :=> 'NotNull 'PGint4
   , "shipper_id"  ::: 'NoDef :=> 'NotNull 'PGint4  ]
:}
>>> :{
type OrdersConstraints =
  '["pk_orders" ::: PrimaryKey '["id"]
  ,"fk_customers" ::: ForeignKey '["customer_id"] "public" "customers" '["id"]
  ,"fk_shippers" ::: ForeignKey '["shipper_id"] "public" "shippers" '["id"] ]
:}
>>> type NamesColumns = '["id" ::: 'NoDef :=> 'NotNull 'PGint4, "name" ::: 'NoDef :=> 'NotNull 'PGtext]
>>> type CustomersConstraints = '["pk_customers" ::: PrimaryKey '["id"]]
>>> type ShippersConstraints = '["pk_shippers" ::: PrimaryKey '["id"]]
>>> :{
type OrdersSchema =
  '[ "orders"   ::: 'Table (OrdersConstraints :=> OrdersColumns)
   , "customers" ::: 'Table (CustomersConstraints :=> NamesColumns)
   , "shippers" ::: 'Table (ShippersConstraints :=> NamesColumns) ]
:}
>>> :{
type OrderRow =
  '[ "price" ::: 'NotNull 'PGfloat4
   , "customerName" ::: 'NotNull 'PGtext
   , "shipperName" ::: 'NotNull 'PGtext
   ]
:}
>>> :{
let
  qry :: Query lat with (Public OrdersSchema) params OrderRow
  qry = select_
    ( #o ! #price `as` #price :*
      #c ! #name `as` #customerName :*
      #s ! #name `as` #shipperName )
    ( from (table (#orders `as` #o)
      & innerJoin (table (#customers `as` #c))
        (#o ! #customer_id .== #c ! #id)
      & innerJoin (table (#shippers `as` #s))
        (#o ! #shipper_id .== #s ! #id)) )
in printSQL qry
:}
SELECT "o"."price" AS "price", "c"."name" AS "customerName", "s"."name" AS "shipperName" FROM "orders" AS "o" INNER JOIN "customers" AS "c" ON ("o"."customer_id" = "c"."id") INNER JOIN "shippers" AS "s" ON ("o"."shipper_id" = "s"."id")

self-join:

>>> :{
let
  qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  qry = select
    (#t1 & DotStar)
    (from (table (#tab `as` #t1) & crossJoin (table (#tab `as` #t2))))
in printSQL qry
:}
SELECT "t1".* FROM "tab" AS "t1" CROSS JOIN "tab" AS "t2"

value queries:

>>> :{
let
  qry :: Query lat with db params '["col1" ::: 'NotNull 'PGtext, "col2" ::: 'NotNull 'PGbool]
  qry = values
    ("true" `as` #col1 :* true `as` #col2)
    ["false" `as` #col1 :* false `as` #col2]
in printSQL qry
:}
SELECT * FROM (VALUES ((E'true' :: text), TRUE), ((E'false' :: text), FALSE)) AS t ("col1", "col2")

set operations:

>>> :{
let
  qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  qry = select Star (from (table #tab)) `unionAll` select Star (from (table #tab))
in printSQL qry
:}
(SELECT * FROM "tab" AS "tab") UNION ALL (SELECT * FROM "tab" AS "tab")

with query:

>>> :{
let
  qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
  qry = with (
    select Star (from (table #tab)) `as` #cte1 :>>
    select Star (from (common #cte1)) `as` #cte2
    ) (select Star (from (common #cte2)))
in printSQL qry
:}
WITH "cte1" AS (SELECT * FROM "tab" AS "tab"), "cte2" AS (SELECT * FROM "cte1" AS "cte1") SELECT * FROM "cte2" AS "cte2"

window functions:

>>> :{
let
  qry :: Query '[] with (Public Schema) db '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint8]
  qry = select
    (#col1 & Also (rank `as` #col2 `Over` (partitionBy #col1 & orderBy [#col2 & Asc])))
    (from (table #tab))
in printSQL qry
:}
SELECT "col1" AS "col1", rank() OVER (PARTITION BY "col1" ORDER BY "col2" ASC) AS "col2" FROM "tab" AS "tab"

correlated subqueries:

>>> :{
let
  qry :: Query '[] with (Public Schema) params '["col1" ::: 'NotNull 'PGint4]
  qry =
    select #col1 (from (table (#tab `as` #t1))
    & where_ (exists (
      select Star (from (table (#tab `as` #t2))
      & where_ (#t2 ! #col2 .== #t1 ! #col1)))))
in printSQL qry
:}
SELECT "col1" AS "col1" FROM "tab" AS "t1" WHERE EXISTS (SELECT * FROM "tab" AS "t2" WHERE ("t2"."col2" = "t1"."col1"))

Constructors

UnsafeQuery 

Instances

Instances details
With (Query lat) 
Instance details

Defined in Squeal.PostgreSQL.Query.With

Methods

with :: forall (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) (row :: RowType). Path (CommonTableExpression (Query lat) db params) with0 with1 -> Query lat with1 db params row -> Query lat with0 db params row #

Eq (Query lat with db params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(==) :: Query lat with db params row -> Query lat with db params row -> Bool #

(/=) :: Query lat with db params row -> Query lat with db params row -> Bool #

Ord (Query lat with db params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

compare :: Query lat with db params row -> Query lat with db params row -> Ordering #

(<) :: Query lat with db params row -> Query lat with db params row -> Bool #

(<=) :: Query lat with db params row -> Query lat with db params row -> Bool #

(>) :: Query lat with db params row -> Query lat with db params row -> Bool #

(>=) :: Query lat with db params row -> Query lat with db params row -> Bool #

max :: Query lat with db params row -> Query lat with db params row -> Query lat with db params row #

min :: Query lat with db params row -> Query lat with db params row -> Query lat with db params row #

Show (Query lat with db params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

showsPrec :: Int -> Query lat with db params row -> ShowS #

show :: Query lat with db params row -> String #

showList :: [Query lat with db params row] -> ShowS #

Generic (Query lat with db params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Associated Types

type Rep (Query lat with db params row) :: Type -> Type #

Methods

from :: Query lat with db params row -> Rep (Query lat with db params row) x #

to :: Rep (Query lat with db params row) x -> Query lat with db params row #

NFData (Query lat with db params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

rnf :: Query lat with db params row -> () #

RenderSQL (Query lat with db params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: Query lat with db params row -> ByteString #

type Rep (Query lat with db params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

type Rep (Query lat with db params row) = D1 ('MetaData "Query" "Squeal.PostgreSQL.Query" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "UnsafeQuery" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderQuery") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

type family Query_ (db :: SchemasType) params row where ... #

The Query_ type is parameterized by a db SchemasType, against which the query is type-checked, an input params Haskell Type, and an ouput row Haskell Type.

A Query_ can be run using runQueryParams, or if params = () using runQuery.

Generally, params will be a Haskell tuple or record whose entries may be referenced using positional parameters and row will be a Haskell record, whose entries will be targeted using overloaded labels.

Query_ is a type family which resolves into a Query, so don't be fooled by the input params and output row Haskell Types, which are converted into appropriate Postgres [NullType] params and RowType rows. Use query to fix actual Haskell input params and output rows.

>>> :set -XDeriveAnyClass -XDerivingStrategies
>>> type Columns = '["col1" ::: 'NoDef :=> 'Null 'PGint8, "col2" ::: 'Def :=> 'NotNull 'PGtext]
>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
>>> :{
data Row = Row { col1 :: Maybe Int64, col2 :: String }
  deriving stock (GHC.Generic)
  deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
:}
>>> :{
let
  qry :: Query_ (Public Schema) (Int64, Bool) Row
  qry = select Star (from (table #tab) & where_ (#col1 .> param @1 .&& notNull (param @2)))
  stmt :: Statement (Public Schema) (Int64, Bool) Row
  stmt = query qry
:}
>>> :type qry
qry
  :: Query
       '[]
       '[]
       '["public" ::: '["tab" ::: 'Table ('[] :=> Columns)]]
       '[ 'NotNull 'PGint8, 'NotNull 'PGbool]
       '["col1" ::: 'Null 'PGint8, "col2" ::: 'NotNull 'PGtext]
>>> :type stmt
stmt
  :: Statement
       '["public" ::: '["tab" ::: 'Table ('[] :=> Columns)]]
       (Int64, Bool)
       Row

Equations

Query_ db params row = Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db (TuplePG params) (RowPG row) 

lowerConnection :: forall a (schema :: a) (db :: [a]). K Connection (schema ': db) -> K Connection db #

Safely lowerConnection to a smaller schema.

finish :: forall k io (db :: k). MonadIO io => K Connection db -> io () #

Closes the connection to the server.

connectdb #

Arguments

:: forall (db :: SchemasType) io. MonadIO io 
=> ByteString

conninfo

-> io (K Connection db) 

Makes a new connection to the database server.

This function opens a new database connection using the parameters taken from the string conninfo.

The passed string can be empty to use all default parameters, or it can contain one or more parameter settings separated by whitespace. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value or a value containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., ' and .

To specify the schema you wish to connect with, use type application.

>>> :set -XDataKinds
>>> :set -XPolyKinds
>>> :set -XTypeOperators
>>> type DB = '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint2])]]
>>> :set -XTypeApplications
>>> :set -XOverloadedStrings
>>> conn <- connectdb @DB "host=localhost port=5432 dbname=exampledb user=postgres password=postgres"

Note that, for now, squeal doesn't offer any protection from connecting with the wrong schema!

class OidOf (db :: SchemasType) (pg :: PGType) where #

The Oid of a PGType

>>> :set -XTypeApplications
>>> conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres"
>>> runReaderT (oidOf @'[] @'PGbool) conn
Oid 16
>>> finish conn

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

Instances

Instances details
OidOf db 'PGuuid 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGtsvector 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGtsquery 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGtimetz 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGtimestamptz 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGtimestamp 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGtime 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGtext 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGoid 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGnumeric 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGmoney 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGjson 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGint8 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGint4 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGint2 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGinet 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGfloat8 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGfloat4 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGdate 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGbytea 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db 'PGbool 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db ('PGvarchar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOfArray db pg => OidOf db ('PGvararray (null pg)) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db ('PGrange 'PGint4) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db ('PGrange 'PGint8) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db ('PGrange 'PGnumeric) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db ('PGrange 'PGtimestamp) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db ('PGrange 'PGtimestamptz) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db ('PGrange 'PGdate) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

(UserType db ('PGenum labels) ~ '(sch, td), Has sch db schema, Has td schema ('Typedef ('PGenum labels))) => OidOf db ('PGenum labels) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

(UserType db ('PGcomposite row) ~ '(sch, td), Has sch db schema, Has td schema ('Typedef ('PGcomposite row))) => OidOf db ('PGcomposite row) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOf db ('PGchar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

OidOfArray db pg => OidOf db ('PGfixarray dims (null pg)) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

Methods

oidOf :: ReaderT (K Connection db) IO Oid #

class OidOfArray (db :: SchemasType) (pg :: PGType) where #

The Oid of an array

Instances

Instances details
OidOfArray db 'PGuuid 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGtsvector 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGtsquery 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGtimetz 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGtimestamptz 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGtimestamp 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGtime 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGtext 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGoid 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGnumeric 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGmoney 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGjson 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGint8 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGint4 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGint2 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGinet 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGfloat8 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGfloat4 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGdate 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGbytea 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db 'PGbool 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db ('PGvarchar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db ('PGrange 'PGint4) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db ('PGrange 'PGint8) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db ('PGrange 'PGnumeric) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db ('PGrange 'PGtimestamp) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db ('PGrange 'PGtimestamptz) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db ('PGrange 'PGdate) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

(UserType db ('PGenum labels) ~ '(sch, td), Has sch db schema, Has td schema ('Typedef ('PGenum labels))) => OidOfArray db ('PGenum labels) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

(UserType db ('PGcomposite row) ~ '(sch, td), Has sch db schema, Has td schema ('Typedef ('PGcomposite row))) => OidOfArray db ('PGcomposite row) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

OidOfArray db ('PGchar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

class OidOfNull (db :: SchemasType) (ty :: NullType) where #

The Oid of a NullType

Instances

Instances details
OidOf db pg => OidOfNull db (null pg) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

class OidOfField (db :: SchemasType) (field :: (Symbol, NullType)) where #

The Oid of a field

Instances

Instances details
OidOfNull db ty => OidOfField db (fld ::: ty) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

type family PG hask :: PGType #

Instances

Instances details
type PG Bool 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Bool = 'PGbool
type PG Char 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Char = 'PGchar 1
type PG Double 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Float 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Float = 'PGfloat4
type PG Int16 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Int16 = 'PGint2
type PG Int32 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Int32 = 'PGint4
type PG Int64 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Int64 = 'PGint8
type PG ByteString 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG ByteString 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Scientific 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG String 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG String = 'PGtext
type PG Text 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Text = 'PGtext
type PG UTCTime 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Value 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Value = 'PGjson
type PG Text 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Text = 'PGtext
type PG UUID 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG UUID = 'PGuuid
type PG Day 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Day = 'PGdate
type PG DiffTime 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG TimeOfDay 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG LocalTime 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Oid 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Oid = 'PGoid
type PG Money 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Money = 'PGmoney
type PG (NetAddr IP) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (NetAddr IP) = 'PGinet
type PG (Range hask) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Range

type PG (Range hask) = 'PGrange (PG hask)
type PG (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (Json hask) = 'PGjson
type PG (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (Jsonb hask) = 'PGjsonb
type PG (Composite hask) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (Composite hask) = 'PGcomposite (RowPG hask)
type PG (Enumerated hask) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (Enumerated hask) = 'PGenum (LabelsPG hask)
type PG (VarArray [x]) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (VarArray [x]) = 'PGvararray (NullPG x)
type PG (VarArray (Vector x)) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (VarArray (Vector x)) = 'PGvararray (NullPG x)
type PG (FixArray hask) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (FixArray hask) = 'PGfixarray (DimPG hask) (FixPG hask)
type PG (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (VarChar n) = 'PGvarchar n
type PG (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (FixChar n) = 'PGchar n
type PG (TimeOfDay, TimeZone) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

class IsPG hask #

The PG type family embeds a subset of Haskell types as Postgres types. As an open type family, PG is extensible.

>>> :kind! PG LocalTime
PG LocalTime :: PGType
= 'PGtimestamp

The preferred way to generate PGs of your own type is through generalized newtype deriving or via deriving.

>>> newtype UserId = UserId {getUserId :: UUID} deriving newtype IsPG
>>> :kind! PG UserId
PG UserId :: PGType
= 'PGuuid
>>> :{
data Answer = Yes | No
  deriving stock GHC.Generic
  deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
  deriving IsPG via Enumerated Answer
:}
>>> :kind! PG Answer
PG Answer :: PGType
= 'PGenum '["Yes", "No"]
>>> :{
data Complex = Complex {real :: Double, imaginary :: Double}
  deriving stock GHC.Generic
  deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
  deriving IsPG via Composite Complex
:}
>>> :kind! PG Complex
PG Complex :: PGType
= 'PGcomposite
    '["real" ::: 'NotNull 'PGfloat8,
      "imaginary" ::: 'NotNull 'PGfloat8]

Associated Types

type PG hask :: PGType #

Instances

Instances details
IsPG Bool

PGbool

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Bool :: PGType #

IsPG Char

PGchar 1

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Char :: PGType #

IsPG Double

PGfloat8

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Double :: PGType #

IsPG Float

PGfloat4

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Float :: PGType #

IsPG Int16

PGint2

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Int16 :: PGType #

IsPG Int32

PGint4

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Int32 :: PGType #

IsPG Int64

PGint8

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Int64 :: PGType #

IsPG ByteString

PGbytea

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG ByteString :: PGType #

IsPG ByteString

PGbytea

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG ByteString :: PGType #

IsPG Scientific

PGnumeric

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Scientific :: PGType #

IsPG String

PGtext

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG String :: PGType #

IsPG Text

PGtext

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Text :: PGType #

IsPG UTCTime

PGtimestamptz

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG UTCTime :: PGType #

IsPG Value

PGjson

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Value :: PGType #

IsPG Text

PGtext

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Text :: PGType #

IsPG UUID

PGuuid

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG UUID :: PGType #

IsPG Day

PGdate

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Day :: PGType #

IsPG DiffTime

PGinterval

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG DiffTime :: PGType #

IsPG TimeOfDay

PGtime

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG TimeOfDay :: PGType #

IsPG LocalTime

PGtimestamp

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG LocalTime :: PGType #

IsPG Oid

PGint2

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Oid :: PGType #

IsPG Money

PGmoney

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Money :: PGType #

IsPG (NetAddr IP)

PGinet

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (NetAddr IP) :: PGType #

IsPG hask => IsPG (Range hask)

PGrange (PG hask)

Instance details

Defined in Squeal.PostgreSQL.Expression.Range

Associated Types

type PG (Range hask) :: PGType #

IsPG (Json hask)

PGjson

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (Json hask) :: PGType #

IsPG (Jsonb hask)

PGjsonb

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (Jsonb hask) :: PGType #

IsPG (Composite hask)

PGcomposite (RowPG hask)

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (Composite hask) :: PGType #

IsPG (Enumerated hask)

PGenum (LabelsPG hask)

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (Enumerated hask) :: PGType #

IsPG (VarArray [x])

PGvararray (NullPG x)

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (VarArray [x]) :: PGType #

IsPG (VarArray (Vector x))

PGvararray (NullPG x)

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (VarArray (Vector x)) :: PGType #

IsPG (FixArray hask)

PGfixarray (DimPG hask) (FixPG hask)

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (FixArray hask) :: PGType #

IsPG (VarChar n)

PGvarchar

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (VarChar n) :: PGType #

IsPG (FixChar n)

PGvarchar

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (FixChar n) :: PGType #

IsPG (TimeOfDay, TimeZone)

PGtimetz

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (TimeOfDay, TimeZone) :: PGType #

type family LabelsPG hask :: [ConstructorName] where ... #

The LabelsPG type family calculates the constructors of a Haskell enum type.

>>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
>>> instance SOP.Generic Schwarma
>>> instance SOP.HasDatatypeInfo Schwarma
>>> :kind! LabelsPG Schwarma
LabelsPG Schwarma :: [Type.ConstructorName]
= '["Beef", "Lamb", "Chicken"]

type family RowPG hask :: RowType where ... #

RowPG turns a Haskell Type into a RowType.

RowPG may be applied to normal Haskell record types provided they have Generic and HasDatatypeInfo instances;

>>> data Person = Person { name :: Strict.Text, age :: Int32 } deriving GHC.Generic
>>> instance SOP.Generic Person
>>> instance SOP.HasDatatypeInfo Person
>>> :kind! RowPG Person
RowPG Person :: [(Symbol, NullType)]
= '["name" ::: 'NotNull 'PGtext, "age" ::: 'NotNull 'PGint4]

Equations

RowPG hask = RowOf (RecordCodeOf hask) 

type family RowOf (record :: [(Symbol, Type)]) :: RowType where ... #

RowOf applies NullPG to the fields of a list.

Equations

RowOf ((col ::: ty) ': record) = (col ::: NullPG ty) ': RowOf record 
RowOf ('[] :: [(Symbol, Type)]) = '[] :: [(Symbol, NullType)] 

type family NullPG hask :: NullType where ... #

NullPG turns a Haskell type into a NullType.

>>> :kind! NullPG Double
NullPG Double :: NullType
= 'NotNull 'PGfloat8
>>> :kind! NullPG (Maybe Double)
NullPG (Maybe Double) :: NullType
= 'Null 'PGfloat8

Equations

NullPG (Maybe hask) = 'Null (PG hask) 
NullPG hask = 'NotNull (PG hask) 

type family TuplePG hask :: [NullType] where ... #

TuplePG turns a Haskell tuple type (including record types) into the corresponding list of NullTypes.

>>> :kind! TuplePG (Double, Maybe Char)
TuplePG (Double, Maybe Char) :: [NullType]
= '[ 'NotNull 'PGfloat8, 'Null ('PGchar 1)]

Equations

TuplePG hask = TupleOf (TupleCodeOf hask (Code hask)) 

type family TupleOf (tuple :: [Type]) :: [NullType] where ... #

TupleOf turns a list of Haskell Types into a list of NullTypes.

Equations

TupleOf (hask ': tuple) = NullPG hask ': TupleOf tuple 
TupleOf ('[] :: [Type]) = '[] :: [NullType] 

type family TupleCodeOf hask (code :: [[Type]]) :: [Type] where ... #

TupleCodeOf takes the Code of a haskell Type and if it's a simple product returns it, otherwise giving a TypeError.

Equations

TupleCodeOf hask '[tuple] = tuple 
TupleCodeOf hask ('[] :: [[Type]]) = TypeError ((('Text "The type `" :<>: 'ShowType hask) :<>: 'Text "' is not a tuple type.") :$$: 'Text "It is a void type with no constructors.") :: [Type] 
TupleCodeOf hask (_1 ': (_2 ': _3)) = TypeError ((('Text "The type `" :<>: 'ShowType hask) :<>: 'Text "' is not a tuple type.") :$$: 'Text "It is a sum type with more than one constructor.") :: [Type] 

type family ConstructorsOf (datatype :: DatatypeInfo) :: [ConstructorInfo] where ... #

Calculates constructors of a datatype.

Equations

ConstructorsOf ('ADT _module _datatype constructors _strictness) = constructors 
ConstructorsOf ('Newtype _module _datatype constructor) = '[constructor] 

type family ConstructorNameOf (constructor :: ConstructorInfo) :: ConstructorName where ... #

Calculates the name of a nullary constructor, otherwise generates a type error.

Equations

ConstructorNameOf ('Constructor name) = name 
ConstructorNameOf ('Infix name _assoc _fix) = TypeError ('Text "ConstructorNameOf error: non-nullary constructor " :<>: 'Text name) :: ConstructorName 
ConstructorNameOf ('Record name _fields) = TypeError ('Text "ConstructorNameOf error: non-nullary constructor " :<>: 'Text name) :: ConstructorName 

type family ConstructorNamesOf (constructors :: [ConstructorInfo]) :: [ConstructorName] where ... #

Calculate the names of nullary constructors.

Equations

ConstructorNamesOf ('[] :: [ConstructorInfo]) = '[] :: [ConstructorName] 
ConstructorNamesOf (constructor ': constructors) = ConstructorNameOf constructor ': ConstructorNamesOf constructors 

type family DimPG hask :: [Nat] where ... #

DimPG turns Haskell nested homogeneous tuples into a list of lengths, up to a depth of 10 for each dimension.

Equations

DimPG (x, x) = 2 ': DimPG x 
DimPG (x, x, x) = 3 ': DimPG x 
DimPG (x, x, x, x) = 4 ': DimPG x 
DimPG (x, x, x, x, x) = 5 ': DimPG x 
DimPG (x, x, x, x, x, x) = 6 ': DimPG x 
DimPG (x, x, x, x, x, x, x) = 7 ': DimPG x 
DimPG (x, x, x, x, x, x, x, x) = 8 ': DimPG x 
DimPG (x, x, x, x, x, x, x, x, x) = 9 ': DimPG x 
DimPG (x, x, x, x, x, x, x, x, x, x) = 10 ': DimPG x 
DimPG x = '[] :: [Nat] 

type family FixPG hask :: NullType where ... #

FixPG extracts NullPG of the base type of nested homogeneous tuples, up to a depth of 10 for each dimension.

Equations

FixPG (x, x) = FixPG x 
FixPG (x, x, x) = FixPG x 
FixPG (x, x, x, x) = FixPG x 
FixPG (x, x, x, x, x) = FixPG x 
FixPG (x, x, x, x, x, x) = FixPG x 
FixPG (x, x, x, x, x, x, x) = FixPG x 
FixPG (x, x, x, x, x, x, x, x) = FixPG x 
FixPG (x, x, x, x, x, x, x, x, x) = FixPG x 
FixPG (x, x, x, x, x, x, x, x, x, x) = FixPG x 
FixPG (x, x, x, x, x, x, x, x, x, x, x) = FixPG x 
FixPG x = NullPG x 

data PGType #

PGType is the promoted datakind of PostgreSQL types.

>>> :kind 'PGbool
'PGbool :: PGType

Constructors

PGbool

logical Boolean (true/false)

PGint2

signed two-byte integer

PGint4

signed four-byte integer

PGint8

signed eight-byte integer

PGnumeric

arbitrary precision numeric type

PGfloat4

single precision floating-point number (4 bytes)

PGfloat8

double precision floating-point number (8 bytes)

PGmoney

currency amount

PGchar Nat

fixed-length character string

PGvarchar Nat

variable-length character string

PGtext

variable-length character string

PGbytea

binary data ("byte array")

PGtimestamp

date and time (no time zone)

PGtimestamptz

date and time, including time zone

PGdate

calendar date (year, month, day)

PGtime

time of day (no time zone)

PGtimetz

time of day, including time zone

PGinterval

time span

PGuuid

universally unique identifier

PGinet

IPv4 or IPv6 host address

PGjson

textual JSON data

PGjsonb

binary JSON data, decomposed

PGvararray NullType

variable length array

PGfixarray [Nat] NullType

fixed length array

PGenum [Symbol]

enumerated (enum) types are data types that comprise a static, ordered set of values.

PGcomposite RowType

a composite type represents the structure of a row or record; it is essentially just a list of field names and their data types.

PGtsvector

A tsvector value is a sorted list of distinct lexemes, which are words that have been normalized to merge different variants of the same word.

PGtsquery

A tsquery value stores lexemes that are to be searched for.

PGoid

Object identifiers (OIDs) are used internally by PostgreSQL as primary keys for various system tables.

PGrange PGType

Range types are data types representing a range of values of some element type (called the range's subtype).

UnsafePGType Symbol

an escape hatch for unsupported PostgreSQL types

Instances

Instances details
PGSubset 'PGtsquery 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 'PGtsquery) (null1 'PGtsquery) ('Null 'PGbool) #

(<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 'PGtsquery) (null1 'PGtsquery) ('Null 'PGbool) #

PGSubset 'PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 'PGjsonb) (null1 'PGjsonb) ('Null 'PGbool) #

(<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 'PGjsonb) (null1 'PGjsonb) ('Null 'PGbool) #

TimeOp 'PGinterval 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGinterval) (null 'PGinterval) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGinterval) (null 'PGinterval) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGinterval) (null 'PGinterval) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGinterval) (null 'PGinterval) #

TimeOp 'PGtimetz 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGtimetz) (null 'PGinterval) (null 'PGtimetz) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGtimetz) (null 'PGtimetz) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGtimetz) (null 'PGinterval) (null 'PGtimetz) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGtimetz) (null 'PGtimetz) (null 'PGinterval) #

TimeOp 'PGtime 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGtime) (null 'PGinterval) (null 'PGtime) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGtime) (null 'PGtime) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGtime) (null 'PGinterval) (null 'PGtime) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGtime) (null 'PGtime) (null 'PGinterval) #

TimeOp 'PGdate 'PGint4 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGdate) (null 'PGint4) (null 'PGdate) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGint4) (null 'PGdate) (null 'PGdate) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGdate) (null 'PGint4) (null 'PGdate) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGdate) (null 'PGdate) (null 'PGint4) #

TimeOp 'PGtimestamptz 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGtimestamptz) (null 'PGinterval) (null 'PGtimestamptz) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGtimestamptz) (null 'PGtimestamptz) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGtimestamptz) (null 'PGinterval) (null 'PGtimestamptz) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGtimestamptz) (null 'PGtimestamptz) (null 'PGinterval) #

TimeOp 'PGtimestamp 'PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: forall (null :: k -> NullType). Operator (null 'PGtimestamp) (null 'PGinterval) (null 'PGtimestamp) #

(+!) :: forall (null :: k -> NullType). Operator (null 'PGinterval) (null 'PGtimestamp) (null 'PGtimestamp) #

(!-) :: forall (null :: k -> NullType). Operator (null 'PGtimestamp) (null 'PGinterval) (null 'PGtimestamp) #

(!-!) :: forall (null :: k -> NullType). Operator (null 'PGtimestamp) (null 'PGtimestamp) (null 'PGinterval) #

PGSubset ('PGrange ty :: PGType) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGrange ty)) (null1 ('PGrange ty)) ('Null 'PGbool) #

(<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGrange ty)) (null1 ('PGrange ty)) ('Null 'PGbool) #

PGSubset ('PGvararray ty :: PGType) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGvararray ty)) (null1 ('PGvararray ty)) ('Null 'PGbool) #

(<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGvararray ty)) (null1 ('PGvararray ty)) ('Null 'PGbool) #

PGIntersect ('PGrange ty :: PGType) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@&&) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGrange ty)) (null1 ('PGrange ty)) ('Null 'PGbool) #

PGIntersect ('PGvararray ty :: PGType) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@&&) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGvararray ty)) (null1 ('PGvararray ty)) ('Null 'PGbool) #

data NullType #

NullType encodes the potential presence or definite absence of a NULL allowing operations which are sensitive to such to be well typed.

>>> :kind 'Null 'PGint4
'Null 'PGint4 :: NullType
>>> :kind 'NotNull ('PGvarchar 50)
'NotNull ('PGvarchar 50) :: NullType

Constructors

Null PGType

NULL may be present

NotNull PGType

NULL is absent

Instances

Instances details
Aggregate AggregateArg (Expression ('Grouped bys) :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) #

count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) #

sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGSum ty)) #

arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ('PGvararray ty)) #

jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjson) #

jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjsonb) #

bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) #

bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) #

boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) #

min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) #

avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGint8) #

regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

Aggregate (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (WindowFunction grp :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowFunction grp lat with db params from ('NotNull 'PGint8) #

count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('NotNull 'PGint8) #

sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGSum ty)) #

arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ('PGvararray ty)) #

jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjson) #

jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjsonb) #

bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) #

bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) #

boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) #

min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) #

avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGint8) #

regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

(Has tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsQualified tab col (NP (Expression 'Ungrouped lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression 'Ungrouped lat with db params from) tys #

(Has tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression 'Ungrouped lat with db params from)) columns #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsQualified tab col (NP (Expression ('Grouped bys) lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression ('Grouped bys) lat with db params from) tys #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns #

(Has tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression 'Ungrouped lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression 'Ungrouped lat with db params from) column #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression ('Grouped bys) lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression ('Grouped bys) lat with db params from) column #

FromValue ty (Maybe y) => IsLabel fld (MaybeT (DecodeRow ((fld ::: ty) ': row)) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: MaybeT (DecodeRow ((fld ::: ty) ': row)) y #

IsLabel fld (MaybeT (DecodeRow row) y) => IsLabel fld (MaybeT (DecodeRow (field ': row)) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: MaybeT (DecodeRow (field ': row)) y #

FromValue ty y => IsLabel fld (DecodeRow ((fld ::: ty) ': row) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: DecodeRow ((fld ::: ty) ': row) y #

IsLabel fld (DecodeRow row y) => IsLabel fld (DecodeRow (field ': row) y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromLabel :: DecodeRow (field ': row) y #

(HasUnique tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsLabel col (NP (Expression 'Ungrouped lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Expression 'Ungrouped lat with db params from) tys #

(HasUnique tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression 'Ungrouped lat with db params from)) columns #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsLabel col (NP (Expression ('Grouped bys) lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Expression ('Grouped bys) lat with db params from) tys #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns #

(HasUnique tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression 'Ungrouped lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Aliased (Expression 'Ungrouped lat with db params from) column #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression ('Grouped bys) lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Aliased (Expression ('Grouped bys) lat with db params from) column #

(KnownSymbol alias, NullTyped db ty) => FieldTyped db (alias ::: ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

fieldtype :: Aliased (TypeExpression db) (alias ::: ty) #

OidOfNull db ty => OidOfField db (fld ::: ty) 
Instance details

Defined in Squeal.PostgreSQL.Session.Oid

(fld0 ~ fld1, ToParam db ty x) => ToField db (fld0 ::: ty) (fld1 ::: x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toField :: P (fld1 ::: x) -> ReaderT (K Connection db) IO (K (Maybe Encoding) (fld0 ::: ty)) #

NullTyped db ('Null ty) => ColumnTyped db ('NoDef :=> 'Null ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

NullTyped db ('NotNull ty) => ColumnTyped db ('NoDef :=> 'NotNull ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

(KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (Path (CommonTableExpression statement db params) with with1) 
Instance details

Defined in Squeal.PostgreSQL.Query.With

Methods

as :: statement with db params common -> Alias cte -> Path (CommonTableExpression statement db params) with with1 #

JsonBuildObject ('[] :: [NullType]) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Json

Methods

jsonBuildObject :: forall (null :: PGType -> NullType). '[] ---> null 'PGjson #

jsonbBuildObject :: forall (null :: PGType -> NullType). '[] ---> null 'PGjsonb #

FilterWhere AggregateArg 'Ungrouped 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition 'Ungrouped lat with db params from -> AggregateArg xs lat with db params from -> AggregateArg xs lat with db params from #

FilterWhere (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) grp 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition grp lat with db params from -> WindowArg grp xs lat with db params from -> WindowArg grp xs lat with db params from #

Additional (FromClause lat with db params :: FromType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

Methods

also :: forall (ys :: [a]) (xs :: [a]). FromClause lat with db params ys -> FromClause lat with db params xs -> FromClause lat with db params (Join xs ys) #

Additional (Selection grp lat with db params from :: RowType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

also :: forall (ys :: [a]) (xs :: [a]). Selection grp lat with db params from ys -> Selection grp lat with db params from xs -> Selection grp lat with db params from (Join xs ys) #

(JsonBuildObject tys, In key PGJsonKey) => JsonBuildObject ('NotNull key ': (value ': tys)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Json

Methods

jsonBuildObject :: forall (null :: PGType -> NullType). ('NotNull key ': (value ': tys)) ---> null 'PGjson #

jsonbBuildObject :: forall (null :: PGType -> NullType). ('NotNull key ': (value ': tys)) ---> null 'PGjsonb #

(KnownSymbol alias, InlineParam x ty) => InlineField (alias ::: x) (alias ::: ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineField :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (alias ::: x) -> Aliased (Expression grp lat with db params from) (alias ::: ty) #

(KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: x) (col ::: ('NoDef :=> ty)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineColumn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (col ::: x) -> Aliased (Optional (Expression grp lat with db params from)) (col ::: ('NoDef :=> ty)) #

(KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: Optional I ('Def :=> x)) (col ::: ('Def :=> ty)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineColumn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (col ::: Optional I ('Def :=> x)) -> Aliased (Optional (Expression grp lat with db params from)) (col ::: ('Def :=> ty)) #

(FromValue ty y, fld0 ~ fld1) => FromField (fld0 ::: ty) (fld1 ::: y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

fromField :: Maybe ByteString -> Either Text (P (fld1 ::: y)) #

ty0 ~ ty1 => SamePGType (alias0 ::: (def0 :=> null0 ty0)) (alias1 ::: (def1 :=> null1 ty1)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

AddColumn ('NoDef :=> 'Null ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ('NoDef :=> 'Null ty) -> AlterTable sch tab db (constraints :=> Create column ('NoDef :=> 'Null ty) columns) #

AddColumn ('Def :=> ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ('Def :=> ty) -> AlterTable sch tab db (constraints :=> Create column ('Def :=> ty) columns) #

IsString (Selection grp lat with db params from '["fromOnly" ::: 'NotNull 'PGtext]) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

fromString :: String -> Selection grp lat with db params from '["fromOnly" ::: 'NotNull 'PGtext] #

type (:=>) (constraint :: k) (ty :: k1) = '(constraint, ty) infixr 7 #

The constraint operator, :=> is a type level pair between a "constraint" and some type, for use in pairing an Optionality with a NullType to produce a ColumnType or a TableConstraints and a ColumnsType to produce a TableType.

data Optionality #

Optionality encodes the availability of DEFAULT for inserts and updates. A column can be assigned a default value. A data Manipulation command can also request explicitly that a column be set to its default value, without having to know what that value is.

Constructors

Def

DEFAULT is available for inserts and updates

NoDef

DEFAULT is unavailable for inserts and updates

Instances

Instances details
NullTyped db ('Null ty) => ColumnTyped db ('NoDef :=> 'Null ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

NullTyped db ('NotNull ty) => ColumnTyped db ('NoDef :=> 'NotNull ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

(KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: x) (col ::: ('NoDef :=> ty)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineColumn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (col ::: x) -> Aliased (Optional (Expression grp lat with db params from)) (col ::: ('NoDef :=> ty)) #

(KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: Optional I ('Def :=> x)) (col ::: ('Def :=> ty)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inlineColumn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (col ::: Optional I ('Def :=> x)) -> Aliased (Optional (Expression grp lat with db params from)) (col ::: ('Def :=> ty)) #

ty0 ~ ty1 => SamePGType (alias0 ::: (def0 :=> null0 ty0)) (alias1 ::: (def1 :=> null1 ty1)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

AddColumn ('NoDef :=> 'Null ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ('NoDef :=> 'Null ty) -> AlterTable sch tab db (constraints :=> Create column ('NoDef :=> 'Null ty) columns) #

AddColumn ('Def :=> ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Table

Methods

addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ('Def :=> ty) -> AlterTable sch tab db (constraints :=> Create column ('Def :=> ty) columns) #

type ColumnType = (Optionality, NullType) #

ColumnType encodes the allowance of DEFAULT and NULL and the base PGType for a column.

>>> :set -XTypeFamilies -XTypeInType
>>> import GHC.TypeLits
>>> type family IdColumn :: ColumnType where IdColumn = 'Def :=> 'NotNull 'PGint4
>>> type family EmailColumn :: ColumnType where EmailColumn = 'NoDef :=> 'Null 'PGtext

type ColumnsType = [(Symbol, ColumnType)] #

ColumnsType is a row of ColumnTypes.

>>> :{
type family UsersColumns :: ColumnsType where
  UsersColumns =
    '[ "name" ::: 'NoDef :=> 'NotNull 'PGtext
     , "id"   :::   'Def :=> 'NotNull 'PGint4
     ]
:}

data TableConstraint #

TableConstraint encodes various forms of data constraints of columns in a table. TableConstraints give you as much control over the data in your tables as you wish. If a user attempts to store data in a column that would violate a constraint, an error is raised. This applies even if the value came from the default value definition.

type TableConstraints = [(Symbol, TableConstraint)] #

A TableConstraints is a row of TableConstraints.

>>> :{
type family UsersConstraints :: TableConstraints where
  UsersConstraints = '[ "pk_users" ::: 'PrimaryKey '["id"] ]
:}

type family Uniquely (key :: [Symbol]) (constraints :: TableConstraints) where ... #

A ForeignKey must reference columns that either are a PrimaryKey or form a Unique constraint.

Equations

Uniquely key ((uq ::: 'Unique key) ': constraints) = () 
Uniquely key ((pk ::: 'PrimaryKey key) ': constraints) = () 
Uniquely key (_1 ': constraints) = Uniquely key constraints 

type TableType = (TableConstraints, ColumnsType) #

TableType encodes a row of constraints on a table as well as the types of its columns.

>>> :{
type family UsersTable :: TableType where
  UsersTable =
    '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
    '[ "id"       :::   'Def :=> 'NotNull 'PGint4
     , "name"     ::: 'NoDef :=> 'NotNull 'PGtext
     ]
:}

type RowType = [(Symbol, NullType)] #

A RowType is a row of NullTypes. They correspond to Haskell record types by means of RowPG and are used in many places.

>>> :{
type family PersonRow :: RowType where
  PersonRow =
    '[ "name"        ::: 'NotNull 'PGtext
     , "age"         ::: 'NotNull 'PGint4
     , "dateOfBirth" :::    'Null 'PGdate
     ]
:}

type FromType = [(Symbol, RowType)] #

FromType is a row of RowTypes. It can be thought of as a product, or horizontal gluing and is used in FromClauses and TableExpressions.

type family ColumnsToRow (columns :: ColumnsType) :: RowType where ... #

ColumnsToRow removes column constraints.

Equations

ColumnsToRow ((column ::: (_1 :=> ty)) ': columns) = (column ::: ty) ': ColumnsToRow columns 
ColumnsToRow ('[] :: [(Symbol, ColumnType)]) = '[] :: [(Symbol, NullType)] 

type family TableToColumns (table :: TableType) :: ColumnsType where ... #

TableToColumns removes table constraints.

Equations

TableToColumns (constraints :=> columns) = columns 

type family TableToRow (table :: TableType) :: RowType where ... #

Convert a table to a row type.

Equations

TableToRow tab = ColumnsToRow (TableToColumns tab) 

type PGNum = '['PGint2, 'PGint4, 'PGint8, 'PGnumeric, 'PGfloat4, 'PGfloat8] #

Numeric Postgres types.

type PGFloating = '['PGfloat4, 'PGfloat8, 'PGnumeric] #

Floating Postgres types.

type PGIntegral = '['PGint2, 'PGint4, 'PGint8] #

Integral Postgres types.

class SamePGType (ty0 :: (Symbol, ColumnType)) (ty1 :: (Symbol, ColumnType)) #

Equality constraint on the underlying PGType of two columns.

Instances

Instances details
ty0 ~ ty1 => SamePGType (alias0 ::: (def0 :=> null0 ty0)) (alias1 ::: (def1 :=> null1 ty1)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

type family AllNotNull (columns :: ColumnsType) where ... #

AllNotNull is a constraint that proves a ColumnsType has no NULLs.

Equations

AllNotNull ((_1 ::: (_2 :=> 'NotNull _3)) ': columns) = AllNotNull columns 
AllNotNull ('[] :: [(Symbol, ColumnType)]) = () 

type family NotAllNull (columns :: ColumnsType) where ... #

NotAllNull is a constraint that proves a ColumnsType has some NOT NULL.

Equations

NotAllNull ((_1 ::: (_2 :=> 'NotNull _3)) ': _4) = () 
NotAllNull ((_1 ::: (_2 :=> 'Null _3)) ': columns) = NotAllNull columns 

type family NullifyType (ty :: NullType) :: NullType where ... #

NullifyType is an idempotent that nullifies a NullType.

Equations

NullifyType (null ty) = 'Null ty 

type family NullifyRow (columns :: RowType) :: RowType where ... #

NullifyRow is an idempotent that nullifies a RowType.

Equations

NullifyRow ((column ::: ty) ': columns) = (column ::: NullifyType ty) ': NullifyRow columns 
NullifyRow ('[] :: [(Symbol, NullType)]) = '[] :: [(Symbol, NullType)] 

type family NullifyFrom (tables :: FromType) :: FromType where ... #

NullifyFrom is an idempotent that nullifies a FromType used to nullify the left or right hand side of an outer join in a FromClause.

Equations

NullifyFrom ((table ::: columns) ': tables) = (table ::: NullifyRow columns) ': NullifyFrom tables 
NullifyFrom ('[] :: [(Symbol, RowType)]) = '[] :: [(Symbol, RowType)] 

type family Create (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Create alias x xs adds alias ::: x to the end of xs and is used in createTable statements and in ALTER TABLE addColumn.

Equations

Create alias (x :: k) ('[] :: [(Symbol, k)]) = '[alias ::: x] 
Create alias (x :: k) ((alias ::: y) ': xs :: [(Symbol, k)]) = TypeError (('Text "Create: alias " :<>: 'ShowType alias) :<>: 'Text "already exists") :: [(Symbol, k)] 
Create alias (y :: k) (x ': xs :: [(Symbol, k)]) = x ': Create alias y xs 

type family CreateIfNotExists (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Similar to Create but no error on pre-existence

Equations

CreateIfNotExists alias (x :: k) ('[] :: [(Symbol, k)]) = '[alias ::: x] 
CreateIfNotExists alias (x :: k) ((alias ::: y) ': xs :: [(Symbol, k)]) = (alias ::: y) ': xs 
CreateIfNotExists alias (y :: k) (x ': xs :: [(Symbol, k)]) = x ': CreateIfNotExists alias y xs 

type family CreateOrReplace (alias :: Symbol) (x :: t) (xs :: [(Symbol, t)]) :: [(Symbol, t)] where ... #

Similar to Create but used to replace values with the same type.

Equations

CreateOrReplace alias (x :: k) ('[] :: [(Symbol, k)]) = '[alias ::: x] 
CreateOrReplace alias (x :: k) ((alias ::: x) ': xs :: [(Symbol, k)]) = (alias ::: x) ': xs 
CreateOrReplace alias (x :: t) ((alias ::: y) ': xs :: [(Symbol, t)]) = TypeError ((((('Text "CreateOrReplace: expected type " :<>: 'ShowType x) :<>: 'Text " but alias ") :<>: 'ShowType alias) :<>: 'Text " has type ") :<>: 'ShowType y) :: [(Symbol, t)] 
CreateOrReplace alias (y :: t) (x ': xs :: [(Symbol, t)]) = x ': CreateOrReplace alias y xs 

type family Drop (alias :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Drop alias xs removes the type associated with alias in xs and is used in dropTable statements and in ALTER TABLE dropColumn statements.

Equations

Drop alias ('[] :: [(Symbol, k)]) = TypeError (('Text "Drop: alias " :<>: 'ShowType alias) :<>: 'Text " does not exist") :: [(Symbol, k)] 
Drop alias ((alias ::: x) ': xs :: [(Symbol, k)]) = xs 
Drop alias (x ': xs :: [(Symbol, k)]) = x ': Drop alias xs 

type family DropSchemum (alias :: Symbol) (sch :: k1 -> k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Drop a particular flavor of schemum type

Equations

DropSchemum alias (sch :: k1 -> k2) ('[] :: [(Symbol, k2)]) = TypeError (('Text "DropSchemum: alias " :<>: 'ShowType alias) :<>: 'Text " does not exist") :: [(Symbol, k2)] 
DropSchemum alias (sch :: k1 -> k2) ((alias ::: sch x) ': xs :: [(Symbol, k2)]) = xs 
DropSchemum alias (sch0 :: k1 -> k2) ((alias ::: sch1 x) ': xs :: [(Symbol, k2)]) = TypeError ((((('Text "DropSchemum: expected schemum " :<>: 'ShowType sch0) :<>: 'Text " but alias ") :<>: 'ShowType alias) :<>: 'Text " has schemum ") :<>: 'ShowType sch1) :: [(Symbol, k2)] 
DropSchemum alias (sch :: k1 -> k2) (x ': xs :: [(Symbol, k2)]) = x ': DropSchemum alias sch xs 

type family DropIfExists (alias :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Similar to Drop but no error on non-existence

Equations

DropIfExists alias ('[] :: [(Symbol, k)]) = '[] :: [(Symbol, k)] 
DropIfExists alias ((alias ::: x) ': xs :: [(Symbol, k)]) = xs 
DropIfExists alias (x ': xs :: [(Symbol, k)]) = x ': DropIfExists alias xs 

type family DropSchemumIfExists (alias :: Symbol) (sch :: k1 -> k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Similar to DropSchemum but no error on non-existence

Equations

DropSchemumIfExists alias (sch :: k1 -> k2) ('[] :: [(Symbol, k2)]) = '[] :: [(Symbol, k2)] 
DropSchemumIfExists alias (sch :: k1 -> k2) ((alias ::: sch x) ': xs :: [(Symbol, k2)]) = xs 
DropSchemumIfExists alias (sch0 :: k1 -> k2) ((alias ::: sch1 x) ': xs :: [(Symbol, k2)]) = TypeError ((((('Text "DropSchemumIfExists: expected schemum " :<>: 'ShowType sch1) :<>: 'Text " but alias ") :<>: 'ShowType alias) :<>: 'Text " has schemum ") :<>: 'ShowType sch0) :: [(Symbol, k2)] 
DropSchemumIfExists alias (sch :: k1 -> k2) (x ': xs :: [(Symbol, k2)]) = x ': DropSchemumIfExists alias sch xs 

type family Alter (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Alter alias x xs replaces the type associated with an alias in xs with the type x and is used in alterTable and alterColumn.

Equations

Alter alias (x :: k) ('[] :: [(Symbol, k)]) = TypeError (('Text "Alter: alias " :<>: 'ShowType alias) :<>: 'Text " does not exist") :: [(Symbol, k)] 
Alter alias (x1 :: k) ((alias ::: x0) ': xs :: [(Symbol, k)]) = (alias ::: x1) ': xs 
Alter alias (x1 :: k) (x0 ': xs :: [(Symbol, k)]) = x0 ': Alter alias x1 xs 

type family AlterIfExists (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Similar to Alter but no error on non-existence

Equations

AlterIfExists alias (x :: k) ('[] :: [(Symbol, k)]) = '[] :: [(Symbol, k)] 
AlterIfExists alias (x1 :: k) ((alias ::: x0) ': xs :: [(Symbol, k)]) = (alias ::: x1) ': xs 
AlterIfExists alias (x1 :: k) (x0 ': xs :: [(Symbol, k)]) = x0 ': AlterIfExists alias x1 xs 

type family Rename (alias0 :: Symbol) (alias1 :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Rename alias0 alias1 xs replaces the alias alias0 by alias1 in xs and is used in alterTableRename and renameColumn.

Equations

Rename alias0 alias1 ('[] :: [(Symbol, k)]) = TypeError (('Text "Rename: alias " :<>: 'ShowType alias0) :<>: 'Text " does not exist") :: [(Symbol, k)] 
Rename alias0 alias1 ((alias0 ::: x0) ': xs :: [(Symbol, k)]) = (alias1 ::: x0) ': xs 
Rename alias0 alias1 (x ': xs :: [(Symbol, k)]) = x ': Rename alias0 alias1 xs 

type family RenameIfExists (alias0 :: Symbol) (alias1 :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Similar to Rename but no error on non-existence

Equations

RenameIfExists alias x ('[] :: [(Symbol, k)]) = '[] :: [(Symbol, k)] 
RenameIfExists alias0 alias1 ((alias0 ::: x0) ': xs :: [(Symbol, k)]) = (alias1 ::: x0) ': xs 
RenameIfExists alias0 alias1 (x ': xs :: [(Symbol, k)]) = x ': RenameIfExists alias0 alias1 xs 

type family SetSchema (sch0 :: Symbol) (sch1 :: Symbol) (schema0 :: [(Symbol, k)]) (schema1 :: [(Symbol, k)]) (obj :: Symbol) (srt :: k1 -> k) (ty :: k1) (db :: [(Symbol, [(Symbol, k)])]) :: [(Symbol, [(Symbol, k)])] where ... #

Move an object from one schema to another

Equations

SetSchema sch0 sch1 (schema0 :: [(Symbol, k1)]) (schema1 :: [(Symbol, k1)]) obj (srt :: k2 -> k1) (ty :: k2) (db :: [(Symbol, [(Symbol, k1)])]) = Alter sch1 (Create obj (srt ty) schema1) (Alter sch0 (DropSchemum obj srt schema0) db) 

type family ConstraintInvolves (column :: Symbol) (constraint :: TableConstraint) :: Bool where ... #

Check if a TableConstraint involves a column

Equations

ConstraintInvolves column ('Check columns) = Elem column columns 
ConstraintInvolves column ('Unique columns) = Elem column columns 
ConstraintInvolves column ('PrimaryKey columns) = Elem column columns 
ConstraintInvolves column ('ForeignKey columns sch tab refcolumns) = Elem column columns 

type family DropIfConstraintsInvolve (column :: Symbol) (constraints :: [(Symbol, TableConstraint)]) :: [(Symbol, TableConstraint)] where ... #

Drop all TableConstraints that involve a column

Equations

DropIfConstraintsInvolve column ('[] :: [(Symbol, TableConstraint)]) = '[] :: [(Symbol, TableConstraint)] 
DropIfConstraintsInvolve column ((alias ::: constraint) ': constraints) = If (ConstraintInvolves column constraint) (DropIfConstraintsInvolve column constraints) ((alias ::: constraint) ': DropIfConstraintsInvolve column constraints) 

data SchemumType #

A SchemumType is a user-created type, like a Table, View or Typedef.

Instances

Instances details
Category Definition 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

id :: forall (a :: k). Definition a a #

(.) :: forall (b :: k) (c :: k) (a :: k). Definition b c -> Definition a b -> Definition a c #

IndexedMonadTrans PQ 
Instance details

Defined in Squeal.PostgreSQL.Session

Methods

pqAp :: forall (m :: Type -> Type) (i :: k) (j :: k) x y (k1 :: k). Monad m => PQ i j m (x -> y) -> PQ j k1 m x -> PQ i k1 m y #

pqJoin :: forall (m :: Type -> Type) (i :: k) (j :: k) (k1 :: k) y. Monad m => PQ i j m (PQ j k1 m y) -> PQ i k1 m y #

pqBind :: forall (m :: Type -> Type) x (j :: k) (k1 :: k) y (i :: k). Monad m => (x -> PQ j k1 m y) -> PQ i j m x -> PQ i k1 m y #

pqThen :: forall (m :: Type -> Type) (j :: k) (k1 :: k) y (i :: k) x. Monad m => PQ j k1 m y -> PQ i j m x -> PQ i k1 m y #

pqAndThen :: forall (m :: Type -> Type) y (j :: k) (k1 :: k) z x (i :: k). Monad m => (y -> PQ j k1 m z) -> (x -> PQ i j m y) -> x -> PQ i k1 m z #

Aggregate AggregateArg (Expression ('Grouped bys) :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) #

count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) #

sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGSum ty)) #

arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ('PGvararray ty)) #

jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjson) #

jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjsonb) #

bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) #

bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) #

boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) #

max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) #

min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) #

avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGint8) #

regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) #

stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) #

Aggregate (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (WindowFunction grp :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowFunction grp lat with db params from ('NotNull 'PGint8) #

count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('NotNull 'PGint8) #

sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGSum ty)) #

arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ('PGvararray ty)) #

jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjson) #

jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjsonb) #

bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) #

bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) #

boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) #

max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) #

min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) #

avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGint8) #

regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) #

stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) #

Migratory Definition (Indexed PQ IO ())

pure migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration Definition) db0 db1 -> Indexed PQ IO () db0 db1 #

Migratory (IsoQ (Indexed PQ IO ())) (IsoQ (Indexed PQ IO ()))

impure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ (Indexed PQ IO ()))) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

Migratory (IsoQ Definition) (IsoQ (Indexed PQ IO ()))

pure rewindable migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ Definition)) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 #

Migratory (OpQ (Indexed PQ IO ())) (OpQ (Indexed PQ IO ()))

impure rewinds

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ (Indexed PQ IO ()))) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 #

Migratory (OpQ Definition) (OpQ (Indexed PQ IO ()))

pure rewinds

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ Definition)) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 #

Migratory (Indexed PQ IO ()) (Indexed PQ IO ())

impure migrations

Instance details

Defined in Squeal.PostgreSQL.Session.Migration

Methods

runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (Indexed PQ IO ())) db0 db1 -> Indexed PQ IO () db0 db1 #

type FunctionType = ([NullType], ReturnsType) #

Use :=> to pair the parameter types with the return type of a function.

>>> :{
type family Fn :: FunctionType where
  Fn = '[ 'NotNull 'PGint4] :=> 'Returns ('NotNull 'PGint4)
:}

data IndexType #

PostgreSQL provides several index types: B-tree, Hash, GiST, SP-GiST, GIN and BRIN. Each index type uses a different algorithm that is best suited to different types of queries.

Constructors

Btree

B-trees can handle equality and range queries on data that can be sorted into some ordering.

Hash

Hash indexes can only handle simple equality comparisons.

Gist

GiST indexes are not a single kind of index, but rather an infrastructure within which many different indexing strategies can be implemented.

Spgist

SP-GiST indexes, like GiST indexes, offer an infrastructure that supports various kinds of searches.

Gin

GIN indexes are “inverted indexes” which are appropriate for data values that contain multiple component values, such as arrays.

Brin

BRIN indexes (a shorthand for Block Range INdexes) store summaries about the values stored in consecutive physical block ranges of a table.

data ReturnsType #

Return type of a function

Constructors

Returns NullType

function

ReturnsTable RowType

set returning function

type SchemaType = [(Symbol, SchemumType)] #

A schema of a database consists of a list of aliased, user-defined SchemumTypes.

>>> :{
type family Schema :: SchemaType where
  Schema =
    '[ "users" ::: 'Table (
        '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
        '[ "id"   :::   'Def :=> 'NotNull 'PGint4
        , "name" ::: 'NoDef :=> 'NotNull 'PGtext
        ])
    , "emails" ::: 'Table (
        '[ "pk_emails"  ::: 'PrimaryKey '["id"]
        , "fk_user_id" ::: 'ForeignKey '["user_id"] "public" "users" '["id"]
        ] :=>
        '[ "id"      :::   'Def :=> 'NotNull 'PGint4
        , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
        , "email"   ::: 'NoDef :=>    'Null 'PGtext
        ])
    ]
:}

type SchemasType = [(Symbol, SchemaType)] #

A database contains one or more named schemas, which in turn contain tables. The same object name can be used in different schemas without conflict; for example, both schema1 and myschema can contain tables named mytable. Unlike databases, schemas are not rigidly separated: a user can access objects in any of the schemas in the database they are connected to, if they have privileges to do so.

There are several reasons why one might want to use schemas:

  • To allow many users to use one database without interfering with each other.
  • To organize database objects into logical groups to make them more manageable.
  • Third-party applications can be put into separate schemas so they do not collide with the names of other objects.

type family Public (schema :: SchemaType) :: SchemasType where ... #

A type family to use for a single schema database.

Equations

Public schema = '["public" ::: schema] 

class IsPGlabel (label :: Symbol) expr where #

IsPGlabel looks very much like the IsLabel class. Whereas the overloaded label, fromLabel is used for column references, labels are used for enum terms. A label is called with type application like label @"beef".

Methods

label :: expr #

Instances

Instances details
label ~ label1 => IsPGlabel label (PGlabel label1) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

label :: PGlabel label1 #

IsPGlabel label (y -> K y label) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

label :: y -> K y label #

IsPGlabel label (y -> NP (K y :: Symbol -> Type) '[label]) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

label :: y -> NP (K y) '[label] #

labels ~ '[label] => IsPGlabel label (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

label :: NP PGlabel labels #

(KnownSymbol label, In label labels) => IsPGlabel label (Expression grp lat with db params from (null ('PGenum labels))) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

label :: Expression grp lat with db params from (null ('PGenum labels)) #

data PGlabel (label :: Symbol) #

A PGlabel unit type with an IsPGlabel instance

Constructors

PGlabel 

Instances

Instances details
label ~ label1 => IsPGlabel label (PGlabel label1) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

label :: PGlabel label1 #

labels ~ '[label] => IsPGlabel label (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

label :: NP PGlabel labels #

KnownSymbol label => RenderSQL (PGlabel label) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

renderSQL :: PGlabel label -> ByteString #

All KnownSymbol labels => RenderSQL (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

renderSQL :: NP PGlabel labels -> ByteString #

type PGJsonKey = '['PGint2, 'PGint4, 'PGtext] #

Is a type a valid JSON key?

type PGJsonType = '['PGjson, 'PGjsonb] #

Is a type a valid JSON type?

class IsNotElem (x :: k) (isElem :: k1) #

Utility class for AllUnique to provide nicer error messages.

Instances

Instances details
IsNotElem (x :: k) 'False 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

(TypeError (('Text "Cannot assign to " :<>: 'ShowType alias) :<>: 'Text " more than once") :: Constraint) => IsNotElem ('(alias, a) :: (k1, k2)) 'True 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

class AllUnique (xs :: [(Symbol, a)]) #

No elem of xs appears more than once, in the context of assignment.

Instances

Instances details
AllUnique ('[] :: [(Symbol, a)]) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

(IsNotElem x (Elem x xs), AllUnique xs) => AllUnique (x ': xs :: [(Symbol, a)]) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

type Updatable (table :: TableType) (columns :: [(Symbol, a)]) = (All (HasIn (TableToColumns table) :: (Symbol, a) -> Constraint) columns, AllUnique columns, SListI (TableToColumns table)) #

Updatable lists of columns

type family UserTypeName (schema :: SchemaType) (ty :: PGType) :: Maybe Symbol where ... #

Calculate the name of a user defined type.

Equations

UserTypeName ('[] :: [(Symbol, SchemumType)]) ty = 'Nothing :: Maybe Symbol 
UserTypeName ((td ::: 'Typedef ty) ': _1) ty = 'Just td 
UserTypeName (_1 ': schema) ty = UserTypeName schema ty 

type family UserTypeNamespace (sch :: Symbol) (td :: Maybe Symbol) (schemas :: SchemasType) (ty :: PGType) :: (Symbol, Symbol) where ... #

Helper to calculate the schema of a user defined type.

Equations

UserTypeNamespace sch ('Nothing :: Maybe Symbol) schemas ty = UserType schemas ty 
UserTypeNamespace sch ('Just td) schemas ty = '(sch, td) 

type family UserType (db :: SchemasType) (ty :: PGType) :: (Symbol, Symbol) where ... #

Calculate the schema and name of a user defined type.

Equations

UserType ('[] :: [(Symbol, SchemaType)]) ty = TypeError ('Text "No such user type: " :<>: 'ShowType ty) :: (Symbol, Symbol) 
UserType ((sch ::: schema) ': schemas) ty = UserTypeNamespace sch (UserTypeName schema ty) schemas ty 

mapAliased :: forall k expr (x :: k) (y :: k) (alias :: Symbol). (expr x -> expr y) -> Aliased expr (alias ::: x) -> Aliased expr (alias ::: y) #

Map a function over an Aliased expression.

renderAliased :: forall k expression (aliased :: (Symbol, k)). (forall (ty :: k). expression ty -> ByteString) -> Aliased expression aliased -> ByteString #

>>> let renderMaybe = fromString . maybe "Nothing" (const "Just")
>>> renderAliased renderMaybe (Just (3::Int) `As` #an_int)
"Just AS \"an_int\""

type (:::) (alias :: Symbol) (ty :: k) = '(alias, ty) infixr 6 #

The alias operator ::: is like a promoted version of As, a type level pair between an alias and some type.

data Grouping #

Grouping is an auxiliary namespace, created by GROUP BY clauses (groupBy), and used for typesafe aggregation

Constructors

Ungrouped

no aggregation permitted

Grouped [(Symbol, Symbol)]

aggregation required for any column which is not grouped

class (KnownSymbol table, KnownSymbol column) => GroupedBy (table :: Symbol) (column :: Symbol) (bys :: k) #

A GroupedBy constraint indicates that a table qualified column is a member of the auxiliary namespace created by GROUP BY clauses and thus, may be called in an output Expression without aggregating.

Instances

Instances details
(KnownSymbol table, KnownSymbol column) => GroupedBy table column ('(table, column) ': bys :: [(Symbol, Symbol)]) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

(KnownSymbol table, KnownSymbol column, GroupedBy table column bys) => GroupedBy table column (tabcol ': bys :: [a]) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

data Alias (alias :: Symbol) #

Aliases are proxies for a type level string or Symbol and have an IsLabel instance so that with -XOverloadedLabels

>>> :set -XOverloadedLabels
>>> #foobar :: Alias "foobar"
Alias

Constructors

Alias 

Instances

Instances details
IsQualified qualifier alias (Alias qualifier, Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias qualifier -> Alias alias -> (Alias qualifier, Alias alias) #

alias1 ~ alias2 => IsLabel alias1 (Alias alias2) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: Alias alias2 #

aliases ~ '[alias] => IsLabel alias (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: NP Alias aliases #

(alias0 ~ alias1, alias0 ~ alias2, KnownSymbol alias2) => IsLabel alias0 (Aliased Alias (alias1 ::: alias2)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: Aliased Alias (alias1 ::: alias2) #

Eq (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(==) :: Alias alias -> Alias alias -> Bool #

(/=) :: Alias alias -> Alias alias -> Bool #

Ord (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

compare :: Alias alias -> Alias alias -> Ordering #

(<) :: Alias alias -> Alias alias -> Bool #

(<=) :: Alias alias -> Alias alias -> Bool #

(>) :: Alias alias -> Alias alias -> Bool #

(>=) :: Alias alias -> Alias alias -> Bool #

max :: Alias alias -> Alias alias -> Alias alias #

min :: Alias alias -> Alias alias -> Alias alias #

Show (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

showsPrec :: Int -> Alias alias -> ShowS #

show :: Alias alias -> String #

showList :: [Alias alias] -> ShowS #

Generic (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Associated Types

type Rep (Alias alias) :: Type -> Type #

Methods

from :: Alias alias -> Rep (Alias alias) x #

to :: Rep (Alias alias) x -> Alias alias #

NFData (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

rnf :: Alias alias -> () #

KnownSymbol alias => RenderSQL (Alias alias)
>>> printSQL (#jimbob :: Alias "jimbob")
"jimbob"
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

renderSQL :: Alias alias -> ByteString #

All KnownSymbol aliases => RenderSQL (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

renderSQL :: NP Alias aliases -> ByteString #

type Rep (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

type Rep (Alias alias) = D1 ('MetaData "Alias" "Squeal.PostgreSQL.Type.Alias" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) (C1 ('MetaCons "Alias" 'PrefixI 'False) (U1 :: Type -> Type))

data Aliased (expression :: k -> Type) (aliased :: (Symbol, k)) where #

The As operator is used to name an expression. As is like a demoted version of :::.

>>> Just "hello" `As` #hi :: Aliased Maybe ("hi" ::: String)
As (Just "hello") Alias

Constructors

As :: forall k (alias :: Symbol) (expression :: k -> Type) (ty :: k). KnownSymbol alias => expression ty -> Alias alias -> Aliased expression '(alias, ty) 

Instances

Instances details
(Has tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression 'Ungrouped lat with db params from)) columns #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns #

(Has tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression 'Ungrouped lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression 'Ungrouped lat with db params from) column #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression ('Grouped bys) lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression ('Grouped bys) lat with db params from) column #

(q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias q0 -> Alias a0 -> Aliased (QualifiedAlias q1) (a1 ::: a2) #

(KnownSymbol alias, tys ~ '[alias ::: ty]) => Aliasable alias (expression ty) (NP (Aliased expression) tys) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

as :: expression ty -> Alias alias -> NP (Aliased expression) tys #

(KnownSymbol alias, aliased ~ (alias ::: ty)) => Aliasable alias (expression ty) (Aliased expression aliased) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

as :: expression ty -> Alias alias -> Aliased expression aliased #

(HasUnique tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression 'Ungrouped lat with db params from)) columns #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns #

(HasUnique tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression 'Ungrouped lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Aliased (Expression 'Ungrouped lat with db params from) column #

(HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression ('Grouped bys) lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Aliased (Expression ('Grouped bys) lat with db params from) column #

(alias0 ~ alias1, alias0 ~ alias2, KnownSymbol alias2) => IsLabel alias0 (Aliased Alias (alias1 ::: alias2)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: Aliased Alias (alias1 ::: alias2) #

(q ~ "public", a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsLabel a0 (Aliased (QualifiedAlias q) (a1 ::: a2)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: Aliased (QualifiedAlias q) (a1 ::: a2) #

Eq (expression ty) => Eq (Aliased expression (alias ::: ty)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(==) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool #

(/=) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool #

Ord (expression ty) => Ord (Aliased expression (alias ::: ty)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

compare :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Ordering #

(<) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool #

(<=) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool #

(>) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool #

(>=) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool #

max :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) #

min :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) #

Show (expression ty) => Show (Aliased expression (alias ::: ty)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

showsPrec :: Int -> Aliased expression (alias ::: ty) -> ShowS #

show :: Aliased expression (alias ::: ty) -> String #

showList :: [Aliased expression (alias ::: ty)] -> ShowS #

class KnownSymbol alias => Aliasable (alias :: Symbol) expression aliased | aliased -> expression, aliased -> alias where #

The Aliasable class provides a way to scrap your Nils in an NP list of Aliased expressions.

Methods

as :: expression -> Alias alias -> aliased #

Instances

Instances details
(KnownSymbol alias, tys ~ '[alias ::: ty]) => Aliasable alias (expression ty) (NP (Aliased expression) tys) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

as :: expression ty -> Alias alias -> NP (Aliased expression) tys #

(KnownSymbol alias, aliased ~ (alias ::: ty)) => Aliasable alias (expression ty) (Aliased expression aliased) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

as :: expression ty -> Alias alias -> Aliased expression aliased #

(KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (Path (CommonTableExpression statement db params) with with1) 
Instance details

Defined in Squeal.PostgreSQL.Query.With

Methods

as :: statement with db params common -> Alias cte -> Path (CommonTableExpression statement db params) with with1 #

(KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (CommonTableExpression statement db params with with1) 
Instance details

Defined in Squeal.PostgreSQL.Query.With

Methods

as :: statement with db params common -> Alias cte -> CommonTableExpression statement db params with with1 #

(KnownSymbol col, row ~ '[col ::: ty]) => Aliasable col (Expression grp lat with db params from ty) (Selection grp lat with db params from row) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

as :: Expression grp lat with db params from ty -> Alias col -> Selection grp lat with db params from row #

type HasUnique (alias :: Symbol) (fields :: [(Symbol, k)]) (field :: k) = fields ~ '[alias ::: field] #

HasUnique alias fields field is a constraint that proves that fields is a singleton of alias ::: field.

type Has (alias :: Symbol) (fields :: [(Symbol, kind)]) (field :: kind) = HasErr fields alias fields field #

Has alias fields field is a constraint that proves that fields has a field of alias ::: field, inferring field from alias and fields.

class KnownSymbol alias => HasErr (err :: k) (alias :: Symbol) (fields :: [(Symbol, kind)]) (field :: kind) | alias fields -> field #

HasErr is like Has except it also retains the original list of fields being searched, so that error messages are more useful.

Instances

Instances details
(KnownSymbol alias, field0 ~ field1) => HasErr (err :: k) alias ((alias ::: field0) ': fields :: [(Symbol, kind)]) (field1 :: kind) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

(KnownSymbol alias, HasErr err alias fields field) => HasErr (err :: k) alias (field' ': fields :: [(Symbol, kind)]) (field :: kind) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

class HasIn (fields :: k) (field :: k1) #

HasIn fields (alias ::: field) is a constraint that proves that fields has a field of alias ::: field. It is used in UPDATEs to choose which subfields to update.

Instances

Instances details
Has alias fields field => HasIn (fields :: [(Symbol, k)]) (alias ::: field :: (Symbol, k)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

class All KnownSymbol aliases => HasAll (aliases :: [Symbol]) (fields :: [(Symbol, kind)]) (subfields :: [(Symbol, kind)]) | aliases fields -> subfields #

HasAll extends Has to take lists of aliases and fields and infer a list of subfields.

Instances

Instances details
HasAll ('[] :: [Symbol]) (fields :: [(Symbol, kind)]) ('[] :: [(Symbol, kind)]) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

(Has alias fields field, HasAll aliases fields subfields) => HasAll (alias ': aliases) (fields :: [(Symbol, k)]) ((alias ::: field) ': subfields :: [(Symbol, k)]) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

class IsQualified (qualifier :: Symbol) (alias :: Symbol) expression where #

Analagous to IsLabel, the constraint IsQualified defines ! for a column alias qualified by a table alias.

Methods

(!) :: Alias qualifier -> Alias alias -> expression infixl 9 #

Instances

Instances details
(Has rel rels cols, Has col cols ty, by ~ '(rel, col)) => IsQualified rel col (By rels by) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

(!) :: Alias rel -> Alias col -> By rels by #

IsQualified qualifier alias (Alias qualifier, Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias qualifier -> Alias alias -> (Alias qualifier, Alias alias) #

(q ~ q', a ~ a') => IsQualified q a (QualifiedAlias q' a') 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias q -> Alias a -> QualifiedAlias q' a' #

(Has rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsQualified rel col (NP (By rels) bys) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

(!) :: Alias rel -> Alias col -> NP (By rels) bys #

(Has tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsQualified tab col (NP (Expression 'Ungrouped lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression 'Ungrouped lat with db params from) tys #

(Has tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression 'Ungrouped lat with db params from)) columns #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsQualified tab col (NP (Expression ('Grouped bys) lat with db params from) tys) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression ('Grouped bys) lat with db params from) tys #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns #

(Has tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression 'Ungrouped lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression 'Ungrouped lat with db params from) column #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression ('Grouped bys) lat with db params from) column) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression ('Grouped bys) lat with db params from) column #

(q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias q0 -> Alias a0 -> Aliased (QualifiedAlias q1) (a1 ::: a2) #

(Has tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty]) => IsQualified tab col (Selection 'Ungrouped lat with db params from row1) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

(!) :: Alias tab -> Alias col -> Selection 'Ungrouped lat with db params from row1 #

(Has tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty], GroupedBy tab col bys) => IsQualified tab col (Selection ('Grouped bys) lat with db params from row1) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

(!) :: Alias tab -> Alias col -> Selection ('Grouped bys) lat with db params from row1 #

(Has tab (Join from lat) row, Has col row ty) => IsQualified tab col (Expression 'Ungrouped lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Expression 'Ungrouped lat with db params from ty #

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys) => IsQualified tab col (Expression ('Grouped bys) lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Expression ('Grouped bys) lat with db params from ty #

data QualifiedAlias (qualifier :: Symbol) (alias :: Symbol) #

QualifiedAliases enables multi-schema support by allowing a reference to a Table, Typedef or View to be qualified by their schemas. By default, a qualifier of public is provided.

>>> :{
let
  alias1 :: QualifiedAlias "sch" "tab"
  alias1 = #sch ! #tab
  alias2 :: QualifiedAlias "public" "vw"
  alias2 = #vw
in printSQL alias1 >> printSQL alias2
:}
"sch"."tab"
"vw"

Constructors

QualifiedAlias 

Instances

Instances details
(q ~ q', a ~ a') => IsQualified q a (QualifiedAlias q' a') 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias q -> Alias a -> QualifiedAlias q' a' #

(q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias q0 -> Alias a0 -> Aliased (QualifiedAlias q1) (a1 ::: a2) #

(q' ~ "public", a ~ a') => IsLabel a (QualifiedAlias q' a') 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: QualifiedAlias q' a' #

(q ~ "public", a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsLabel a0 (Aliased (QualifiedAlias q) (a1 ::: a2)) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: Aliased (QualifiedAlias q) (a1 ::: a2) #

Eq (QualifiedAlias qualifier alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(==) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool #

(/=) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool #

Ord (QualifiedAlias qualifier alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

compare :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Ordering #

(<) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool #

(<=) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool #

(>) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool #

(>=) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool #

max :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias #

min :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias #

Show (QualifiedAlias qualifier alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

showsPrec :: Int -> QualifiedAlias qualifier alias -> ShowS #

show :: QualifiedAlias qualifier alias -> String #

showList :: [QualifiedAlias qualifier alias] -> ShowS #

Generic (QualifiedAlias qualifier alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Associated Types

type Rep (QualifiedAlias qualifier alias) :: Type -> Type #

Methods

from :: QualifiedAlias qualifier alias -> Rep (QualifiedAlias qualifier alias) x #

to :: Rep (QualifiedAlias qualifier alias) x -> QualifiedAlias qualifier alias #

NFData (QualifiedAlias qualifier alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

rnf :: QualifiedAlias qualifier alias -> () #

(KnownSymbol q, KnownSymbol a) => RenderSQL (QualifiedAlias q a) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

type Rep (QualifiedAlias qualifier alias) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

type Rep (QualifiedAlias qualifier alias) = D1 ('MetaData "QualifiedAlias" "Squeal.PostgreSQL.Type.Alias" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'False) (C1 ('MetaCons "QualifiedAlias" 'PrefixI 'False) (U1 :: Type -> Type))

one :: forall k f (x :: k). f x -> NP f '[x] #

A list of length one.

(*:) :: forall k f (x :: k) (y :: k). f x -> f y -> NP f '[x, y] infixl 8 #

A useful operator for ending an NP list of length at least 2 without Nil

disjoin :: forall k (xs :: [k]) (ys :: [k]) (expr :: k -> Type). SListI xs => NP expr (Join xs ys) -> (NP expr xs, NP expr ys) #

disjoin is a utility function for splitting an NP list into pieces.

type family Join (xs :: [a]) (ys :: [a]) :: [a] where ... #

Join is simply promoted ++ and is used in JOINs in FromClauses.

Equations

Join ('[] :: [a]) (ys :: [a]) = ys 
Join (x ': xs :: [a]) (ys :: [a]) = x ': Join xs ys 

class Additional (expr :: [a] -> Type) where #

The Additional class is for appending type-level list parameterized constructors such as NP, Selection, and FromClause.

Methods

also :: forall (ys :: [a]) (xs :: [a]). expr ys -> expr xs -> expr (Join xs ys) #

Instances

Instances details
Additional (NP expr :: [a] -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Type.List

Methods

also :: forall (ys :: [a0]) (xs :: [a0]). NP expr ys -> NP expr xs -> NP expr (Join xs ys) #

Additional (FromClause lat with db params :: FromType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

Methods

also :: forall (ys :: [a]) (xs :: [a]). FromClause lat with db params ys -> FromClause lat with db params xs -> FromClause lat with db params (Join xs ys) #

Additional (Selection grp lat with db params from :: RowType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

also :: forall (ys :: [a]) (xs :: [a]). Selection grp lat with db params from ys -> Selection grp lat with db params from xs -> Selection grp lat with db params from (Join xs ys) #

type family Elem (x :: k) (xs :: [k]) :: Bool where ... #

Elem is a promoted elem.

Equations

Elem (x :: k) ('[] :: [k]) = 'False 
Elem (x :: a) (x ': _1 :: [a]) = 'True 
Elem (x :: k) (_1 ': xs :: [k]) = Elem x xs 

type family In (x :: t) (xs :: [t]) where ... #

In x xs is a constraint that proves that x is in xs.

Equations

In (x :: t) (xs :: [t]) = If (Elem x xs) () (TypeError (('ShowType x :<>: 'Text " is not in ") :<>: 'ShowType xs) :: Constraint) 

type family Length (xs :: [k]) :: Nat where ... #

Calculate the Length of a type level list

>>> :kind! Length '[Char,String,Bool,Double]
Length '[Char,String,Bool,Double] :: Nat
= 4

Equations

Length ('[] :: [k]) = 0 
Length (_1 ': xs :: [k]) = 1 + Length xs 

getFixChar :: forall (n :: Nat). FixChar n -> Text #

Access the Text of a FixChar

fixChar :: forall (n :: Nat). KnownNat n => Text -> Maybe (FixChar n) #

Constructor for FixChar

getVarChar :: forall (n :: Nat). VarChar n -> Text #

Access the Text of a VarChar

varChar :: forall (n :: Nat). KnownNat n => Text -> Maybe (VarChar n) #

Constructor for VarChar

newtype Money #

The Money newtype stores a monetary value in terms of the number of cents, i.e. $2,000.20 would be expressed as Money { cents = 200020 }.

>>> :kind! PG Money
PG Money :: PGType
= 'PGmoney

Constructors

Money 

Fields

Instances

Instances details
Eq Money 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

(==) :: Money -> Money -> Bool #

(/=) :: Money -> Money -> Bool #

Ord Money 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

compare :: Money -> Money -> Ordering #

(<) :: Money -> Money -> Bool #

(<=) :: Money -> Money -> Bool #

(>) :: Money -> Money -> Bool #

(>=) :: Money -> Money -> Bool #

max :: Money -> Money -> Money #

min :: Money -> Money -> Money #

Read Money 
Instance details

Defined in Squeal.PostgreSQL.Type

Show Money 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

showsPrec :: Int -> Money -> ShowS #

show :: Money -> String #

showList :: [Money] -> ShowS #

Generic Money 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Rep Money :: Type -> Type #

Methods

from :: Money -> Rep Money x #

to :: Rep Money x -> Money #

Generic Money 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Code Money :: [[Type]] #

Methods

from :: Money -> Rep Money #

to :: Rep Money -> Money #

HasDatatypeInfo Money 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type DatatypeInfoOf Money :: DatatypeInfo #

Methods

datatypeInfo :: proxy Money -> DatatypeInfo (Code Money) #

Inline Money 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Money -> Expr (null (PG Money)) #

FromPG Money 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG Money

PGmoney

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG Money :: PGType #

ToPG db Money 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

type Rep Money 
Instance details

Defined in Squeal.PostgreSQL.Type

type Rep Money = D1 ('MetaData "Money" "Squeal.PostgreSQL.Type" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "Money" 'PrefixI 'True) (S1 ('MetaSel ('Just "cents") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))
type Code Money 
Instance details

Defined in Squeal.PostgreSQL.Type

type DatatypeInfoOf Money 
Instance details

Defined in Squeal.PostgreSQL.Type

type PG Money 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG Money = 'PGmoney

newtype Json hask #

The Json newtype is an indication that the Haskell type it's applied to should be stored as a PGjson.

>>> :kind! PG (Json [String])
PG (Json [String]) :: PGType
= 'PGjson

Constructors

Json 

Fields

Instances

Instances details
ToJSON x => ToPG db (Json x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Json x -> ReaderT (K Connection db) IO Encoding #

Eq hask => Eq (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

(==) :: Json hask -> Json hask -> Bool #

(/=) :: Json hask -> Json hask -> Bool #

Ord hask => Ord (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

compare :: Json hask -> Json hask -> Ordering #

(<) :: Json hask -> Json hask -> Bool #

(<=) :: Json hask -> Json hask -> Bool #

(>) :: Json hask -> Json hask -> Bool #

(>=) :: Json hask -> Json hask -> Bool #

max :: Json hask -> Json hask -> Json hask #

min :: Json hask -> Json hask -> Json hask #

Read hask => Read (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

readsPrec :: Int -> ReadS (Json hask) #

readList :: ReadS [Json hask] #

readPrec :: ReadPrec (Json hask) #

readListPrec :: ReadPrec [Json hask] #

Show hask => Show (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

showsPrec :: Int -> Json hask -> ShowS #

show :: Json hask -> String #

showList :: [Json hask] -> ShowS #

Generic (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Rep (Json hask) :: Type -> Type #

Methods

from :: Json hask -> Rep (Json hask) x #

to :: Rep (Json hask) x -> Json hask #

Generic (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Code (Json hask) :: [[Type]] #

Methods

from :: Json hask -> Rep (Json hask) #

to :: Rep (Json hask) -> Json hask #

HasDatatypeInfo (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type DatatypeInfoOf (Json hask) :: DatatypeInfo #

Methods

datatypeInfo :: proxy (Json hask) -> DatatypeInfo (Code (Json hask)) #

ToJSON x => Inline (Json x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Json x -> Expr (null (PG (Json x))) #

FromJSON x => FromPG (Json x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG (Json hask)

PGjson

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (Json hask) :: PGType #

type Rep (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Rep (Json hask) = D1 ('MetaData "Json" "Squeal.PostgreSQL.Type" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "Json" 'PrefixI 'True) (S1 ('MetaSel ('Just "getJson") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 hask)))
type Code (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Code (Json hask) = GCode (Json hask)
type DatatypeInfoOf (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

type PG (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (Json hask) = 'PGjson

newtype Jsonb hask #

The Jsonb newtype is an indication that the Haskell type it's applied to should be stored as a PGjsonb.

>>> :kind! PG (Jsonb [String])
PG (Jsonb [String]) :: PGType
= 'PGjsonb

Constructors

Jsonb 

Fields

Instances

Instances details
ToJSON x => ToPG db (Jsonb x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: Jsonb x -> ReaderT (K Connection db) IO Encoding #

Eq hask => Eq (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

(==) :: Jsonb hask -> Jsonb hask -> Bool #

(/=) :: Jsonb hask -> Jsonb hask -> Bool #

Ord hask => Ord (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

compare :: Jsonb hask -> Jsonb hask -> Ordering #

(<) :: Jsonb hask -> Jsonb hask -> Bool #

(<=) :: Jsonb hask -> Jsonb hask -> Bool #

(>) :: Jsonb hask -> Jsonb hask -> Bool #

(>=) :: Jsonb hask -> Jsonb hask -> Bool #

max :: Jsonb hask -> Jsonb hask -> Jsonb hask #

min :: Jsonb hask -> Jsonb hask -> Jsonb hask #

Read hask => Read (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

readsPrec :: Int -> ReadS (Jsonb hask) #

readList :: ReadS [Jsonb hask] #

readPrec :: ReadPrec (Jsonb hask) #

readListPrec :: ReadPrec [Jsonb hask] #

Show hask => Show (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

showsPrec :: Int -> Jsonb hask -> ShowS #

show :: Jsonb hask -> String #

showList :: [Jsonb hask] -> ShowS #

Generic (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Rep (Jsonb hask) :: Type -> Type #

Methods

from :: Jsonb hask -> Rep (Jsonb hask) x #

to :: Rep (Jsonb hask) x -> Jsonb hask #

Generic (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Code (Jsonb hask) :: [[Type]] #

Methods

from :: Jsonb hask -> Rep (Jsonb hask) #

to :: Rep (Jsonb hask) -> Jsonb hask #

HasDatatypeInfo (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type DatatypeInfoOf (Jsonb hask) :: DatatypeInfo #

Methods

datatypeInfo :: proxy (Jsonb hask) -> DatatypeInfo (Code (Jsonb hask)) #

ToJSON x => Inline (Jsonb x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Jsonb x -> Expr (null (PG (Jsonb x))) #

FromJSON x => FromPG (Jsonb x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG (Jsonb hask)

PGjsonb

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (Jsonb hask) :: PGType #

type Rep (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Rep (Jsonb hask) = D1 ('MetaData "Jsonb" "Squeal.PostgreSQL.Type" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "Jsonb" 'PrefixI 'True) (S1 ('MetaSel ('Just "getJsonb") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 hask)))
type Code (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Code (Jsonb hask) = GCode (Jsonb hask)
type DatatypeInfoOf (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type

type PG (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (Jsonb hask) = 'PGjsonb

newtype Composite record #

The Composite newtype is an indication that the Haskell type it's applied to should be stored as a PGcomposite.

>>> :{
data Complex = Complex
  { real :: Double
  , imaginary :: Double
  } deriving stock GHC.Generic
    deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
:}
>>> :kind! PG (Composite Complex)
PG (Composite Complex) :: PGType
= 'PGcomposite
    '["real" ::: 'NotNull 'PGfloat8,
      "imaginary" ::: 'NotNull 'PGfloat8]

Constructors

Composite 

Fields

Instances

Instances details
(SListI fields, IsRecord x xs, AllZip (ToField db) fields xs, All (OidOfField db) fields, RowPG x ~ fields) => ToPG db (Composite x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Eq record => Eq (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

(==) :: Composite record -> Composite record -> Bool #

(/=) :: Composite record -> Composite record -> Bool #

Ord record => Ord (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

compare :: Composite record -> Composite record -> Ordering #

(<) :: Composite record -> Composite record -> Bool #

(<=) :: Composite record -> Composite record -> Bool #

(>) :: Composite record -> Composite record -> Bool #

(>=) :: Composite record -> Composite record -> Bool #

max :: Composite record -> Composite record -> Composite record #

min :: Composite record -> Composite record -> Composite record #

Read record => Read (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

readsPrec :: Int -> ReadS (Composite record) #

readList :: ReadS [Composite record] #

readPrec :: ReadPrec (Composite record) #

readListPrec :: ReadPrec [Composite record] #

Show record => Show (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

showsPrec :: Int -> Composite record -> ShowS #

show :: Composite record -> String #

showList :: [Composite record] -> ShowS #

Generic (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Rep (Composite record) :: Type -> Type #

Methods

from :: Composite record -> Rep (Composite record) x #

to :: Rep (Composite record) x -> Composite record #

Generic (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Code (Composite record) :: [[Type]] #

Methods

from :: Composite record -> Rep (Composite record) #

to :: Rep (Composite record) -> Composite record #

HasDatatypeInfo (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type DatatypeInfoOf (Composite record) :: DatatypeInfo #

Methods

datatypeInfo :: proxy (Composite record) -> DatatypeInfo (Code (Composite record)) #

(IsRecord x xs, AllZip InlineField xs (RowPG x)) => Inline (Composite x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Composite x -> Expr (null (PG (Composite x))) #

(IsRecord y ys, AllZip FromField row ys, RowPG y ~ row) => FromPG (Composite y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG (Composite hask)

PGcomposite (RowPG hask)

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (Composite hask) :: PGType #

type Rep (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Rep (Composite record) = D1 ('MetaData "Composite" "Squeal.PostgreSQL.Type" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "Composite" 'PrefixI 'True) (S1 ('MetaSel ('Just "getComposite") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 record)))
type Code (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Code (Composite record) = GCode (Composite record)
type DatatypeInfoOf (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.Type

type PG (Composite hask) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (Composite hask) = 'PGcomposite (RowPG hask)

newtype Enumerated enum #

The Enumerated newtype is an indication that the Haskell type it's applied to should be stored as a PGenum.

>>> :kind! PG (Enumerated Ordering)
PG (Enumerated Ordering) :: PGType
= 'PGenum '["LT", "EQ", "GT"]

Constructors

Enumerated 

Fields

Instances

Instances details
(IsEnumType x, HasDatatypeInfo x, LabelsPG x ~ labels) => ToPG db (Enumerated x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Eq enum => Eq (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

(==) :: Enumerated enum -> Enumerated enum -> Bool #

(/=) :: Enumerated enum -> Enumerated enum -> Bool #

Ord enum => Ord (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

compare :: Enumerated enum -> Enumerated enum -> Ordering #

(<) :: Enumerated enum -> Enumerated enum -> Bool #

(<=) :: Enumerated enum -> Enumerated enum -> Bool #

(>) :: Enumerated enum -> Enumerated enum -> Bool #

(>=) :: Enumerated enum -> Enumerated enum -> Bool #

max :: Enumerated enum -> Enumerated enum -> Enumerated enum #

min :: Enumerated enum -> Enumerated enum -> Enumerated enum #

Read enum => Read (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Type

Show enum => Show (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

showsPrec :: Int -> Enumerated enum -> ShowS #

show :: Enumerated enum -> String #

showList :: [Enumerated enum] -> ShowS #

Generic (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Rep (Enumerated enum) :: Type -> Type #

Methods

from :: Enumerated enum -> Rep (Enumerated enum) x #

to :: Rep (Enumerated enum) x -> Enumerated enum #

Generic (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Code (Enumerated enum) :: [[Type]] #

Methods

from :: Enumerated enum -> Rep (Enumerated enum) #

to :: Rep (Enumerated enum) -> Enumerated enum #

HasDatatypeInfo (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type DatatypeInfoOf (Enumerated enum) :: DatatypeInfo #

Methods

datatypeInfo :: proxy (Enumerated enum) -> DatatypeInfo (Code (Enumerated enum)) #

(IsEnumType x, HasDatatypeInfo x) => Inline (Enumerated x) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). Enumerated x -> Expr (null (PG (Enumerated x))) #

(IsEnumType y, HasDatatypeInfo y, LabelsPG y ~ labels) => FromPG (Enumerated y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG (Enumerated hask)

PGenum (LabelsPG hask)

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (Enumerated hask) :: PGType #

type Rep (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Rep (Enumerated enum) = D1 ('MetaData "Enumerated" "Squeal.PostgreSQL.Type" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "Enumerated" 'PrefixI 'True) (S1 ('MetaSel ('Just "getEnumerated") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 enum)))
type Code (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Code (Enumerated enum) = GCode (Enumerated enum)
type DatatypeInfoOf (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Type

type PG (Enumerated hask) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (Enumerated hask) = 'PGenum (LabelsPG hask)

newtype VarArray arr #

The VarArray newtype is an indication that the Haskell type it's applied to should be stored as a PGvararray.

>>> import Data.Vector
>>> :kind! PG (VarArray (Vector Double))
PG (VarArray (Vector Double)) :: PGType
= 'PGvararray ('NotNull 'PGfloat8)

Constructors

VarArray 

Fields

Instances

Instances details
(NullPG x ~ ty, ToArray db ('[] :: [Nat]) ty x, OidOfNull db ty) => ToPG db (VarArray [x]) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: VarArray [x] -> ReaderT (K Connection db) IO Encoding #

(NullPG x ~ ty, ToArray db ('[] :: [Nat]) ty x, OidOfNull db ty) => ToPG db (VarArray (Vector x)) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Eq arr => Eq (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

(==) :: VarArray arr -> VarArray arr -> Bool #

(/=) :: VarArray arr -> VarArray arr -> Bool #

Ord arr => Ord (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

compare :: VarArray arr -> VarArray arr -> Ordering #

(<) :: VarArray arr -> VarArray arr -> Bool #

(<=) :: VarArray arr -> VarArray arr -> Bool #

(>) :: VarArray arr -> VarArray arr -> Bool #

(>=) :: VarArray arr -> VarArray arr -> Bool #

max :: VarArray arr -> VarArray arr -> VarArray arr #

min :: VarArray arr -> VarArray arr -> VarArray arr #

Read arr => Read (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Show arr => Show (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

showsPrec :: Int -> VarArray arr -> ShowS #

show :: VarArray arr -> String #

showList :: [VarArray arr] -> ShowS #

Generic (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Rep (VarArray arr) :: Type -> Type #

Methods

from :: VarArray arr -> Rep (VarArray arr) x #

to :: Rep (VarArray arr) x -> VarArray arr #

Generic (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Code (VarArray arr) :: [[Type]] #

Methods

from :: VarArray arr -> Rep (VarArray arr) #

to :: Rep (VarArray arr) -> VarArray arr #

HasDatatypeInfo (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type DatatypeInfoOf (VarArray arr) :: DatatypeInfo #

Methods

datatypeInfo :: proxy (VarArray arr) -> DatatypeInfo (Code (VarArray arr)) #

InlineParam x (NullPG x) => Inline (VarArray [x]) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). VarArray [x] -> Expr (null (PG (VarArray [x]))) #

InlineParam x (NullPG x) => Inline (VarArray (Vector x)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). VarArray (Vector x) -> Expr (null (PG (VarArray (Vector x)))) #

(FromArray ('[] :: [Nat]) ty y, ty ~ NullPG y) => FromPG (VarArray [y]) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

(FromArray ('[] :: [Nat]) ty y, ty ~ NullPG y) => FromPG (VarArray (Vector y)) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG (VarArray [x])

PGvararray (NullPG x)

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (VarArray [x]) :: PGType #

IsPG (VarArray (Vector x))

PGvararray (NullPG x)

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (VarArray (Vector x)) :: PGType #

type Rep (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Rep (VarArray arr) = D1 ('MetaData "VarArray" "Squeal.PostgreSQL.Type" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "VarArray" 'PrefixI 'True) (S1 ('MetaSel ('Just "getVarArray") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 arr)))
type Code (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Code (VarArray arr) = GCode (VarArray arr)
type DatatypeInfoOf (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

type PG (VarArray [x]) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (VarArray [x]) = 'PGvararray (NullPG x)
type PG (VarArray (Vector x)) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (VarArray (Vector x)) = 'PGvararray (NullPG x)

newtype FixArray arr #

The FixArray newtype is an indication that the Haskell type it's applied to should be stored as a PGfixarray.

>>> :kind! PG (FixArray ((Double, Double), (Double, Double)))
PG (FixArray ((Double, Double), (Double, Double))) :: PGType
= 'PGfixarray '[2, 2] ('NotNull 'PGfloat8)

Constructors

FixArray 

Fields

Instances

Instances details
(ToArray db dims ty x, OidOfNull db ty) => ToPG db (FixArray x) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Eq arr => Eq (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

(==) :: FixArray arr -> FixArray arr -> Bool #

(/=) :: FixArray arr -> FixArray arr -> Bool #

Ord arr => Ord (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

compare :: FixArray arr -> FixArray arr -> Ordering #

(<) :: FixArray arr -> FixArray arr -> Bool #

(<=) :: FixArray arr -> FixArray arr -> Bool #

(>) :: FixArray arr -> FixArray arr -> Bool #

(>=) :: FixArray arr -> FixArray arr -> Bool #

max :: FixArray arr -> FixArray arr -> FixArray arr #

min :: FixArray arr -> FixArray arr -> FixArray arr #

Read arr => Read (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Show arr => Show (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

showsPrec :: Int -> FixArray arr -> ShowS #

show :: FixArray arr -> String #

showList :: [FixArray arr] -> ShowS #

Generic (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Rep (FixArray arr) :: Type -> Type #

Methods

from :: FixArray arr -> Rep (FixArray arr) x #

to :: Rep (FixArray arr) x -> FixArray arr #

Generic (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Code (FixArray arr) :: [[Type]] #

Methods

from :: FixArray arr -> Rep (FixArray arr) #

to :: Rep (FixArray arr) -> FixArray arr #

HasDatatypeInfo (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type DatatypeInfoOf (FixArray arr) :: DatatypeInfo #

Methods

datatypeInfo :: proxy (FixArray arr) -> DatatypeInfo (Code (FixArray arr)) #

FromArray dims ty y => FromPG (FixArray y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG (FixArray hask)

PGfixarray (DimPG hask) (FixPG hask)

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (FixArray hask) :: PGType #

type Rep (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Rep (FixArray arr) = D1 ('MetaData "FixArray" "Squeal.PostgreSQL.Type" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "FixArray" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFixArray") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 arr)))
type Code (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Code (FixArray arr) = GCode (FixArray arr)
type DatatypeInfoOf (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.Type

type PG (FixArray hask) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (FixArray hask) = 'PGfixarray (DimPG hask) (FixPG hask)

newtype Only x #

Only is a 1-tuple type, useful for encoding or decoding a singleton

Constructors

Only 

Fields

Instances

Instances details
Functor Only 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

fmap :: (a -> b) -> Only a -> Only b #

(<$) :: a -> Only b -> Only a #

Foldable Only 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

fold :: Monoid m => Only m -> m #

foldMap :: Monoid m => (a -> m) -> Only a -> m #

foldMap' :: Monoid m => (a -> m) -> Only a -> m #

foldr :: (a -> b -> b) -> b -> Only a -> b #

foldr' :: (a -> b -> b) -> b -> Only a -> b #

foldl :: (b -> a -> b) -> b -> Only a -> b #

foldl' :: (b -> a -> b) -> b -> Only a -> b #

foldr1 :: (a -> a -> a) -> Only a -> a #

foldl1 :: (a -> a -> a) -> Only a -> a #

toList :: Only a -> [a] #

null :: Only a -> Bool #

length :: Only a -> Int #

elem :: Eq a => a -> Only a -> Bool #

maximum :: Ord a => Only a -> a #

minimum :: Ord a => Only a -> a #

sum :: Num a => Only a -> a #

product :: Num a => Only a -> a #

Traversable Only 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

traverse :: Applicative f => (a -> f b) -> Only a -> f (Only b) #

sequenceA :: Applicative f => Only (f a) -> f (Only a) #

mapM :: Monad m => (a -> m b) -> Only a -> m (Only b) #

sequence :: Monad m => Only (m a) -> m (Only a) #

Eq x => Eq (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

(==) :: Only x -> Only x -> Bool #

(/=) :: Only x -> Only x -> Bool #

Ord x => Ord (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

compare :: Only x -> Only x -> Ordering #

(<) :: Only x -> Only x -> Bool #

(<=) :: Only x -> Only x -> Bool #

(>) :: Only x -> Only x -> Bool #

(>=) :: Only x -> Only x -> Bool #

max :: Only x -> Only x -> Only x #

min :: Only x -> Only x -> Only x #

Read x => Read (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Type

Show x => Show (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

showsPrec :: Int -> Only x -> ShowS #

show :: Only x -> String #

showList :: [Only x] -> ShowS #

Generic (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Rep (Only x) :: Type -> Type #

Methods

from :: Only x -> Rep (Only x) x0 #

to :: Rep (Only x) x0 -> Only x #

Generic (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type Code (Only x) :: [[Type]] #

Methods

from :: Only x -> Rep (Only x) #

to :: Rep (Only x) -> Only x #

HasDatatypeInfo (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Type

Associated Types

type DatatypeInfoOf (Only x) :: DatatypeInfo #

Methods

datatypeInfo :: proxy (Only x) -> DatatypeInfo (Code (Only x)) #

type Rep (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Rep (Only x) = D1 ('MetaData "Only" "Squeal.PostgreSQL.Type" "squeal-postgresql-0.7.0.1-K3qRKJMfBF18Xb8uCfM6Cl" 'True) (C1 ('MetaCons "Only" 'PrefixI 'True) (S1 ('MetaSel ('Just "fromOnly") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 x)))
type Code (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Type

type Code (Only x) = GCode (Only x)
type DatatypeInfoOf (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Type

data VarChar (n :: Nat) #

Variable-length text type with limit

>>> :kind! PG (VarChar 4)
PG (VarChar 4) :: PGType
= 'PGvarchar 4

Instances

Instances details
ToPG db (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: VarChar n -> ReaderT (K Connection db) IO Encoding #

Eq (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

(==) :: VarChar n -> VarChar n -> Bool #

(/=) :: VarChar n -> VarChar n -> Bool #

Ord (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

compare :: VarChar n -> VarChar n -> Ordering #

(<) :: VarChar n -> VarChar n -> Bool #

(<=) :: VarChar n -> VarChar n -> Bool #

(>) :: VarChar n -> VarChar n -> Bool #

(>=) :: VarChar n -> VarChar n -> Bool #

max :: VarChar n -> VarChar n -> VarChar n #

min :: VarChar n -> VarChar n -> VarChar n #

Read (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type

Show (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

showsPrec :: Int -> VarChar n -> ShowS #

show :: VarChar n -> String #

showList :: [VarChar n] -> ShowS #

(KnownNat n, 1 <= n) => Inline (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). VarChar n -> Expr (null (PG (VarChar n))) #

KnownNat n => FromPG (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG (VarChar n)

PGvarchar

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (VarChar n) :: PGType #

type PG (VarChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (VarChar n) = 'PGvarchar n

data FixChar (n :: Nat) #

Fixed-length, blank padded

>>> :kind! PG (FixChar 4)
PG (FixChar 4) :: PGType
= 'PGchar 4

Instances

Instances details
ToPG db (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

toPG :: FixChar n -> ReaderT (K Connection db) IO Encoding #

Eq (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

(==) :: FixChar n -> FixChar n -> Bool #

(/=) :: FixChar n -> FixChar n -> Bool #

Ord (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

compare :: FixChar n -> FixChar n -> Ordering #

(<) :: FixChar n -> FixChar n -> Bool #

(<=) :: FixChar n -> FixChar n -> Bool #

(>) :: FixChar n -> FixChar n -> Bool #

(>=) :: FixChar n -> FixChar n -> Bool #

max :: FixChar n -> FixChar n -> FixChar n #

min :: FixChar n -> FixChar n -> FixChar n #

Read (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type

Show (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type

Methods

showsPrec :: Int -> FixChar n -> ShowS #

show :: FixChar n -> String #

showList :: [FixChar n] -> ShowS #

(KnownNat n, 1 <= n) => Inline (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Inline

Methods

inline :: forall (null :: PGType -> NullType). FixChar n -> Expr (null (PG (FixChar n))) #

KnownNat n => FromPG (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

IsPG (FixChar n)

PGvarchar

Instance details

Defined in Squeal.PostgreSQL.Type.PG

Associated Types

type PG (FixChar n) :: PGType #

type PG (FixChar n) 
Instance details

Defined in Squeal.PostgreSQL.Type.PG

type PG (FixChar n) = 'PGchar n

trySqueal :: MonadUnliftIO io => io a -> io (Either SquealException a) #

Either return a SquealException or a result.

handleSqueal #

Arguments

:: MonadUnliftIO io 
=> (SquealException -> io a)

handler

-> io a 
-> io a 

catchSqueal #

Arguments

:: MonadUnliftIO io 
=> io a 
-> (SquealException -> io a)

handler

-> io a 

pattern UniqueViolation :: ByteString -> SquealException #

A pattern for unique violation exceptions.

pattern CheckViolation :: ByteString -> SquealException #

A pattern for check constraint violation exceptions.

pattern SerializationFailure :: ByteString -> SquealException #

A pattern for serialization failure exceptions.

data SquealException #

Exceptions that can be thrown by Squeal.

Constructors

SQLException SQLState

SQL exception state

ConnectionException Text

LibPQ function connection exception

DecodingException Text Text

decoding exception function and error message

ColumnsException Text Column

unexpected number of columns

RowsException Text Row Row

too few rows, expected at least and actual number of rows

printSQL :: (RenderSQL sql, MonadIO io) => sql -> io () #

Print SQL.

class RenderSQL sql where #

A class for rendering SQL

Methods

renderSQL :: sql -> ByteString #

Instances

Instances details
RenderSQL OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

RenderSQL OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

RenderSQL ReferentialAction 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

RenderSQL TransactionMode

Render a TransactionMode.

Instance details

Defined in Squeal.PostgreSQL.Session.Transaction

RenderSQL IsolationLevel

Render an IsolationLevel.

Instance details

Defined in Squeal.PostgreSQL.Session.Transaction

RenderSQL AccessMode

Render an AccessMode.

Instance details

Defined in Squeal.PostgreSQL.Session.Transaction

RenderSQL DeferrableMode

Render a DeferrableMode.

Instance details

Defined in Squeal.PostgreSQL.Session.Transaction

RenderSQL LockStrength 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

RenderSQL Waiting 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

RenderSQL TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

RenderSQL [SortExpression grp lat with db params from] 
Instance details

Defined in Squeal.PostgreSQL.Expression.Sort

Methods

renderSQL :: [SortExpression grp lat with db params from] -> ByteString #

KnownSymbol label => RenderSQL (PGlabel label) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

renderSQL :: PGlabel label -> ByteString #

KnownSymbol alias => RenderSQL (Alias alias)
>>> printSQL (#jimbob :: Alias "jimbob")
"jimbob"
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

renderSQL :: Alias alias -> ByteString #

RenderSQL (IndexMethod ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Index

RenderSQL (Definition db0 db1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

renderSQL :: Definition db0 db1 -> ByteString #

RenderSQL (By from by) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

renderSQL :: By from by -> ByteString #

RenderSQL (LockingClause from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

RenderSQL (TypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

RenderSQL (ColumnTypeExpression db ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

(KnownSymbol q, KnownSymbol a) => RenderSQL (QualifiedAlias q a) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

All KnownSymbol labels => RenderSQL (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

Methods

renderSQL :: NP PGlabel labels -> ByteString #

All KnownSymbol aliases => RenderSQL (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

renderSQL :: NP Alias aliases -> ByteString #

RenderSQL (ConflictTarget constraints)

Render a ConflictTarget

Instance details

Defined in Squeal.PostgreSQL.Manipulation.Insert

Methods

renderSQL :: ConflictTarget constraints -> ByteString #

RenderSQL (Statement db x y) 
Instance details

Defined in Squeal.PostgreSQL.Session.Statement

Methods

renderSQL :: Statement db x y -> ByteString #

(forall (x :: k). RenderSQL (expr x)) => RenderSQL (Optional expr ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Default

Methods

renderSQL :: Optional expr ty -> ByteString #

RenderSQL (ProcedureDefinition db args) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Procedure

RenderSQL (TableConstraintExpression sch tab db constraint) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Constraint

Methods

renderSQL :: TableConstraintExpression sch tab db constraint -> ByteString #

RenderSQL (QueryClause with db params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation.Insert

Methods

renderSQL :: QueryClause with db params columns -> ByteString #

RenderSQL (Manipulation with db params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: Manipulation with db params columns -> ByteString #

RenderSQL (GroupByClause grp from) 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

renderSQL :: GroupByClause grp from -> ByteString #

SListI (TableToColumns table) => RenderSQL (ConflictClause tab with db params table)

Render a ConflictClause.

Instance details

Defined in Squeal.PostgreSQL.Manipulation.Insert

Methods

renderSQL :: ConflictClause tab with db params table -> ByteString #

RenderSQL (ConflictAction tab with db params table) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation.Insert

Methods

renderSQL :: ConflictAction tab with db params table -> ByteString #

RenderSQL (ReturningClause with db params from row) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: ReturningClause with db params from row -> ByteString #

RenderSQL (FromClause lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Query.From

Methods

renderSQL :: FromClause lat with db params from -> ByteString #

(forall (c :: FromType) (s :: SchemasType) (p :: [NullType]) (r :: RowType). RenderSQL (statement c s p r)) => RenderSQL (CommonTableExpression statement db params with0 with1) 
Instance details

Defined in Squeal.PostgreSQL.Query.With

Methods

renderSQL :: CommonTableExpression statement db params with0 with1 -> ByteString #

RenderSQL (Query lat with db params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: Query lat with db params row -> ByteString #

RenderSQL (FunctionDefinition db args ret) 
Instance details

Defined in Squeal.PostgreSQL.Definition.Function

Methods

renderSQL :: FunctionDefinition db args ret -> ByteString #

RenderSQL (WindowDefinition grp lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

renderSQL :: WindowDefinition grp lat with db params from -> ByteString #

SListI xs => RenderSQL (AggregateArg xs lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

renderSQL :: AggregateArg xs lat with db params from -> ByteString #

RenderSQL (JoinItem lat with db params left right) 
Instance details

Defined in Squeal.PostgreSQL.Query.From.Join

Methods

renderSQL :: JoinItem lat with db params left right -> ByteString #

RenderSQL (TableExpression grp lat with db params from)

Render a TableExpression

Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

renderSQL :: TableExpression grp lat with db params from -> ByteString #

RenderSQL (HavingClause grp lat with db params from)

Render a HavingClause.

Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

renderSQL :: HavingClause grp lat with db params from -> ByteString #

RenderSQL (SortExpression grp lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Sort

Methods

renderSQL :: SortExpression grp lat with db params from -> ByteString #

RenderSQL (Selection grp lat with db params from row) 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

renderSQL :: Selection grp lat with db params from row -> ByteString #

RenderSQL (WindowFunction grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

renderSQL :: WindowFunction grp lat with db params from ty -> ByteString #

SListI args => RenderSQL (WindowArg grp args lat with db params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

renderSQL :: WindowArg grp args lat with db params from -> ByteString #

RenderSQL (Expression grp lat with db params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

renderSQL :: Expression grp lat with db params from ty -> ByteString #

type Pool = Pool #