squeal-postgresql-0.9.0.0: Squeal PostgreSQL Library
Copyright(c) Eitan Chatav 2019
Maintainereitan@morphism.tech
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Squeal.PostgreSQL.Type.Alias

Description

This module embeds Postgres's alias system in Haskell in a typesafe fashion. Thanks to GHC's OverloadedLabels extension, Squeal can reference aliases by prepending with a #.

Synopsis

Aliases

type (:::) (alias :: Symbol) ty = '(alias, ty) infixr 6 Source #

The alias operator ::: is like a promoted version of As, a type level pair between an alias and some type.

data Alias (alias :: Symbol) Source #

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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias qualifier -> Alias alias -> (Alias qualifier, Alias alias) Source #

alias1 ~ alias2 => IsLabel alias1 (Alias alias2) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: Alias alias2 #

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

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

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: NP Alias aliases #

Eq (Alias alias) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(==) :: Alias alias -> Alias alias -> Bool #

(/=) :: Alias alias -> Alias alias -> Bool #

Ord (Alias alias) Source # 
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) Source # 
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) Source # 
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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

rnf :: Alias alias -> () #

KnownSymbol alias => RenderSQL (Alias alias) Source #
>>> printSQL (#jimbob :: Alias "jimbob")
"jimbob"
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

renderSQL :: Alias alias -> ByteString Source #

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

renderSQL :: NP Alias aliases -> ByteString Source #

type Rep (Alias alias) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

type Rep (Alias alias) = D1 ('MetaData "Alias" "Squeal.PostgreSQL.Type.Alias" "squeal-postgresql-0.9.0.0-D17NIjlcsGRAwJTaCTXyvM" 'False) (C1 ('MetaCons "Alias" 'PrefixI 'False) (U1 :: Type -> Type))

class IsLabel (x :: Symbol) a where #

Methods

fromLabel :: a #

Instances

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: Alias alias2 #

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: QualifiedAlias q' a' #

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

Defined in Squeal.PostgreSQL.Session.Decode

Methods

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

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

Defined in Squeal.PostgreSQL.Session.Decode

Methods

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

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

Defined in Squeal.PostgreSQL.Session.Decode

Methods

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

(KnownSymbol fld, FromValue ty y) => IsLabel fld (DecodeRow ((fld ::: ty) ': row) y) Source # 
Instance details

Defined in Squeal.PostgreSQL.Session.Decode

Methods

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

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

Defined in Squeal.PostgreSQL.Query.Table

Methods

fromLabel :: By rels by #

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

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

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

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

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

fromLabel :: NP Alias aliases #

(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) Source # 
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, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression ('Grouped bys) lat with db params from) column) Source # 
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, GroupedBy tab col bys, tys ~ '[ty]) => IsLabel col (NP (Expression ('Grouped bys) lat with db params from) tys) Source # 
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, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) Source # 
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, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression 'Ungrouped lat with db params from) column) Source # 
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, tys ~ '[ty]) => IsLabel col (NP (Expression 'Ungrouped lat with db params from) tys) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

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

Defined in Squeal.PostgreSQL.Query.Table

Methods

fromLabel :: NP (By rels) bys #

(ToParam db ty x, ty ~ NullPG x) => IsLabel fld (EncodeParams db '[fld ::: ty] x) Source # 
Instance details

Defined in Squeal.PostgreSQL.Session.Encode

Methods

fromLabel :: EncodeParams db '[fld ::: ty] x #

(HasUnique tab (Join from lat) row, Has col row ty) => IsLabel col (AggregateArg '[ty] lat with db params from) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

fromLabel :: AggregateArg '[ty] lat with db params from #

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

(HasUnique tab (Join from lat) row, Has col row ty) => IsLabel col (Expression 'Ungrouped lat with db params from ty) Source # 
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 (WindowArg ('Grouped bys) '[ty] lat with db params from) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

fromLabel :: WindowArg ('Grouped bys) '[ty] lat with db params from #

(HasUnique tab (Join from lat) row, Has col row ty) => IsLabel col (WindowArg 'Ungrouped '[ty] lat with db params from) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

fromLabel :: WindowArg 'Ungrouped '[ty] lat with db params from #

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

fromLabel :: 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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

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

data Aliased expression aliased where Source #

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 :: KnownSymbol alias => expression ty -> Alias alias -> Aliased expression (alias ::: ty) 

Instances

Instances details
(q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias q0 -> Alias a0 -> Aliased (QualifiedAlias q1) (a1 ::: a2) Source #

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

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

(KnownSymbol alias, aliased ~ (alias ::: ty)) => Aliasable alias (expression ty) (Aliased expression aliased) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

as :: expression ty -> Alias alias -> Aliased expression aliased Source #

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

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

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

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

(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) Source # 
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, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression ('Grouped bys) lat with db params from) column) Source # 
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, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) Source # 
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, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression 'Ungrouped lat with db params from) column) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

Eq (expression ty) => Eq (Aliased expression (alias ::: ty)) Source # 
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)) Source # 
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)) Source # 
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 expression aliased | aliased -> expression, aliased -> alias where Source #

The Aliasable class provides a way to scrap your Nils in an NP list of Aliased expressions.

Methods

as :: expression -> Alias alias -> aliased Source #

Instances

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

Defined in Squeal.PostgreSQL.Type.Alias

Methods

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

(KnownSymbol alias, aliased ~ (alias ::: ty)) => Aliasable alias (expression ty) (Aliased expression aliased) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

as :: expression ty -> Alias alias -> Aliased expression aliased Source #

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

Defined in Squeal.PostgreSQL.Query.With

Methods

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

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

Defined in Squeal.PostgreSQL.Query.With

Methods

as :: statement with db params common -> Alias cte -> CommonTableExpression statement db params with with1 Source #

(KnownSymbol col, row ~ '[col ::: ty]) => Aliasable col (Expression grp lat with db params from ty) (Selection grp lat with db params from row) Source # 
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 Source #

renderAliased :: (forall ty. expression ty -> ByteString) -> Aliased expression aliased -> ByteString Source #

>>> let renderMaybe = fromString . maybe "Nothing" (const "Just")
>>> renderAliased renderMaybe (Just (3::Int) `As` #an_int)
"Just AS \"an_int\""

mapAliased :: (expr x -> expr y) -> Aliased expr (alias ::: x) -> Aliased expr (alias ::: y) Source #

Map a function over an Aliased expression.

class KnownSymbol alias => Has (alias :: Symbol) (fields :: [(Symbol, kind)]) (field :: kind) | alias fields -> field Source #

Has alias fields field is a constraint that proves that fields has a field of alias ::: field, inferring field from alias and fields.

Instances

Instances details
(KnownSymbol alias, HasErr ('[] :: [(Symbol, kind)]) alias ('[] :: [(Symbol, kind)]) field) => Has alias ('[] :: [(Symbol, kind)]) (field :: kind) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

(KnownSymbol alias, HasErr (field' ': fields) alias (field' ': fields) field) => Has alias (field' ': fields :: [(Symbol, kind)]) (field :: kind) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

(KnownSymbol alias, HasErr ((alias ::: field0) ': fields) alias ((alias ::: field0) ': fields) field1) => Has alias ((alias ::: field0) ': fields :: [(Symbol, kind)]) (field1 :: kind) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

type HasUnique alias fields field = fields ~ '[alias ::: field] Source #

HasUnique alias fields field is a constraint that proves that fields is a singleton of alias ::: field.

class KnownSymbol alias => HasErr (allFields :: [(Symbol, kind)]) (alias :: Symbol) (fields :: [(Symbol, kind)]) (field :: kind) | alias fields -> field Source #

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, LookupFailedError alias allFields, field ~ (Any :: kind)) => HasErr (allFields :: [(Symbol, kind)]) alias ('[] :: [(Symbol, kind)]) (field :: kind) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

(KnownSymbol alias, HasErr allFields alias fields field) => HasErr (allFields :: [(Symbol, kind)]) alias (field' ': fields :: [(Symbol, kind)]) (field :: kind) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

(KnownSymbol alias, field0 ~ field1, MismatchError alias allFields field0 field1) => HasErr (allFields :: [(Symbol, k)]) alias ((alias ::: field0) ': fields :: [(Symbol, k)]) (field1 :: k) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

class All KnownSymbol aliases => HasAll (aliases :: [Symbol]) (fields :: [(Symbol, kind)]) (subfields :: [(Symbol, kind)]) | aliases fields -> subfields Source #

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)]) Source # 
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)]) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

class HasIn fields field Source #

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)) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Qualified Aliases

data QualifiedAlias (qualifier :: Symbol) (alias :: Symbol) Source #

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') Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias q -> Alias a -> QualifiedAlias q' a' Source #

(q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias q0 -> Alias a0 -> Aliased (QualifiedAlias q1) (a1 ::: a2) Source #

(q' ~ "public", a ~ a') => IsLabel a (QualifiedAlias q' a') Source # 
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)) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

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

Eq (QualifiedAlias qualifier alias) Source # 
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) Source # 
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) Source # 
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) Source # 
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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

rnf :: QualifiedAlias qualifier alias -> () #

(KnownSymbol q, KnownSymbol a) => RenderSQL (QualifiedAlias q a) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

type Rep (QualifiedAlias qualifier alias) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

type Rep (QualifiedAlias qualifier alias) = D1 ('MetaData "QualifiedAlias" "Squeal.PostgreSQL.Type.Alias" "squeal-postgresql-0.9.0.0-D17NIjlcsGRAwJTaCTXyvM" 'False) (C1 ('MetaCons "QualifiedAlias" 'PrefixI 'False) (U1 :: Type -> Type))

class IsQualified qualifier alias expression where Source #

Analagous to IsLabel, the constraint IsQualified defines ! for a column alias qualified by a table alias.

Methods

(!) :: Alias qualifier -> Alias alias -> expression infixl 9 Source #

Instances

Instances details
(q ~ q', a ~ a') => IsQualified q a (QualifiedAlias q' a') Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias q -> Alias a -> QualifiedAlias q' a' Source #

IsQualified qualifier alias (Alias qualifier, Alias alias) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias qualifier -> Alias alias -> (Alias qualifier, Alias alias) Source #

(Has rel rels cols, Has col cols ty, by ~ '(rel, col)) => IsQualified rel col (By rels by) Source # 
Instance details

Defined in Squeal.PostgreSQL.Query.Table

Methods

(!) :: Alias rel -> Alias col -> By rels by Source #

(q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Methods

(!) :: Alias q0 -> Alias a0 -> Aliased (QualifiedAlias q1) (a1 ::: a2) Source #

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

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

Defined in Squeal.PostgreSQL.Expression

Methods

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

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

Defined in Squeal.PostgreSQL.Query.Table

Methods

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

(Has tab (Join from lat) row, Has col row ty) => IsQualified tab col (AggregateArg '[ty] lat with db params from) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

(!) :: Alias tab -> Alias col -> AggregateArg '[ty] lat with db params from Source #

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

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

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

Defined in Squeal.PostgreSQL.Expression

Methods

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

(Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys) => IsQualified tab col (WindowArg ('Grouped bys) '[ty] lat with db params from) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

(!) :: Alias tab -> Alias col -> WindowArg ('Grouped bys) '[ty] lat with db params from Source #

(Has tab (Join from lat) row, Has col row ty) => IsQualified tab col (WindowArg 'Ungrouped '[ty] lat with db params from) Source # 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

(!) :: Alias tab -> Alias col -> WindowArg 'Ungrouped '[ty] lat with db params from Source #

(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) Source # 
Instance details

Defined in Squeal.PostgreSQL.Query.Select

Methods

(!) :: Alias tab -> Alias col -> Selection ('Grouped bys) lat with db params from row1 Source #

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

Defined in Squeal.PostgreSQL.Query.Select

Methods

(!) :: Alias tab -> Alias col -> Selection 'Ungrouped lat with db params from row1 Source #

Grouping

data Grouping Source #

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 column bys Source #

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)]) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

(KnownSymbol table, KnownSymbol column, GroupedBy table column bys) => GroupedBy table column (tabcol ': bys :: [a]) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Alias

Error reporting

type LookupFailedError needle haystack = LookupFailedError' (LookupFailedError' () (DefaultPrettyPrinter haystack) needle haystack) (PrettyPrintHaystack haystack) needle haystack Source #

LookupFailedError reports a nicer error when we fail to look up some needle in some haystack

type family PrettyPrintHaystack (haystack :: [(Symbol, k)]) :: PrettyPrintInfo Source #

PrettyPrintHaystack allows us to use the kind of our haystack to come up with nicer errors. It is implemented as an open type family for dependency reasons

Instances

Instances details
type PrettyPrintHaystack (haystack :: SchemasType) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

type PrettyPrintHaystack (haystack :: SchemasType) = 'PrettyPrintInfo ('Text "schema (SchemaType)") ('Text "database (SchemasType)") ('Text " " :<>: 'ShowType (Sort (MapFst haystack)))
type PrettyPrintHaystack (haystack :: SchemaType) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

type PrettyPrintHaystack (haystack :: SchemaType) = 'PrettyPrintInfo ('Text "table, view, typedef, index, function, or procedure (SchemumType)") ('Text "schema (SchemaType)") (PrettyPrintPartitionedSchema (PartitionSchema haystack))
type PrettyPrintHaystack (haystack :: FromType) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

type PrettyPrintHaystack (haystack :: FromType) = 'PrettyPrintInfo ('Text "row (RowType)") ('Text "from clause (FromType)") ('ShowType (Sort (MapFst haystack)))
type PrettyPrintHaystack (haystack :: TableConstraints) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

type PrettyPrintHaystack (haystack :: TableConstraints) = 'PrettyPrintInfo ('Text "constraint (TableConstraint)") ('Text "table (TableConstraints)") ('ShowType (Sort (MapFst haystack)))
type PrettyPrintHaystack (haystack :: ColumnsType) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

type PrettyPrintHaystack (haystack :: ColumnsType) = 'PrettyPrintInfo ('Text "column definition (ColumnType)") ('Text "table (ColumnsType)") ('ShowType (Sort (MapFst haystack)))
type PrettyPrintHaystack (haystack :: RowType) Source # 
Instance details

Defined in Squeal.PostgreSQL.Type.Schema

type PrettyPrintHaystack (haystack :: RowType) = 'PrettyPrintInfo ('Text "column (NullType)") ('Text "row (RowType)") ('ShowType (Sort (MapFst haystack)))

data PrettyPrintInfo Source #

PrettyPrintInfo is a data type intended to be used at the type level which describes how to pretty print a haystack in our custom errors. The general intention is we use PrettyPrintHaystack to define a more specific way of pretty printing our error information for each kind that we care about

type family MismatchError (alias :: Symbol) (fields :: [(Symbol, kind)]) (found :: kind) (expected :: kind) :: Constraint where ... Source #

MismatchError reports a nicer error with more context when we successfully do a lookup but find a different field than we expected. As a type family, it ensures that we only do the (expensive) calculation of coming up with our pretty printing information when we actually have a mismatch

Equations

MismatchError _ _ found found = () 
MismatchError alias fields found expected = MismatchError' (MismatchError' () (DefaultPrettyPrinter fields) alias fields found expected) (PrettyPrintHaystack fields) alias fields found expected 

type family LookupFailedError' (fallbackForUnknownKind :: Constraint) (prettyPrintInfo :: PrettyPrintInfo) (needle :: Symbol) (haystack :: [(Symbol, k)]) :: Constraint where ... Source #

LookupFailedError' is the workhorse behind LookupFailedError, but taking an additional type as the first argument. We can put another type error in there which will only show if LookupFailedError' is stuck; this allows us to fall back to DefaultPrettyPrinter when a PrettyPrintHaystack instance is missing

Equations

LookupFailedError' _ ('PrettyPrintInfo needleName haystackName prettyHaystack) needle rawHaystack = TypeError ((((((((('Text "Could not find " :<>: needleName) :<>: 'Text " named ") :<>: 'ShowType needle) :$$: (('Text "in " :<>: haystackName) :<>: 'Text ":")) :$$: prettyHaystack) :$$: 'Text "") :$$: (('Text "*Raw " :<>: haystackName) :<>: 'Text "*:")) :$$: 'ShowType rawHaystack) :$$: 'Text "") 

type family DefaultPrettyPrinter (haystack :: [(Symbol, k)]) :: PrettyPrintInfo where ... Source #

DefaultPrettyPrinter provides a default we can use for kinds that don't provide an instance of PrettyPrintInfo, although that should generally only be accidental

Equations

DefaultPrettyPrinter (haystack :: [(Symbol, k)]) = 'PrettyPrintInfo (('Text "some kind without a PrettyPrintHaystack instance (" :<>: 'ShowType k) :<>: 'Text ")") (('Text "associative list of that kind ([(Symbol, " :<>: 'ShowType k) :<>: 'Text ")])") ('ShowType (Sort (MapFst haystack))) 

type family MismatchError' (err :: Constraint) (ppInfo :: PrettyPrintInfo) (alias :: Symbol) (fields :: [(Symbol, kind)]) (found :: kind) (expected :: kind) :: Constraint where ... Source #

MismatchError' is the workhorse behind MismatchError, but taking an additional type as the first argument. We can put another type error in there which will only show if MismatchError' is stuck; this allows us to fall back to DefaultPrettyPrinter when a PrettyPrintHaystack instance is missing

Equations

MismatchError' _ ('PrettyPrintInfo needleName haystackName _) alias fields found expected = TypeError ((((((((('Text "Type mismatch when looking up " :<>: needleName) :<>: 'Text " named ") :<>: 'ShowType alias) :$$: (('Text "in " :<>: haystackName) :<>: 'Text ":")) :$$: 'ShowType fields) :$$: 'Text "") :$$: ('Text "Expected: " :<>: 'ShowType expected)) :$$: ('Text "But found: " :<>: 'ShowType found)) :$$: 'Text "")