-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | RDBMSs' schema templates for relational-query
--   
--   This package contains some RDBMSs' schema structure definitions.
--   
--   Supported RDBMS schemas are below:
--   
--   <ul>
--   <li>IBM DB2</li>
--   <li>PostgreSQL</li>
--   <li>Microsoft SQLServer</li>
--   <li>SQLite3</li>
--   <li>Oracle</li>
--   <li>MySQL</li>
--   </ul>
@package relational-schemas
@version 0.1.8.0


-- | Generate template of SYSCAT.columns system catalog table.
module Database.Relational.Schema.IBMDB2.Columns
data Columns
Columns :: !String -> !String -> !String -> !Int16 -> !String -> !String -> !Int32 -> !Int16 -> !Maybe String -> !String -> !Int16 -> !String -> !String -> !Int64 -> !Maybe String -> !Maybe String -> !Int32 -> !Maybe Int16 -> !Maybe Int16 -> !Int16 -> !Int16 -> !Int64 -> !Maybe String -> !Maybe String -> !Maybe String -> !Maybe String -> !Maybe String -> !Maybe String -> !Maybe String -> !Maybe String -> !String -> !Int32 -> !String -> !String -> !Maybe String -> !Maybe String -> Columns
[tabschema] :: Columns -> !String
[tabname] :: Columns -> !String
[colname] :: Columns -> !String
[colno] :: Columns -> !Int16
[typeschema] :: Columns -> !String
[typename] :: Columns -> !String
[length] :: Columns -> !Int32
[scale] :: Columns -> !Int16
[default_] :: Columns -> !Maybe String
[nulls] :: Columns -> !String
[codepage] :: Columns -> !Int16
[logged] :: Columns -> !String
[compact] :: Columns -> !String
[colcard] :: Columns -> !Int64
[high2key] :: Columns -> !Maybe String
[low2key] :: Columns -> !Maybe String
[avgcollen] :: Columns -> !Int32
[keyseq] :: Columns -> !Maybe Int16
[partkeyseq] :: Columns -> !Maybe Int16
[nquantiles] :: Columns -> !Int16
[nmostfreq] :: Columns -> !Int16
[numnulls] :: Columns -> !Int64
[targetTypeschema] :: Columns -> !Maybe String
[targetTypename] :: Columns -> !Maybe String
[scopeTabschema] :: Columns -> !Maybe String
[scopeTabname] :: Columns -> !Maybe String
[sourceTabschema] :: Columns -> !Maybe String
[sourceTabname] :: Columns -> !Maybe String
[dlFeatures] :: Columns -> !Maybe String
[specialProps] :: Columns -> !Maybe String
[hidden] :: Columns -> !String
[inlineLength] :: Columns -> !Int32
[identity] :: Columns -> !String
[generated] :: Columns -> !String
[text] :: Columns -> !Maybe String
[remarks] :: Columns -> !Maybe String
remarks' :: Pi Columns (Maybe String)
text' :: Pi Columns (Maybe String)
generated' :: Pi Columns String
identity' :: Pi Columns String
inlineLength' :: Pi Columns Int32
hidden' :: Pi Columns String
specialProps' :: Pi Columns (Maybe String)
dlFeatures' :: Pi Columns (Maybe String)
sourceTabname' :: Pi Columns (Maybe String)
sourceTabschema' :: Pi Columns (Maybe String)
scopeTabname' :: Pi Columns (Maybe String)
scopeTabschema' :: Pi Columns (Maybe String)
targetTypename' :: Pi Columns (Maybe String)
targetTypeschema' :: Pi Columns (Maybe String)
numnulls' :: Pi Columns Int64
nmostfreq' :: Pi Columns Int16
nquantiles' :: Pi Columns Int16
partkeyseq' :: Pi Columns (Maybe Int16)
keyseq' :: Pi Columns (Maybe Int16)
avgcollen' :: Pi Columns Int32
low2key' :: Pi Columns (Maybe String)
high2key' :: Pi Columns (Maybe String)
colcard' :: Pi Columns Int64
compact' :: Pi Columns String
logged' :: Pi Columns String
codepage' :: Pi Columns Int16
nulls' :: Pi Columns String
default' :: Pi Columns (Maybe String)
scale' :: Pi Columns Int16
length' :: Pi Columns Int32
typename' :: Pi Columns String
typeschema' :: Pi Columns String
colno' :: Pi Columns Int16
colname' :: Pi Columns String
tabname' :: Pi Columns String
tabschema' :: Pi Columns String
insertQueryColumns :: forall p_a6YN. Relation p_a6YN Columns -> InsertQuery p_a6YN
insertColumns :: Insert Columns
columns :: Relation () Columns
tableOfColumns :: Table Columns
columnOffsetsColumns :: Array Int Int
instance GHC.Generics.Generic Database.Relational.Schema.IBMDB2.Columns.Columns
instance GHC.Show.Show Database.Relational.Schema.IBMDB2.Columns.Columns
instance Database.Record.Persistable.PersistableWidth Database.Relational.Schema.IBMDB2.Columns.Columns
instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Base.String -> GHC.Base.String -> GHC.Base.String -> GHC.Int.Int16 -> GHC.Base.String -> GHC.Base.String -> GHC.Int.Int32 -> GHC.Int.Int16 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Base.String -> GHC.Int.Int16 -> GHC.Base.String -> GHC.Base.String -> GHC.Int.Int64 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Int.Int16 -> GHC.Maybe.Maybe GHC.Int.Int16 -> GHC.Int.Int16 -> GHC.Int.Int16 -> GHC.Int.Int64 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Base.String -> GHC.Int.Int32 -> GHC.Base.String -> GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> Database.Relational.Schema.IBMDB2.Columns.Columns)
instance Database.Relational.ProjectableClass.LiteralSQL Database.Relational.Schema.IBMDB2.Columns.Columns
instance Database.Relational.Table.TableDerivable Database.Relational.Schema.IBMDB2.Columns.Columns
instance Database.Relational.OverloadedProjection.HasProjection "tabschema" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "tabname" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "colname" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "colno" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Int.Int16
instance Database.Relational.OverloadedProjection.HasProjection "typeschema" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "typename" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "length" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "scale" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Int.Int16
instance Database.Relational.OverloadedProjection.HasProjection "default_" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "nulls" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "codepage" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Int.Int16
instance Database.Relational.OverloadedProjection.HasProjection "logged" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "compact" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "colcard" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Int.Int64
instance Database.Relational.OverloadedProjection.HasProjection "high2key" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "low2key" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "avgcollen" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "keyseq" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Int.Int16)
instance Database.Relational.OverloadedProjection.HasProjection "partkeyseq" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Int.Int16)
instance Database.Relational.OverloadedProjection.HasProjection "nquantiles" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Int.Int16
instance Database.Relational.OverloadedProjection.HasProjection "nmostfreq" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Int.Int16
instance Database.Relational.OverloadedProjection.HasProjection "numnulls" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Int.Int64
instance Database.Relational.OverloadedProjection.HasProjection "targetTypeschema" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "targetTypename" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "scopeTabschema" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "scopeTabname" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "sourceTabschema" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "sourceTabname" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "dlFeatures" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "specialProps" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "hidden" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "inlineLength" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "identity" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "generated" Database.Relational.Schema.IBMDB2.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "text" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "remarks" Database.Relational.Schema.IBMDB2.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)


-- | <i>Deprecated: import Database.Relational.Schema.IBMDB2.Columns
--   instead of this module.</i>
module Database.Relational.Schema.DB2Syscat.Columns


-- | <i>Deprecated: import config from Database.Relational.Schema.IBMDB2
--   instead of this module.</i>
module Database.Relational.Schema.DB2Syscat.Config

-- | Configuration parameter against IBM DB2.
config :: Config


-- | This module provides custom APIs with appropriate configuration for
--   IBMDB2.
module Database.Custom.IBMDB2

-- | <a>UniqueRelation</a> inferred from table.
derivedUniqueRelation :: TableDerivable r => Key Unique r k -> Record c k -> UniqueRelation () c r

-- | Typed <a>KeyUpdate</a> using inferred primary key.
primaryUpdate :: HasConstraintKey Primary r p => Table r -> KeyUpdate p r

-- | Typed <a>KeyUpdate</a> using specified constraint key.
updateByConstraintKey :: Table r -> Key c r p -> KeyUpdate p r

-- | Convert from Haskell type <tt>r</tt> into SQL value <tt>q</tt> list
--   expected by update form like
--   
--   <i>UPDATE <a>table</a> SET c0 = ?, c1 = ?, ..., cn = ? WHERE key0 = ?
--   AND key1 = ? AND key2 = ? ... </i>
--   
--   using derived <tt>RecordToSql</tt> proof object.
updateValuesWithKey :: ToSql q r => Pi r p -> r -> [q]

-- | Deprecated.
primary :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Query restricted with inferred primary key.
primarySelect :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Deprecated.
primary' :: PersistableWidth p => Key Primary a p -> Relation () a -> Relation p a

-- | Deprecated.
unique :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified unique key.
uniqueSelect :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified key.
specifiedKey :: PersistableWidth p => Pi a p -> Relation () a -> Relation p a

-- | Update statement for sequence table
updateNumber :: (PersistableWidth s, Integral i, LiteralSQL i) => i -> Sequence s i -> Update ()

-- | Update statement for sequence table
updateNumber' :: (PersistableWidth s, Integral i, LiteralSQL i) => Config -> i -> Sequence s i -> Update ()

-- | Unsafely apply sequence number. Only safe to build corresponding
--   record type.
($$) :: Binding r s i => (i -> r) -> Number r i -> r

-- | Unsafely apply sequence number.
($$!) :: (i -> r) -> Number r i -> r

-- | Get untyped sequence number.
extractNumber :: Number r i -> i

-- | Unsafely specify sequence number.
unsafeSpecifyNumber :: Binding r s i => i -> Number r i

-- | Derive <a>Sequence</a> from corresponding <a>Relation</a>
fromRelation :: Binding r s i => Relation () r -> Sequence s i

-- | Derive binding using primary key.
primaryBinding :: (TableDerivable r, SequenceDerivable s i, HasConstraintKey Primary r i) => SeqBinding r s i

-- | Unsafely specify binding between normal-table and sequence-table.
unsafeSpecifyBinding :: (TableDerivable r, SequenceDerivable s i) => Pi r i -> SeqBinding r s i

-- | Infer <a>Relation</a> of sequence table
seqRelation :: TableDerivable s => Sequence s i -> Relation () s

-- | Unsafely specify sequence table.
unsafeSpecifySequence :: TableDerivable s => (s -> i) -> Pi s i -> Sequence s i

-- | Basic record to express sequence-table. actual sequence-table is a
--   table which has only one column of integer type.
data Sequence s i

-- | <a>Sequence</a> derivation rule
class TableDerivable s => SequenceDerivable s i | s -> i
derivedSequence :: SequenceDerivable s i => Sequence s i

-- | Record to express binding between normal-table and sequence-table.
data SeqBinding r s i

-- | Derivation rule for binding between <a>Table</a> and <a>Sequence</a>
class (TableDerivable r, SequenceDerivable s i) => Binding r s i | r -> s
binding :: Binding r s i => SeqBinding r s i

-- | Sequence number type for record type <tt>r</tt>
data Number r i

-- | Make typed <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
delete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Table</a> and <a>Restrict</a>
--   computation.
typedDelete :: Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, <a>Table</a> and
--   <a>Restrict</a> computation.
typedDelete' :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make untyped delete SQL string from <a>Table</a> and <a>Restrict</a>
--   computation.
deleteSQL :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> String

-- | Table type inferred <a>InsertQuery</a>.
derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Table type inferred <a>InsertQuery</a>.
insertQuery' :: TableDerivable r => Config -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a>.
typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a> with configuration parameter.
typedInsertQuery' :: Config -> Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make untyped insert select SQL string from <a>Table</a>, <a>Pi</a> and
--   <a>Relation</a>.
insertQuerySQL :: Config -> Table r -> Pi r r' -> Relation p r' -> String

-- | Make typed <a>Insert</a> list from records list.
insertValueList :: (TableDerivable r, LiteralSQL r') => Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> list from <a>Config</a> and records list.
insertValueList' :: (TableDerivable r, LiteralSQL r') => Config -> Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> from <a>defaultConfig</a>, derived table and
--   monadic builded <a>Register</a> object.
derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
insertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Table</a> and monadic builded
--   <a>InsertTarget</a> object.
typedInsertValue :: Table r -> InsertTarget p r -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, <a>Table</a> and monadic
--   builded <a>InsertTarget</a> object.
typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p

-- | Table type inferred <a>Insert</a>.
derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Table type inferred <a>Insert</a>.
insert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a>.
typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a> with configuration parameter.
typedInsert' :: PersistableWidth r => Config -> Table r -> Pi r r' -> Insert r'

-- | Unsafely make typed <a>Insert</a> from single insert and chunked
--   insert SQL.
unsafeTypedInsert' :: String -> String -> Int -> Insert a

-- | Size to use chunked insert
chunkSizeOfInsert :: Insert a -> Int

-- | Statement to use chunked insert
untypeChunkInsert :: Insert a -> String

-- | Deprecated. use <a>updateAllColumn</a>.
derivedUpdateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation without placeholder other than target
--   table columns. Update target is all column.
updateAllColumnNoPH :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict ()) -> Update r

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Deprecated. use <a>updateAllColumn'</a>.
derivedUpdateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Table</a> and <a>Restrict</a>
--   computation. Update target is all column.
typedUpdateAllColumn :: PersistableWidth r => Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
update' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> using <a>defaultConfig</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate :: Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate' :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make untyped update SQL string from <a>Table</a> and <a>Assign</a>
--   computation.
updateSQL :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> String

-- | Unsafely make typed <a>Update</a> from SQL string.
unsafeTypedUpdate :: String -> Update p

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
keyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> object using derived info specified by
--   <a>Relation</a> type.
typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from <a>Table</a> and key columns selector
--   <a>Pi</a>.
typedKeyUpdate :: Table a -> Pi a p -> KeyUpdate p a

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery' :: Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery_ :: Config -> Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into untyped SQL query string.
relationalQuerySQL :: Config -> Relation p r -> QuerySuffix -> String

-- | Unsafely make typed <a>Query</a> from SQL string.
unsafeTypedQuery :: String -> Query p a

-- | Query type with place-holder parameter <tt>p</tt> and query result
--   type <tt>a</tt>.
newtype Query p a
Query :: String -> Query p a
[untypeQuery] :: Query p a -> String

-- | Update type with key type <tt>p</tt> and update record type
--   <tt>a</tt>. Columns to update are record columns other than key
--   columns, So place-holder parameter type is the same as record type
--   <tt>a</tt>.
data KeyUpdate p a
KeyUpdate :: Pi a p -> String -> KeyUpdate p a
[updateKey] :: KeyUpdate p a -> Pi a p
[untypeKeyUpdate] :: KeyUpdate p a -> String

-- | Update type with place-holder parameter <tt>p</tt>.
newtype Update p
Update :: String -> Update p
[untypeUpdate] :: Update p -> String

-- | Insert type to insert record type <tt>a</tt>.
data Insert a
Insert :: String -> Maybe (String, Int) -> Insert a
[untypeInsert] :: Insert a -> String
[chunkedInsert] :: Insert a -> Maybe (String, Int)

-- | InsertQuery type.
newtype InsertQuery p
InsertQuery :: String -> InsertQuery p
[untypeInsertQuery] :: InsertQuery p -> String

-- | Delete type with place-holder parameter <tt>p</tt>.
newtype Delete p
Delete :: String -> Delete p
[untypeDelete] :: Delete p -> String

-- | Untype interface for typed no-result type statments with single type
--   parameter which represents place-holder parameter <tt>p</tt>.
class UntypeableNoFetch (s :: Type -> Type)
untypeNoFetch :: UntypeableNoFetch s => s p -> String

-- | Make <a>StringSQL</a> strings of SQL INSERT strings from records list
sqlChunksFromRecordList :: LiteralSQL r' => Config -> Table r -> Pi r r' -> [r'] -> [StringSQL]

-- | Make <a>StringSQL</a> string of SQL INSERT statement from
--   <a>InsertTarget</a>
sqlFromInsertTarget :: Config -> Table r -> InsertTarget p r -> StringSQL

-- | Make <a>StringSQL</a> string of SQL INSERT record chunk statement from
--   <a>InsertTarget</a>
sqlChunkFromInsertTarget :: Config -> Table r -> InsertTarget p r -> (StringSQL, Int)

-- | parametalized <a>Register</a> monad from <a>Pi</a>
piRegister :: PersistableWidth r => Pi r r' -> Register r (PlaceHolders r')

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a> with
--   place-holder parameter <tt>p</tt>.
insertTarget' :: Register r (PlaceHolders p) -> InsertTarget p r

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a>.
insertTarget :: Register r () -> InsertTarget () r

-- | SQL SET clause and WHERE clause <a>StringSQL</a> string from
--   <a>Assign</a> computation.
sqlFromUpdateTarget :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> StringSQL

-- | Deprecated.
updateTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Deprecated.
updateTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict ()) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all. With placefolder type <tt>p</tt>.
liftTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all.
liftTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders ())) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Deprecated.
updateTarget' :: (Record Flat r -> Assign r (PlaceHolders p)) -> UpdateTarget p r

-- | Deprecated.
updateTarget :: (Record Flat r -> Assign r ()) -> UpdateTarget () r

-- | SQL WHERE clause <a>StringSQL</a> string from <a>Restrict</a>
--   computation.
sqlWhereFromRestriction :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> StringSQL

-- | Deprecated.
restriction' :: (Record Flat r -> Restrict (PlaceHolders p)) -> Restriction p r

-- | Deprecated.
restriction :: (Record Flat r -> Restrict ()) -> Restriction () r

-- | Restriction type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type Restriction p r = Record Flat r -> Restrict PlaceHolders p

-- | UpdateTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type UpdateTarget p r = Record Flat r -> Assign r PlaceHolders p

-- | InsertTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
data InsertTarget p r

-- | Intersection of two relations with place-holder parameters. Not
--   distinct.
intersectAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersectAll'`

-- | Intersection of two relations with place-holder parameters.
intersect' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersect'`

-- | Subtraction of two relations with place-holder parameters. Not
--   distinct.
exceptAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `exceptAll'`

-- | Subtraction of two relations with place-holder parameters.
except' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `except'`

-- | Union of two relations with place-holder parameters. Not distinct.
unionAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `unionAll'`

-- | Union of two relations with place-holder parameters.
union' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `union'`

-- | Intersection of two relations. Not distinct.
intersectAll :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersectAll`

-- | Intersection of two relations.
intersect :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersect`

-- | Subtraction of two relations. Not distinct.
exceptAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `exceptAll`

-- | Subtraction of two relations.
except :: Relation () a -> Relation () a -> Relation () a
infixl 7 `except`

-- | Union of two relations. Not distinct.
unionAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `unionAll`

-- | Union of two relations.
union :: Relation () a -> Relation () a -> Relation () a
infixl 7 `union`

-- | Apply restriction for direct join style.
on' :: ([JoinRestriction a b] -> Relation pc (a, b)) -> [JoinRestriction a b] -> Relation pc (a, b)
infixl 8 `on'`

-- | Direct full outer join.
full :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation () (Maybe a, Maybe b)
infixl 8 `full`

-- | Direct right outer join.
right :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) b] -> Relation () (Maybe a, b)
infixl 8 `right`

-- | Direct left outer join.
left :: Relation () a -> Relation () b -> [JoinRestriction a (Maybe b)] -> Relation () (a, Maybe b)
infixl 8 `left`

-- | Direct inner join.
inner :: Relation () a -> Relation () b -> [JoinRestriction a b] -> Relation () (a, b)
infixl 8 `inner`

-- | Direct full outer join with place-holder parameters.
full' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation (pa, pb) (Maybe a, Maybe b)
infixl 8 `full'`

-- | Direct right outer join with place-holder parameters.
right' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) b] -> Relation (pa, pb) (Maybe a, b)
infixl 8 `right'`

-- | Direct left outer join with place-holder parameters.
left' :: Relation pa a -> Relation pb b -> [JoinRestriction a (Maybe b)] -> Relation (pa, pb) (a, Maybe b)
infixl 8 `left'`

-- | Direct inner join with place-holder parameters.
inner' :: Relation pa a -> Relation pb b -> [JoinRestriction a b] -> Relation (pa, pb) (a, b)
infixl 8 `inner'`

-- | Restriction predicate function type for direct style join operator,
--   used on predicates of direct join style as follows.
--   
--   <pre>
--   do xy &lt;- query $
--            relX <a>inner</a> relY <a>on</a>` [ x y -&gt; ... ] -- this lambda form has JoinRestriction type
--      ...
--   </pre>
type JoinRestriction a b = Record Flat a -> Record Flat b -> Predicate Flat

-- | Scalar sub-query.
queryScalar :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation () c r -> m (Record c (Maybe r))

-- | Scalar sub-query with place-holder parameter <tt>p</tt>.
queryScalar' :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation p c r -> m (PlaceHolders p, Record c (Maybe r))

-- | Aggregated <a>UniqueRelation</a>.
aggregatedUnique :: Relation ph r -> Pi r a -> (Record Flat a -> Record Aggregated b) -> UniqueRelation ph Flat b

-- | Finalize <a>QueryUnique</a> monad and generate <a>UniqueRelation</a>.
uniqueRelation' :: QueryUnique (PlaceHolders p, Record c r) -> UniqueRelation p c r

-- | Join unique sub-query with place-holder parameter <tt>p</tt>. Query
--   result is <a>Maybe</a>.
uniqueQueryMaybe' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c (Maybe r))

-- | Join unique sub-query with place-holder parameter <tt>p</tt>.
uniqueQuery' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c r)

-- | Discard unique attribute.
unUnique :: UniqueRelation p c r -> Relation p r

-- | Unsafely specify unique relation.
unsafeUnique :: Relation p r -> UniqueRelation p c r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a>.
aggregateRelation :: QueryAggregate (Record Aggregated r) -> Relation () r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
aggregateRelation' :: AggregatedQuery p r -> Relation p r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a>.
relation :: QuerySimple (Record Flat r) -> Relation () r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
relation' :: SimpleQuery p r -> Relation p r

-- | List sub-query, for <i>IN</i> and <i>EXIST</i>.
queryList :: MonadQualify ConfigureQuery m => Relation () r -> m (RecordList (Record c) r)

-- | List sub-query, for <i>IN</i> and <i>EXIST</i> with place-holder
--   parameter <tt>p</tt>.
queryList' :: MonadQualify ConfigureQuery m => Relation p r -> m (PlaceHolders p, RecordList (Record c) r)

-- | Join sub-query. Query result is <a>Maybe</a>. The combinations of
--   <a>query</a> and <a>queryMaybe</a> express inner joins, left outer
--   joins, right outer joins, and full outer joins. Here is an example of
--   a right outer join:
--   
--   <pre>
--   outerJoin = relation $ do
--     e &lt;- queryMaybe employee
--     d &lt;- query department
--     on $ e ?! E.deptId' .=. just (d ! D.deptId')
--     return $ (,) |$| e |*| d
--   </pre>
queryMaybe :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat (Maybe r))

-- | Join sub-query. Query result is not <a>Maybe</a>.
query :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat r)

-- | Interface to derive <a>Table</a> type object.
tableOf :: TableDerivable r => Relation () r -> Table r

-- | Inferred <a>Relation</a>.
derivedRelation :: TableDerivable r => Relation () r

-- | Simple <a>Relation</a> from <a>Table</a>.
table :: Table r -> Relation () r

-- | Unique relation type to compose scalar queries.
data UniqueRelation p c r

-- | Operator to make record of window function result using built
--   <a>Window</a> monad.
over :: SqlContext c => Record OverWindow a -> Window c () -> Record c a
infix 8 `over`

-- | Aggregated query monad type.
type QueryAggregate = Orderings Aggregated Restrictings Aggregated AggregatingSetT QueryCore

-- | Aggregated query type. <a>AggregatedQuery</a> p r ==
--   <a>QueryAggregate</a> (<a>PlaceHolders</a> p, <a>Record</a>
--   <a>Aggregated</a> r).
type AggregatedQuery p r = OrderedQuery Aggregated Restrictings Aggregated AggregatingSetT QueryCore p r

-- | Partition monad type for partition-by clause.
type Window c = Orderings c PartitioningSet c

-- | Finalize grouping set list.
groupingSets :: AggregatingSetList a -> AggregateKey a

-- | Finalize grouping power set as cube power set.
cube :: AggregatingPowerSet a -> AggregateKey a

-- | Finalize grouping power set as rollup power set.
rollup :: AggregatingPowerSet a -> AggregateKey a

-- | Specify key of rollup and cube power set.
bkey :: Record Flat r -> AggregatingPowerSet (Record Aggregated (Maybe r))

-- | Finalize and specify single grouping set.
set :: AggregatingSet a -> AggregatingSetList a

-- | Specify key of single grouping set.
key' :: AggregateKey a -> AggregatingSet a

-- | Specify key of single grouping set from Record.
key :: Record Flat r -> AggregatingSet (Record Aggregated (Maybe r))

-- | Target update monad type used from update statement and merge
--   statement.
type Assign r = Assignings r Restrict

-- | Target register monad type used from insert statement.
type Register r = Assignings r ConfigureQuery

-- | Add and assginment.
(<-#) :: forall (m :: Type -> Type) r v. Monad m => AssignTarget r v -> Record Flat v -> Assignings r m ()
infix 4 <-#

-- | Add an assignment.
assignTo :: forall (m :: Type -> Type) v r. Monad m => Record Flat v -> AssignTarget r v -> Assignings r m ()

-- | Simple (not-aggregated) query monad type.
type QuerySimple = Orderings Flat QueryCore

-- | Simple (not-aggregated) query type. <tt>SimpleQuery'</tt> p r ==
--   <a>QuerySimple</a> (<a>PlaceHolders</a> p, <a>Record</a> r).
type SimpleQuery p r = OrderedQuery Flat QueryCore p r

-- | Unique query monad type.
data QueryUnique a

-- | Extract <a>QueryCore</a> computation.
extractCore :: QueryCore a -> ConfigureQuery (((a, [Predicate Flat]), JoinProduct), Duplication)

-- | Core query monad type used from flat(not-aggregated) query and
--   aggregated query.
type QueryCore = Restrictings Flat QueryJoin ConfigureQuery

-- | OrderedQuery monad type with placeholder type <tt>p</tt>. Record must
--   be the same as <a>Orderings</a> context type parameter <tt>c</tt>.
type OrderedQuery c (m :: Type -> Type) p r = Orderings c m (PlaceHolders p, Record c r)

-- | Add descendant ordering term.
desc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ascendant ordering term.
asc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ordering terms.
orderBy :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Orderings c m ()

-- | Add ordering terms with null ordering.
orderBy' :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Nulls -> Orderings c m ()

-- | Type to accumulate ordering context. Type <tt>c</tt> is ordering term
--   record context type.
data Orderings c (m :: Type -> Type) a

-- | Restrict only monad type used from update statement and delete
--   statement.
type Restrict = Restrictings Flat ConfigureQuery

-- | Add restriction to this aggregated query. Aggregated Record type
--   version.
having :: MonadRestrict Aggregated m => Predicate Aggregated -> m ()

-- | Add restriction to this not aggregated query.
wheres :: MonadRestrict Flat m => Predicate Flat -> m ()

-- | Add restriction to last join. Record type version.
on :: MonadQuery m => Predicate Flat -> m ()

-- | Specify DISTINCT attribute to query context.
distinct :: MonadQuery m => m ()

-- | Specify ALL attribute to query context.
all' :: MonadQuery m => m ()

-- | Restrict context interface
class (Functor m, Monad m) => MonadRestrict c (m :: Type -> Type)

-- | Add restriction to this context.
restrict :: MonadRestrict c m => Predicate c -> m ()

-- | Query building interface.
class (Functor m, Monad m, MonadQualify ConfigureQuery m) => MonadQuery (m :: Type -> Type)

-- | Join sub-query with place-holder parameter <tt>p</tt>. query result is
--   not <a>Maybe</a>.
query' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat r)

-- | Join sub-query with place-holder parameter <tt>p</tt>. Query result is
--   <a>Maybe</a>.
queryMaybe' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat (Maybe r))

-- | Lift interface from base qualify monad.
class (Functor q, Monad q, Functor m, Monad m) => MonadQualify (q :: Type -> Type) (m :: Type -> Type)

-- | Aggregated query building interface extends <a>MonadQuery</a>.
class MonadQuery m => MonadAggregate (m :: Type -> Type)

-- | Add <i>GROUP BY</i> term into context and get aggregated record.
groupBy :: MonadAggregate m => Record Flat r -> m (Record Aggregated r)
groupBy' :: MonadAggregate m => AggregateKey (Record Aggregated r) -> m (Record Aggregated r)

-- | Window specification building interface.
class Monad m => MonadPartition c (m :: Type -> Type)

-- | Add <i>PARTITION BY</i> term into context.
partitionBy :: MonadPartition c m => Record c r -> m ()

-- | Same as <a>(?!?)</a>. Use this operator like '(?? #foo) mayX'.
(??) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ??

-- | Same as <a>(?!)</a>. Use this operator like '(? #foo) mayX'.
(?) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
(!??) :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c
infixl 8 !??

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
flattenPiMaybe :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c

-- | Get narrower record along with projection path and project into result
--   record type. Source record <a>Maybe</a> phantom functor and projection
--   path leaf <a>Maybe</a> functor are <tt>join</tt>-ed.
(?!?) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ?!?

-- | Get narrower record along with projection path <a>Maybe</a> phantom
--   functor is <a>map</a>-ed.
(?!) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?!

-- | Get narrower record along with projection path.
(!) :: PersistableWidth a => Record c a -> Pi a b -> Record c b
infixl 8 !

-- | Aggregation function SOME.
some' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function ANY.
any' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function EVERY.
every :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function MIN.
min' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MIN.
minMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function MAX.
max' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MAX.
maxMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function AVG.
avg :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe b)

-- | Aggregation function AVG.
avgMaybe :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe b)

-- | Aggregation function SUM.
sum' :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function SUM.
sumMaybe :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function COUNT.
count :: (Integral b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac b

-- | Unsafely make aggregation uni-operator from SQL keyword.
unsafeAggregateOp :: (AggregatedContext ac, SqlContext ac) => Keyword -> Record Flat a -> Record ac b

-- | Binary operator the same as <a>projectZip</a>.
(><) :: ProductIsoApplicative p => p a -> p b -> p (a, b)
infixl 1 ><

-- | Zipping projections.
projectZip :: ProductIsoApplicative p => p a -> p b -> p (a, b)

-- | Provide scoped placeholder and return its parameter object. Monadic
--   version.
placeholder :: (PersistableWidth t, SqlContext c, Monad m) => (Record c t -> m a) -> m (PlaceHolders t, a)

-- | Provide scoped placeholder and return its parameter object.
placeholder' :: (PersistableWidth t, SqlContext c) => (Record c t -> a) -> (PlaceHolders t, a)

-- | Provide scoped placeholder from width and return its parameter object.
pwPlaceholder :: SqlContext c => PersistableRecordWidth a -> (Record c a -> b) -> (PlaceHolders a, b)

-- | No placeholder semantics. Same as <a>unitPlaceHolder</a>
unitPH :: PlaceHolders ()

-- | No placeholder semantics
unitPlaceHolder :: PlaceHolders ()

-- | Unsafely get placeholder parameter
unsafePlaceHolders :: PlaceHolders p

-- | Unsafely add placeholder parameter to queries.
unsafeAddPlaceHolders :: Functor f => f a -> f (PlaceHolders p, a)

-- | <i>CUME_DIST()</i> term.
cumeDist :: Record OverWindow Double

-- | <i>PERCENT_RANK()</i> term.
percentRank :: Record OverWindow Double

-- | <i>ROW_NUMBER()</i> term.
rowNumber :: Integral a => Record OverWindow a

-- | <i>DENSE_RANK()</i> term.
denseRank :: Integral a => Record OverWindow a

-- | <i>RANK()</i> term.
rank :: Integral a => Record OverWindow a

-- | Operator from maybe type using record extended <tt>isNull</tt>.
fromMaybe :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c r -> Record c (Maybe r) -> Record c r

-- | Operator corresponding SQL <i>NOT (... IS NULL)</i> , and extended
--   against record type.
isJust :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Operator corresponding SQL <i>IS NULL</i> , and extended against
--   record types.
isNothing :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Binary operator corresponding SQL <i>IN</i> .
in' :: OperatorContext c => Record c t -> RecordList (Record c) t -> Record c (Maybe Bool)
infix 4 `in'`

-- | Null default version of <a>case'</a>.
caseMaybe :: (OperatorContext c, PersistableWidth b) => Record c a -> [(Record c a, Record c (Maybe b))] -> Record c (Maybe b)

-- | Uncurry version of <a>case'</a>, and you can write like ...
--   <a>casesOrElse</a>` <a>clause</a>.
casesOrElse' :: OperatorContext c => (Record c a, [(Record c a, Record c b)]) -> Record c b -> Record c b

-- | Simple case operator correnponding SQL simple <i>CASE</i>. Like,
--   <i>CASE x WHEN v THEN a WHEN w THEN b ... ELSE c END</i>
case' :: OperatorContext c => Record c a -> [(Record c a, Record c b)] -> Record c b -> Record c b

-- | Null default version of <a>caseSearch</a>.
caseSearchMaybe :: (OperatorContext c, PersistableWidth a) => [(Predicate c, Record c (Maybe a))] -> Record c (Maybe a)

-- | Same as <a>caseSearch</a>, but you can write like <a>list</a>
--   <a>casesOrElse</a> <a>clause</a>.
casesOrElse :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Search case operator correnponding SQL search <i>CASE</i>. Like,
--   <i>CASE WHEN p0 THEN a WHEN p1 THEN b ... ELSE c END</i>
caseSearch :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Unsafely show number into string-like type in records.
showNumMaybe :: (SqlContext c, Num a, IsString b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number fromIntegral uni-operator.
fromIntegralMaybe :: (SqlContext c, Integral a, Num b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negateMaybe :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a)

-- | Number operator corresponding SQL <i>*</i> .
(?*?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?*?

-- | Number operator corresponding SQL /// .
(?/?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?/?

-- | Number operator corresponding SQL <i>-</i> .
(?-?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?-?

-- | Number operator corresponding SQL <i>+</i> .
(?+?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?+?

-- | Unsafely show number into string-like type in records.
showNum :: (SqlContext c, Num a, IsString b) => Record c a -> Record c b

-- | Number fromIntegral uni-operator.
fromIntegral' :: (SqlContext c, Integral a, Num b) => Record c a -> Record c b

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negate' :: (OperatorContext c, Num a) => Record c a -> Record c a

-- | Number operator corresponding SQL <i>*</i> .
(.*.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 .*.

-- | Number operator corresponding SQL /// .
(./.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 ./.

-- | Number operator corresponding SQL <i>-</i> .
(.-.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .-.

-- | Number operator corresponding SQL <i>+</i> .
(.+.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .+.

-- | String-compare operator corresponding SQL <i>LIKE</i> . Maybe type
--   version.
likeMaybe :: (OperatorContext c, IsString a, LiteralSQL a) => Record c (Maybe a) -> a -> Record c (Maybe Bool)
infix 4 `likeMaybe`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like :: (OperatorContext c, IsString a, LiteralSQL a) => Record c a -> a -> Record c (Maybe Bool)
infix 4 `like`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
likeMaybe' :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe Bool)
infix 4 `likeMaybe'`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like' :: (OperatorContext c, IsString a) => Record c a -> Record c a -> Record c (Maybe Bool)
infix 4 `like'`

-- | Concatinate operator corresponding SQL <i>||</i> . Maybe type version.
(?||?) :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 5 ?||?

-- | Concatinate operator corresponding SQL <i>||</i> .
(.||.) :: OperatorContext c => Record c a -> Record c a -> Record c a
infixl 5 .||.

-- | Logical operator corresponding SQL <i>EXISTS</i> .
exists :: OperatorContext c => RecordList (Record Exists) r -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>NOT</i> .
not' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>OR</i> .
or' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 2 `or'`

-- | Logical operator corresponding SQL <i>AND</i> .
and' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 3 `and'`

-- | Compare operator corresponding SQL <i>&lt;&gt;</i> .
(.<>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<>.

-- | Compare operator corresponding SQL <i>&gt;=</i> .
(.>=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>=.

-- | Compare operator corresponding SQL <i>&gt;</i> .
(.>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>.

-- | Compare operator corresponding SQL <i>&lt;=</i> .
(.<=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<=.

-- | Compare operator corresponding SQL <i>&lt;</i> .
(.<.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<.

-- | Compare operator corresponding SQL <i>=</i> .
(.=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .=.

-- | Unsafely make binary operator for records from string binary operator.
unsafeBinOp :: SqlContext k => SqlBinOp -> Record k a -> Record k b -> Record k c

-- | Unsafely make unary operator for records from SQL keyword.
unsafeUniOp :: SqlContext c2 => (Keyword -> Keyword) -> Record c1 a -> Record c2 b

-- | Unsafely generate SQL expression string from record object. String
--   interface of <a>unsafeShowSql'</a>.
unsafeShowSql :: Record c a -> String

-- | Unsafely generate SQL expression term from record object.
unsafeShowSql' :: Record c a -> StringSQL

-- | RecordList with polymorphic type of SQL set value from Haskell list.
values :: (LiteralSQL t, OperatorContext c) => [t] -> RecordList (Record c) t

-- | Record with polymorphic type of SQL false value.
valueFalse :: OperatorContext c => Record c (Maybe Bool)

-- | Record with polymorphic type of SQL true value.
valueTrue :: OperatorContext c => Record c (Maybe Bool)

-- | Generate record with polymorphic type of SQL constant values from
--   Haskell value.
value :: (LiteralSQL t, OperatorContext c) => t -> Record c t

-- | Record with polymorphic phantom type of SQL null value. Semantics of
--   comparing is unsafe.
nothing :: (OperatorContext c, SqlContext c, PersistableWidth a) => Record c (Maybe a)

-- | Unsafely Project single SQL string. String interface of
--   <tt>unsafeProjectSql''</tt>.
unsafeProjectSql :: SqlContext c => String -> Record c t

-- | Unsafely Project single SQL term.
unsafeProjectSql' :: SqlContext c => StringSQL -> Record c t

-- | Binary operator type for SQL String.
type SqlBinOp = Keyword -> Keyword -> Keyword

-- | Interface to control <a>Maybe</a> of phantom type in records.
class ProjectableMaybe (p :: Type -> Type)

-- | Cast record phantom type into <a>Maybe</a>.
just :: ProjectableMaybe p => p a -> p (Maybe a)

-- | Compose nested <a>Maybe</a> phantom type on record.
flattenMaybe :: ProjectableMaybe p => p (Maybe (Maybe a)) -> p (Maybe a)

-- | Interface to compose phantom <a>Maybe</a> nested type.
class ProjectableFlattenMaybe a b
flatten :: (ProjectableFlattenMaybe a b, ProjectableMaybe p) => p a -> p b

-- | Projection path for snd of tuple.
snd' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) b

-- | Projection path for fst of tuple.
fst' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) a
tuplePi7_6' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a7
tuplePi7_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a6
tuplePi7_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a5
tuplePi7_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a4
tuplePi7_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a3
tuplePi7_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a2
tuplePi7_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a1
tuplePi6_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a6
tuplePi6_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a5
tuplePi6_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a4
tuplePi6_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a3
tuplePi6_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a2
tuplePi6_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a1
tuplePi5_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a5
tuplePi5_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a4
tuplePi5_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a3
tuplePi5_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a2
tuplePi5_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a1
tuplePi4_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a4
tuplePi4_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a3
tuplePi4_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a2
tuplePi4_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a1
tuplePi3_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a3
tuplePi3_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a2
tuplePi3_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a1
tuplePi2_1' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a2
tuplePi2_0' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a1

-- | Generate update SQL specified by single key.
updateOtherThanKeySQL :: Table r -> Pi r p -> String

-- | Type for query suffix words
type QuerySuffix = [Keyword]

-- | Make projected record list from <a>Record</a> list.
list :: [p t] -> RecordList p t

-- | Projected record list type for row list.
data RecordList (p :: Type -> Type) t

-- | Phantom typed table type
data Table r

-- | Inference rule of <a>Table</a> existence.
class PersistableWidth r => TableDerivable r
derivedTable :: TableDerivable r => Table r

-- | Dump internal structure tree.
dump :: Relation p r -> String

-- | SQL string from <a>Relation</a>.
sqlFromRelation :: Relation p r -> StringSQL

-- | Generate SQL string from <a>Relation</a> with configuration.
sqlFromRelationWith :: Relation p r -> Config -> StringSQL

-- | Simplify placeholder type applying right identity element.
leftPh :: Relation (p, ()) r -> Relation p r

-- | Simplify placeholder type applying left identity element.
rightPh :: Relation ((), p) r -> Relation p r

-- | <a>PersistableRecordWidth</a> of <a>Relation</a> type.
relationWidth :: Relation p r -> PersistableRecordWidth r

-- | Sub-query Qualify monad from relation.
untypeRelation :: Relation p r -> ConfigureQuery SubQuery

-- | Unsafely type qualified subquery into record typed relation type.
unsafeTypeRelation :: ConfigureQuery SubQuery -> Relation p r

-- | Read configuration.
askConfig :: ConfigureQuery Config

-- | Get qualifyed table form query.
qualifyQuery :: a -> ConfigureQuery (Qualified a)

-- | Run <a>ConfigureQuery</a> monad with initial state to get only result.
configureQuery :: ConfigureQuery q -> Config -> q

-- | Thin monad type for untyped structure.
type ConfigureQuery = Qualify QueryConfig Identity

-- | Relation type with place-holder parameter <tt>p</tt> and query result
--   type <tt>r</tt>.
data Relation p r

-- | Interface to project SQL terms unsafely.
class SqlContext c

-- | Unsafely project from SQL expression terms.
unsafeProjectSqlTerms :: SqlContext c => [StringSQL] -> Record c t

-- | Placeholder parameter type which has real parameter type arguemnt
--   <tt>p</tt>.
data PlaceHolders p

-- | SQL string for nested-qeury.
unitSQL :: SubQuery -> String

-- | Width of <a>Qualified</a> <tt>SubQUery</tt>.
queryWidth :: Qualified SubQuery -> Int

-- | Order direction. Ascendant or Descendant.
data Order
Asc :: Order
Desc :: Order

-- | Order of null.
data Nulls
NullsFirst :: Nulls
NullsLast :: Nulls

-- | Typeful aggregate element.
data AggregateKey a

-- | Sub-query type
data SubQuery

-- | Phantom typed record. Projected into Haskell record type <tt>t</tt>.
data Record c t

-- | Type for predicate to restrict of query result.
type Predicate c = Record c Maybe Bool

-- | Type for projection function.
type PI c a b = Record c a -> Record c b

-- | Constraint which represents scalar degree.
class PersistableWidth ct => ScalarDegree ct

-- | Deprecated.
showConstantTermsSQL :: ShowConstantTermsSQL a => a -> [StringSQL]
showConstantTermsSQL' :: ShowConstantTermsSQL a => a -> DList StringSQL

-- | Convert from haskell record to SQL literal row-value.
showLiteral :: LiteralSQL a => a -> [StringSQL]

-- | <a>LiteralSQL</a> <tt>a</tt> is implicit rule to derive function to
--   convert from haskell record type <tt>a</tt> into SQL literal
--   row-value.
--   
--   Generic programming
--   (<a>https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#generic-programming</a>)
--   with default signature is available for <a>LiteralSQL</a> class, so
--   you can make instance like below:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   import GHC.Generics (Generic)
--   --
--   data Foo = Foo { ... } deriving Generic
--   instance LiteralSQL Foo
--   </pre>
class LiteralSQL a
showLiteral' :: LiteralSQL a => a -> DList StringSQL

-- | Deprecated.
type ShowConstantTermsSQL = LiteralSQL

-- | Inferred <a>Unique</a> constraint <a>Key</a>. Record type <tt>r</tt>
--   has unique key which type is <tt>ct</tt> derived from primay key.
derivedUniqueKey :: HasConstraintKey Primary r ct => Key Unique r ct

-- | Derive <a>Unique</a> constraint <a>Key</a> from <a>Primary</a>
--   constraint <a>Key</a>
uniqueKey :: PersistableWidth ct => Key Primary r ct -> Key Unique r ct

-- | Get projection path proof object from constraint <a>Key</a>.
projectionKey :: Key c r ct -> Pi r ct

-- | Get table constraint <a>KeyConstraint</a> proof object from constraint
--   <a>Key</a>.
tableConstraint :: Key c r ct -> KeyConstraint c r

-- | Constraint Key proof object. Constraint type <tt>c</tt>, record type
--   <tt>r</tt> and columns type <tt>ct</tt>.
data Key c r ct

-- | Constraint <a>Key</a> inference interface.
class PersistableWidth ct => HasConstraintKey c r ct

-- | Infer constraint key.
constraintKey :: HasConstraintKey c r ct => Key c r ct

-- | Identity projection path.
id' :: Pi a a

-- | Compose projection path. <a>Maybe</a> phantom functors are
--   <tt>join</tt>-ed like <tt>&gt;=&gt;</tt>.
(<?.?>) :: Pi a (Maybe b) -> Pi b (Maybe c) -> Pi a (Maybe c)
infixl 8 <?.?>

-- | Compose projection path. <a>Maybe</a> phantom functor is
--   <a>map</a>-ed.
(<?.>) :: Pi a (Maybe b) -> Pi b c -> Pi a (Maybe c)
infixl 8 <?.>

-- | Compose projection path.
(<.>) :: Pi a b -> Pi b c -> Pi a c
infixl 8 <.>

-- | Expand indexes from key. Infered width version.
expandIndexes :: PersistableWidth a => Pi a b -> [Int]

-- | Expand indexes from key.
expandIndexes' :: PersistableRecordWidth a -> Pi a b -> [Int]

-- | Projection path from type <tt>r0</tt> into type <tt>r1</tt>. This type
--   also indicate key object which type is <tt>r1</tt> for record type
--   <tt>r0</tt>.
data Pi r0 r1

-- | String wrap type for SQL strings.
type StringSQL = Keyword

-- | Type tag for flat (not-aggregated) query
data Flat

-- | Type tag for aggregated query
data Aggregated

-- | Type tag for exists predicate
data Exists

-- | Type tag for window function building
data OverWindow

-- | Type tag for normal aggregatings set
data Set

-- | Type tag for aggregatings GROUPING SETS
data SetList

-- | Type tag for aggregatings power set
data Power

-- | Default configuration of <a>Config</a>. To change some behaviour of
--   relational-query, use record update syntax:
--   
--   <pre>
--   defaultConfig
--     { productUnitSupport            =  <a>PUSupported</a>
--     , chunksInsertSize              =  256
--     , schemaNameMode                =  <a>SchemaQualified</a>
--     , normalizedTableName           =  True
--     , addQueryTableAliasAS          =  False
--     , addModifyTableAliasAS         =  False
--     , enableWarning                 =  True
--     , verboseAsCompilerWarning      =  False
--     , disableOverloadedProjection   =  False
--     , disableSpecializedProjection  =  False
--     , identifierQuotation           =  <a>NoQuotation</a>
--     , nameConfig                    =
--        defaultNameConfig
--        { recordConfig     =  <a>defaultNameConfig</a>
--        , relationVarName  =  \schema table -&gt; <a>varCamelcaseName</a> $ table ++ "_" ++ scheme
--        -- ^ append the table name after the schema name. e.g. "schemaTable"
--        }
--     }
--   </pre>
defaultConfig :: Config

-- | Default implementation of <a>NameConfig</a> type.
defaultNameConfig :: NameConfig

-- | <a>NameConfig</a> type to customize names of expanded templates.
data NameConfig

-- | Unit of product is supported or not.
data ProductUnitSupport
PUSupported :: ProductUnitSupport
PUNotSupported :: ProductUnitSupport

-- | Schema name qualify mode in SQL string.
data SchemaNameMode

-- | Schema qualified table name in SQL string
SchemaQualified :: SchemaNameMode

-- | Not qualified table name in SQL string
SchemaNotQualified :: SchemaNameMode

-- | Configuration for quotation of identifiers of SQL.
data IdentifierQuotation
NoQuotation :: IdentifierQuotation
Quotation :: Char -> IdentifierQuotation

-- | Configuration type.
data Config
data Primary
data NotNull
data Unique

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery :: Relation p r -> [Keyword] -> Query p r

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object.
insertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object with no(unit) placeholder.
insertValueNoPH :: TableDerivable r => Register r () -> Insert ()

-- | Make <a>InsertQuery</a> from derived table, <a>Pi</a> and
--   <a>Relation</a>.
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation.
update :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation
--   with no(unit) placeholder.
updateNoPH :: TableDerivable r => (Record Flat r -> Assign r ()) -> Update ()

-- | Make <a>Delete</a> from derived table and <a>Restrict</a> computation.
delete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation with no(unit) placeholder.
deleteNoPH :: TableDerivable r => (Record Flat r -> Restrict ()) -> Delete ()


-- | This module implements queries to get table schema and table
--   constraint informations from system catalog of IBM DB2.
module Database.Relational.Schema.IBMDB2

-- | Configuration parameter against IBM DB2.
config :: Config

-- | Normalize column name string to query DB2 system catalog
normalizeColumn :: String -> String

-- | Not-null attribute information of column.
notNull :: Columns -> Bool

-- | Get column normalized name and column Haskell type.
getType :: Map String TypeQ -> Columns -> Maybe (String, TypeQ)

-- | Phantom typed <a>Query</a> to get <a>Columns</a> from schema name and
--   table name.
columnsQuerySQL :: Query (String, String) Columns

-- | Phantom typed <a>Query</a> to get primary key name from schema name
--   and table name.
primaryKeyQuerySQL :: Query (String, String) String

module Database.Relational.Schema.MySQL.Columns
data Columns
Columns :: !String -> !String -> !String -> !Int16 -> !Maybe String -> !String -> !String -> Columns
[tableSchema] :: Columns -> !String
[tableName] :: Columns -> !String
[columnName] :: Columns -> !String
[ordinalPosition] :: Columns -> !Int16
[columnDefault] :: Columns -> !Maybe String
[isNullable] :: Columns -> !String
[dataType] :: Columns -> !String
dataType' :: Pi Columns String
isNullable' :: Pi Columns String
columnDefault' :: Pi Columns (Maybe String)
ordinalPosition' :: Pi Columns Int16
columnName' :: Pi Columns String
tableName' :: Pi Columns String
tableSchema' :: Pi Columns String
insertQueryColumns :: forall p_asif. Relation p_asif Columns -> InsertQuery p_asif
insertColumns :: Insert Columns
columns :: Relation () Columns
tableOfColumns :: Table Columns
columnOffsetsColumns :: Array Int Int
instance GHC.Generics.Generic Database.Relational.Schema.MySQL.Columns.Columns
instance GHC.Show.Show Database.Relational.Schema.MySQL.Columns.Columns
instance Database.Record.Persistable.PersistableWidth Database.Relational.Schema.MySQL.Columns.Columns
instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Base.String -> GHC.Base.String -> GHC.Base.String -> GHC.Int.Int16 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Base.String -> GHC.Base.String -> Database.Relational.Schema.MySQL.Columns.Columns)
instance Database.Relational.ProjectableClass.LiteralSQL Database.Relational.Schema.MySQL.Columns.Columns
instance Database.Relational.Table.TableDerivable Database.Relational.Schema.MySQL.Columns.Columns
instance Database.Relational.OverloadedProjection.HasProjection "tableSchema" Database.Relational.Schema.MySQL.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "tableName" Database.Relational.Schema.MySQL.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "columnName" Database.Relational.Schema.MySQL.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "ordinalPosition" Database.Relational.Schema.MySQL.Columns.Columns GHC.Int.Int16
instance Database.Relational.OverloadedProjection.HasProjection "columnDefault" Database.Relational.Schema.MySQL.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "isNullable" Database.Relational.Schema.MySQL.Columns.Columns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "dataType" Database.Relational.Schema.MySQL.Columns.Columns GHC.Base.String


-- | This module provides custom APIs with appropriate configuration for
--   MySQL.
module Database.Custom.MySQL

-- | <a>UniqueRelation</a> inferred from table.
derivedUniqueRelation :: TableDerivable r => Key Unique r k -> Record c k -> UniqueRelation () c r

-- | Typed <a>KeyUpdate</a> using inferred primary key.
primaryUpdate :: HasConstraintKey Primary r p => Table r -> KeyUpdate p r

-- | Typed <a>KeyUpdate</a> using specified constraint key.
updateByConstraintKey :: Table r -> Key c r p -> KeyUpdate p r

-- | Convert from Haskell type <tt>r</tt> into SQL value <tt>q</tt> list
--   expected by update form like
--   
--   <i>UPDATE <a>table</a> SET c0 = ?, c1 = ?, ..., cn = ? WHERE key0 = ?
--   AND key1 = ? AND key2 = ? ... </i>
--   
--   using derived <tt>RecordToSql</tt> proof object.
updateValuesWithKey :: ToSql q r => Pi r p -> r -> [q]

-- | Deprecated.
primary :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Query restricted with inferred primary key.
primarySelect :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Deprecated.
primary' :: PersistableWidth p => Key Primary a p -> Relation () a -> Relation p a

-- | Deprecated.
unique :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified unique key.
uniqueSelect :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified key.
specifiedKey :: PersistableWidth p => Pi a p -> Relation () a -> Relation p a

-- | Update statement for sequence table
updateNumber :: (PersistableWidth s, Integral i, LiteralSQL i) => i -> Sequence s i -> Update ()

-- | Update statement for sequence table
updateNumber' :: (PersistableWidth s, Integral i, LiteralSQL i) => Config -> i -> Sequence s i -> Update ()

-- | Unsafely apply sequence number. Only safe to build corresponding
--   record type.
($$) :: Binding r s i => (i -> r) -> Number r i -> r

-- | Unsafely apply sequence number.
($$!) :: (i -> r) -> Number r i -> r

-- | Get untyped sequence number.
extractNumber :: Number r i -> i

-- | Unsafely specify sequence number.
unsafeSpecifyNumber :: Binding r s i => i -> Number r i

-- | Derive <a>Sequence</a> from corresponding <a>Relation</a>
fromRelation :: Binding r s i => Relation () r -> Sequence s i

-- | Derive binding using primary key.
primaryBinding :: (TableDerivable r, SequenceDerivable s i, HasConstraintKey Primary r i) => SeqBinding r s i

-- | Unsafely specify binding between normal-table and sequence-table.
unsafeSpecifyBinding :: (TableDerivable r, SequenceDerivable s i) => Pi r i -> SeqBinding r s i

-- | Infer <a>Relation</a> of sequence table
seqRelation :: TableDerivable s => Sequence s i -> Relation () s

-- | Unsafely specify sequence table.
unsafeSpecifySequence :: TableDerivable s => (s -> i) -> Pi s i -> Sequence s i

-- | Basic record to express sequence-table. actual sequence-table is a
--   table which has only one column of integer type.
data Sequence s i

-- | <a>Sequence</a> derivation rule
class TableDerivable s => SequenceDerivable s i | s -> i
derivedSequence :: SequenceDerivable s i => Sequence s i

-- | Record to express binding between normal-table and sequence-table.
data SeqBinding r s i

-- | Derivation rule for binding between <a>Table</a> and <a>Sequence</a>
class (TableDerivable r, SequenceDerivable s i) => Binding r s i | r -> s
binding :: Binding r s i => SeqBinding r s i

-- | Sequence number type for record type <tt>r</tt>
data Number r i

-- | Make typed <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
delete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Table</a> and <a>Restrict</a>
--   computation.
typedDelete :: Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, <a>Table</a> and
--   <a>Restrict</a> computation.
typedDelete' :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make untyped delete SQL string from <a>Table</a> and <a>Restrict</a>
--   computation.
deleteSQL :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> String

-- | Table type inferred <a>InsertQuery</a>.
derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Table type inferred <a>InsertQuery</a>.
insertQuery' :: TableDerivable r => Config -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a>.
typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a> with configuration parameter.
typedInsertQuery' :: Config -> Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make untyped insert select SQL string from <a>Table</a>, <a>Pi</a> and
--   <a>Relation</a>.
insertQuerySQL :: Config -> Table r -> Pi r r' -> Relation p r' -> String

-- | Make typed <a>Insert</a> list from records list.
insertValueList :: (TableDerivable r, LiteralSQL r') => Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> list from <a>Config</a> and records list.
insertValueList' :: (TableDerivable r, LiteralSQL r') => Config -> Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> from <a>defaultConfig</a>, derived table and
--   monadic builded <a>Register</a> object.
derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
insertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Table</a> and monadic builded
--   <a>InsertTarget</a> object.
typedInsertValue :: Table r -> InsertTarget p r -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, <a>Table</a> and monadic
--   builded <a>InsertTarget</a> object.
typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p

-- | Table type inferred <a>Insert</a>.
derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Table type inferred <a>Insert</a>.
insert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a>.
typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a> with configuration parameter.
typedInsert' :: PersistableWidth r => Config -> Table r -> Pi r r' -> Insert r'

-- | Unsafely make typed <a>Insert</a> from single insert and chunked
--   insert SQL.
unsafeTypedInsert' :: String -> String -> Int -> Insert a

-- | Size to use chunked insert
chunkSizeOfInsert :: Insert a -> Int

-- | Statement to use chunked insert
untypeChunkInsert :: Insert a -> String

-- | Deprecated. use <a>updateAllColumn</a>.
derivedUpdateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation without placeholder other than target
--   table columns. Update target is all column.
updateAllColumnNoPH :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict ()) -> Update r

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Deprecated. use <a>updateAllColumn'</a>.
derivedUpdateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Table</a> and <a>Restrict</a>
--   computation. Update target is all column.
typedUpdateAllColumn :: PersistableWidth r => Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
update' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> using <a>defaultConfig</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate :: Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate' :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make untyped update SQL string from <a>Table</a> and <a>Assign</a>
--   computation.
updateSQL :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> String

-- | Unsafely make typed <a>Update</a> from SQL string.
unsafeTypedUpdate :: String -> Update p

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
keyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> object using derived info specified by
--   <a>Relation</a> type.
typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from <a>Table</a> and key columns selector
--   <a>Pi</a>.
typedKeyUpdate :: Table a -> Pi a p -> KeyUpdate p a

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery' :: Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery_ :: Config -> Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into untyped SQL query string.
relationalQuerySQL :: Config -> Relation p r -> QuerySuffix -> String

-- | Unsafely make typed <a>Query</a> from SQL string.
unsafeTypedQuery :: String -> Query p a

-- | Query type with place-holder parameter <tt>p</tt> and query result
--   type <tt>a</tt>.
newtype Query p a
Query :: String -> Query p a
[untypeQuery] :: Query p a -> String

-- | Update type with key type <tt>p</tt> and update record type
--   <tt>a</tt>. Columns to update are record columns other than key
--   columns, So place-holder parameter type is the same as record type
--   <tt>a</tt>.
data KeyUpdate p a
KeyUpdate :: Pi a p -> String -> KeyUpdate p a
[updateKey] :: KeyUpdate p a -> Pi a p
[untypeKeyUpdate] :: KeyUpdate p a -> String

-- | Update type with place-holder parameter <tt>p</tt>.
newtype Update p
Update :: String -> Update p
[untypeUpdate] :: Update p -> String

-- | Insert type to insert record type <tt>a</tt>.
data Insert a
Insert :: String -> Maybe (String, Int) -> Insert a
[untypeInsert] :: Insert a -> String
[chunkedInsert] :: Insert a -> Maybe (String, Int)

-- | InsertQuery type.
newtype InsertQuery p
InsertQuery :: String -> InsertQuery p
[untypeInsertQuery] :: InsertQuery p -> String

-- | Delete type with place-holder parameter <tt>p</tt>.
newtype Delete p
Delete :: String -> Delete p
[untypeDelete] :: Delete p -> String

-- | Untype interface for typed no-result type statments with single type
--   parameter which represents place-holder parameter <tt>p</tt>.
class UntypeableNoFetch (s :: Type -> Type)
untypeNoFetch :: UntypeableNoFetch s => s p -> String

-- | Make <a>StringSQL</a> strings of SQL INSERT strings from records list
sqlChunksFromRecordList :: LiteralSQL r' => Config -> Table r -> Pi r r' -> [r'] -> [StringSQL]

-- | Make <a>StringSQL</a> string of SQL INSERT statement from
--   <a>InsertTarget</a>
sqlFromInsertTarget :: Config -> Table r -> InsertTarget p r -> StringSQL

-- | Make <a>StringSQL</a> string of SQL INSERT record chunk statement from
--   <a>InsertTarget</a>
sqlChunkFromInsertTarget :: Config -> Table r -> InsertTarget p r -> (StringSQL, Int)

-- | parametalized <a>Register</a> monad from <a>Pi</a>
piRegister :: PersistableWidth r => Pi r r' -> Register r (PlaceHolders r')

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a> with
--   place-holder parameter <tt>p</tt>.
insertTarget' :: Register r (PlaceHolders p) -> InsertTarget p r

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a>.
insertTarget :: Register r () -> InsertTarget () r

-- | SQL SET clause and WHERE clause <a>StringSQL</a> string from
--   <a>Assign</a> computation.
sqlFromUpdateTarget :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> StringSQL

-- | Deprecated.
updateTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Deprecated.
updateTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict ()) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all. With placefolder type <tt>p</tt>.
liftTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all.
liftTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders ())) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Deprecated.
updateTarget' :: (Record Flat r -> Assign r (PlaceHolders p)) -> UpdateTarget p r

-- | Deprecated.
updateTarget :: (Record Flat r -> Assign r ()) -> UpdateTarget () r

-- | SQL WHERE clause <a>StringSQL</a> string from <a>Restrict</a>
--   computation.
sqlWhereFromRestriction :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> StringSQL

-- | Deprecated.
restriction' :: (Record Flat r -> Restrict (PlaceHolders p)) -> Restriction p r

-- | Deprecated.
restriction :: (Record Flat r -> Restrict ()) -> Restriction () r

-- | Restriction type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type Restriction p r = Record Flat r -> Restrict PlaceHolders p

-- | UpdateTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type UpdateTarget p r = Record Flat r -> Assign r PlaceHolders p

-- | InsertTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
data InsertTarget p r

-- | Intersection of two relations with place-holder parameters. Not
--   distinct.
intersectAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersectAll'`

-- | Intersection of two relations with place-holder parameters.
intersect' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersect'`

-- | Subtraction of two relations with place-holder parameters. Not
--   distinct.
exceptAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `exceptAll'`

-- | Subtraction of two relations with place-holder parameters.
except' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `except'`

-- | Union of two relations with place-holder parameters. Not distinct.
unionAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `unionAll'`

-- | Union of two relations with place-holder parameters.
union' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `union'`

-- | Intersection of two relations. Not distinct.
intersectAll :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersectAll`

-- | Intersection of two relations.
intersect :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersect`

-- | Subtraction of two relations. Not distinct.
exceptAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `exceptAll`

-- | Subtraction of two relations.
except :: Relation () a -> Relation () a -> Relation () a
infixl 7 `except`

-- | Union of two relations. Not distinct.
unionAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `unionAll`

-- | Union of two relations.
union :: Relation () a -> Relation () a -> Relation () a
infixl 7 `union`

-- | Apply restriction for direct join style.
on' :: ([JoinRestriction a b] -> Relation pc (a, b)) -> [JoinRestriction a b] -> Relation pc (a, b)
infixl 8 `on'`

-- | Direct full outer join.
full :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation () (Maybe a, Maybe b)
infixl 8 `full`

-- | Direct right outer join.
right :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) b] -> Relation () (Maybe a, b)
infixl 8 `right`

-- | Direct left outer join.
left :: Relation () a -> Relation () b -> [JoinRestriction a (Maybe b)] -> Relation () (a, Maybe b)
infixl 8 `left`

-- | Direct inner join.
inner :: Relation () a -> Relation () b -> [JoinRestriction a b] -> Relation () (a, b)
infixl 8 `inner`

-- | Direct full outer join with place-holder parameters.
full' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation (pa, pb) (Maybe a, Maybe b)
infixl 8 `full'`

-- | Direct right outer join with place-holder parameters.
right' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) b] -> Relation (pa, pb) (Maybe a, b)
infixl 8 `right'`

-- | Direct left outer join with place-holder parameters.
left' :: Relation pa a -> Relation pb b -> [JoinRestriction a (Maybe b)] -> Relation (pa, pb) (a, Maybe b)
infixl 8 `left'`

-- | Direct inner join with place-holder parameters.
inner' :: Relation pa a -> Relation pb b -> [JoinRestriction a b] -> Relation (pa, pb) (a, b)
infixl 8 `inner'`

-- | Restriction predicate function type for direct style join operator,
--   used on predicates of direct join style as follows.
--   
--   <pre>
--   do xy &lt;- query $
--            relX <a>inner</a> relY <a>on</a>` [ x y -&gt; ... ] -- this lambda form has JoinRestriction type
--      ...
--   </pre>
type JoinRestriction a b = Record Flat a -> Record Flat b -> Predicate Flat

-- | Scalar sub-query.
queryScalar :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation () c r -> m (Record c (Maybe r))

-- | Scalar sub-query with place-holder parameter <tt>p</tt>.
queryScalar' :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation p c r -> m (PlaceHolders p, Record c (Maybe r))

-- | Aggregated <a>UniqueRelation</a>.
aggregatedUnique :: Relation ph r -> Pi r a -> (Record Flat a -> Record Aggregated b) -> UniqueRelation ph Flat b

-- | Finalize <a>QueryUnique</a> monad and generate <a>UniqueRelation</a>.
uniqueRelation' :: QueryUnique (PlaceHolders p, Record c r) -> UniqueRelation p c r

-- | Join unique sub-query with place-holder parameter <tt>p</tt>. Query
--   result is <a>Maybe</a>.
uniqueQueryMaybe' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c (Maybe r))

-- | Join unique sub-query with place-holder parameter <tt>p</tt>.
uniqueQuery' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c r)

-- | Discard unique attribute.
unUnique :: UniqueRelation p c r -> Relation p r

-- | Unsafely specify unique relation.
unsafeUnique :: Relation p r -> UniqueRelation p c r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a>.
aggregateRelation :: QueryAggregate (Record Aggregated r) -> Relation () r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
aggregateRelation' :: AggregatedQuery p r -> Relation p r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a>.
relation :: QuerySimple (Record Flat r) -> Relation () r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
relation' :: SimpleQuery p r -> Relation p r

-- | List sub-query, for <i>IN</i> and <i>EXIST</i>.
queryList :: MonadQualify ConfigureQuery m => Relation () r -> m (RecordList (Record c) r)

-- | List sub-query, for <i>IN</i> and <i>EXIST</i> with place-holder
--   parameter <tt>p</tt>.
queryList' :: MonadQualify ConfigureQuery m => Relation p r -> m (PlaceHolders p, RecordList (Record c) r)

-- | Join sub-query. Query result is <a>Maybe</a>. The combinations of
--   <a>query</a> and <a>queryMaybe</a> express inner joins, left outer
--   joins, right outer joins, and full outer joins. Here is an example of
--   a right outer join:
--   
--   <pre>
--   outerJoin = relation $ do
--     e &lt;- queryMaybe employee
--     d &lt;- query department
--     on $ e ?! E.deptId' .=. just (d ! D.deptId')
--     return $ (,) |$| e |*| d
--   </pre>
queryMaybe :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat (Maybe r))

-- | Join sub-query. Query result is not <a>Maybe</a>.
query :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat r)

-- | Interface to derive <a>Table</a> type object.
tableOf :: TableDerivable r => Relation () r -> Table r

-- | Inferred <a>Relation</a>.
derivedRelation :: TableDerivable r => Relation () r

-- | Simple <a>Relation</a> from <a>Table</a>.
table :: Table r -> Relation () r

-- | Unique relation type to compose scalar queries.
data UniqueRelation p c r

-- | Operator to make record of window function result using built
--   <a>Window</a> monad.
over :: SqlContext c => Record OverWindow a -> Window c () -> Record c a
infix 8 `over`

-- | Aggregated query monad type.
type QueryAggregate = Orderings Aggregated Restrictings Aggregated AggregatingSetT QueryCore

-- | Aggregated query type. <a>AggregatedQuery</a> p r ==
--   <a>QueryAggregate</a> (<a>PlaceHolders</a> p, <a>Record</a>
--   <a>Aggregated</a> r).
type AggregatedQuery p r = OrderedQuery Aggregated Restrictings Aggregated AggregatingSetT QueryCore p r

-- | Partition monad type for partition-by clause.
type Window c = Orderings c PartitioningSet c

-- | Finalize grouping set list.
groupingSets :: AggregatingSetList a -> AggregateKey a

-- | Finalize grouping power set as cube power set.
cube :: AggregatingPowerSet a -> AggregateKey a

-- | Finalize grouping power set as rollup power set.
rollup :: AggregatingPowerSet a -> AggregateKey a

-- | Specify key of rollup and cube power set.
bkey :: Record Flat r -> AggregatingPowerSet (Record Aggregated (Maybe r))

-- | Finalize and specify single grouping set.
set :: AggregatingSet a -> AggregatingSetList a

-- | Specify key of single grouping set.
key' :: AggregateKey a -> AggregatingSet a

-- | Specify key of single grouping set from Record.
key :: Record Flat r -> AggregatingSet (Record Aggregated (Maybe r))

-- | Target update monad type used from update statement and merge
--   statement.
type Assign r = Assignings r Restrict

-- | Target register monad type used from insert statement.
type Register r = Assignings r ConfigureQuery

-- | Add and assginment.
(<-#) :: forall (m :: Type -> Type) r v. Monad m => AssignTarget r v -> Record Flat v -> Assignings r m ()
infix 4 <-#

-- | Add an assignment.
assignTo :: forall (m :: Type -> Type) v r. Monad m => Record Flat v -> AssignTarget r v -> Assignings r m ()

-- | Simple (not-aggregated) query monad type.
type QuerySimple = Orderings Flat QueryCore

-- | Simple (not-aggregated) query type. <tt>SimpleQuery'</tt> p r ==
--   <a>QuerySimple</a> (<a>PlaceHolders</a> p, <a>Record</a> r).
type SimpleQuery p r = OrderedQuery Flat QueryCore p r

-- | Unique query monad type.
data QueryUnique a

-- | Extract <a>QueryCore</a> computation.
extractCore :: QueryCore a -> ConfigureQuery (((a, [Predicate Flat]), JoinProduct), Duplication)

-- | Core query monad type used from flat(not-aggregated) query and
--   aggregated query.
type QueryCore = Restrictings Flat QueryJoin ConfigureQuery

-- | OrderedQuery monad type with placeholder type <tt>p</tt>. Record must
--   be the same as <a>Orderings</a> context type parameter <tt>c</tt>.
type OrderedQuery c (m :: Type -> Type) p r = Orderings c m (PlaceHolders p, Record c r)

-- | Add descendant ordering term.
desc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ascendant ordering term.
asc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ordering terms.
orderBy :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Orderings c m ()

-- | Add ordering terms with null ordering.
orderBy' :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Nulls -> Orderings c m ()

-- | Type to accumulate ordering context. Type <tt>c</tt> is ordering term
--   record context type.
data Orderings c (m :: Type -> Type) a

-- | Restrict only monad type used from update statement and delete
--   statement.
type Restrict = Restrictings Flat ConfigureQuery

-- | Add restriction to this aggregated query. Aggregated Record type
--   version.
having :: MonadRestrict Aggregated m => Predicate Aggregated -> m ()

-- | Add restriction to this not aggregated query.
wheres :: MonadRestrict Flat m => Predicate Flat -> m ()

-- | Add restriction to last join. Record type version.
on :: MonadQuery m => Predicate Flat -> m ()

-- | Specify DISTINCT attribute to query context.
distinct :: MonadQuery m => m ()

-- | Specify ALL attribute to query context.
all' :: MonadQuery m => m ()

-- | Restrict context interface
class (Functor m, Monad m) => MonadRestrict c (m :: Type -> Type)

-- | Add restriction to this context.
restrict :: MonadRestrict c m => Predicate c -> m ()

-- | Query building interface.
class (Functor m, Monad m, MonadQualify ConfigureQuery m) => MonadQuery (m :: Type -> Type)

-- | Join sub-query with place-holder parameter <tt>p</tt>. query result is
--   not <a>Maybe</a>.
query' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat r)

-- | Join sub-query with place-holder parameter <tt>p</tt>. Query result is
--   <a>Maybe</a>.
queryMaybe' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat (Maybe r))

-- | Lift interface from base qualify monad.
class (Functor q, Monad q, Functor m, Monad m) => MonadQualify (q :: Type -> Type) (m :: Type -> Type)

-- | Aggregated query building interface extends <a>MonadQuery</a>.
class MonadQuery m => MonadAggregate (m :: Type -> Type)

-- | Add <i>GROUP BY</i> term into context and get aggregated record.
groupBy :: MonadAggregate m => Record Flat r -> m (Record Aggregated r)
groupBy' :: MonadAggregate m => AggregateKey (Record Aggregated r) -> m (Record Aggregated r)

-- | Window specification building interface.
class Monad m => MonadPartition c (m :: Type -> Type)

-- | Add <i>PARTITION BY</i> term into context.
partitionBy :: MonadPartition c m => Record c r -> m ()

-- | Same as <a>(?!?)</a>. Use this operator like '(?? #foo) mayX'.
(??) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ??

-- | Same as <a>(?!)</a>. Use this operator like '(? #foo) mayX'.
(?) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
(!??) :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c
infixl 8 !??

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
flattenPiMaybe :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c

-- | Get narrower record along with projection path and project into result
--   record type. Source record <a>Maybe</a> phantom functor and projection
--   path leaf <a>Maybe</a> functor are <tt>join</tt>-ed.
(?!?) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ?!?

-- | Get narrower record along with projection path <a>Maybe</a> phantom
--   functor is <a>map</a>-ed.
(?!) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?!

-- | Get narrower record along with projection path.
(!) :: PersistableWidth a => Record c a -> Pi a b -> Record c b
infixl 8 !

-- | Aggregation function SOME.
some' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function ANY.
any' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function EVERY.
every :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function MIN.
min' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MIN.
minMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function MAX.
max' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MAX.
maxMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function AVG.
avg :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe b)

-- | Aggregation function AVG.
avgMaybe :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe b)

-- | Aggregation function SUM.
sum' :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function SUM.
sumMaybe :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function COUNT.
count :: (Integral b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac b

-- | Unsafely make aggregation uni-operator from SQL keyword.
unsafeAggregateOp :: (AggregatedContext ac, SqlContext ac) => Keyword -> Record Flat a -> Record ac b

-- | Binary operator the same as <a>projectZip</a>.
(><) :: ProductIsoApplicative p => p a -> p b -> p (a, b)
infixl 1 ><

-- | Zipping projections.
projectZip :: ProductIsoApplicative p => p a -> p b -> p (a, b)

-- | Provide scoped placeholder and return its parameter object. Monadic
--   version.
placeholder :: (PersistableWidth t, SqlContext c, Monad m) => (Record c t -> m a) -> m (PlaceHolders t, a)

-- | Provide scoped placeholder and return its parameter object.
placeholder' :: (PersistableWidth t, SqlContext c) => (Record c t -> a) -> (PlaceHolders t, a)

-- | Provide scoped placeholder from width and return its parameter object.
pwPlaceholder :: SqlContext c => PersistableRecordWidth a -> (Record c a -> b) -> (PlaceHolders a, b)

-- | No placeholder semantics. Same as <a>unitPlaceHolder</a>
unitPH :: PlaceHolders ()

-- | No placeholder semantics
unitPlaceHolder :: PlaceHolders ()

-- | Unsafely get placeholder parameter
unsafePlaceHolders :: PlaceHolders p

-- | Unsafely add placeholder parameter to queries.
unsafeAddPlaceHolders :: Functor f => f a -> f (PlaceHolders p, a)

-- | <i>CUME_DIST()</i> term.
cumeDist :: Record OverWindow Double

-- | <i>PERCENT_RANK()</i> term.
percentRank :: Record OverWindow Double

-- | <i>ROW_NUMBER()</i> term.
rowNumber :: Integral a => Record OverWindow a

-- | <i>DENSE_RANK()</i> term.
denseRank :: Integral a => Record OverWindow a

-- | <i>RANK()</i> term.
rank :: Integral a => Record OverWindow a

-- | Operator from maybe type using record extended <tt>isNull</tt>.
fromMaybe :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c r -> Record c (Maybe r) -> Record c r

-- | Operator corresponding SQL <i>NOT (... IS NULL)</i> , and extended
--   against record type.
isJust :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Operator corresponding SQL <i>IS NULL</i> , and extended against
--   record types.
isNothing :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Binary operator corresponding SQL <i>IN</i> .
in' :: OperatorContext c => Record c t -> RecordList (Record c) t -> Record c (Maybe Bool)
infix 4 `in'`

-- | Null default version of <a>case'</a>.
caseMaybe :: (OperatorContext c, PersistableWidth b) => Record c a -> [(Record c a, Record c (Maybe b))] -> Record c (Maybe b)

-- | Uncurry version of <a>case'</a>, and you can write like ...
--   <a>casesOrElse</a>` <a>clause</a>.
casesOrElse' :: OperatorContext c => (Record c a, [(Record c a, Record c b)]) -> Record c b -> Record c b

-- | Simple case operator correnponding SQL simple <i>CASE</i>. Like,
--   <i>CASE x WHEN v THEN a WHEN w THEN b ... ELSE c END</i>
case' :: OperatorContext c => Record c a -> [(Record c a, Record c b)] -> Record c b -> Record c b

-- | Null default version of <a>caseSearch</a>.
caseSearchMaybe :: (OperatorContext c, PersistableWidth a) => [(Predicate c, Record c (Maybe a))] -> Record c (Maybe a)

-- | Same as <a>caseSearch</a>, but you can write like <a>list</a>
--   <a>casesOrElse</a> <a>clause</a>.
casesOrElse :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Search case operator correnponding SQL search <i>CASE</i>. Like,
--   <i>CASE WHEN p0 THEN a WHEN p1 THEN b ... ELSE c END</i>
caseSearch :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Unsafely show number into string-like type in records.
showNumMaybe :: (SqlContext c, Num a, IsString b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number fromIntegral uni-operator.
fromIntegralMaybe :: (SqlContext c, Integral a, Num b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negateMaybe :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a)

-- | Number operator corresponding SQL <i>*</i> .
(?*?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?*?

-- | Number operator corresponding SQL /// .
(?/?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?/?

-- | Number operator corresponding SQL <i>-</i> .
(?-?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?-?

-- | Number operator corresponding SQL <i>+</i> .
(?+?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?+?

-- | Unsafely show number into string-like type in records.
showNum :: (SqlContext c, Num a, IsString b) => Record c a -> Record c b

-- | Number fromIntegral uni-operator.
fromIntegral' :: (SqlContext c, Integral a, Num b) => Record c a -> Record c b

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negate' :: (OperatorContext c, Num a) => Record c a -> Record c a

-- | Number operator corresponding SQL <i>*</i> .
(.*.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 .*.

-- | Number operator corresponding SQL /// .
(./.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 ./.

-- | Number operator corresponding SQL <i>-</i> .
(.-.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .-.

-- | Number operator corresponding SQL <i>+</i> .
(.+.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .+.

-- | String-compare operator corresponding SQL <i>LIKE</i> . Maybe type
--   version.
likeMaybe :: (OperatorContext c, IsString a, LiteralSQL a) => Record c (Maybe a) -> a -> Record c (Maybe Bool)
infix 4 `likeMaybe`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like :: (OperatorContext c, IsString a, LiteralSQL a) => Record c a -> a -> Record c (Maybe Bool)
infix 4 `like`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
likeMaybe' :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe Bool)
infix 4 `likeMaybe'`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like' :: (OperatorContext c, IsString a) => Record c a -> Record c a -> Record c (Maybe Bool)
infix 4 `like'`

-- | Concatinate operator corresponding SQL <i>||</i> . Maybe type version.
(?||?) :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 5 ?||?

-- | Concatinate operator corresponding SQL <i>||</i> .
(.||.) :: OperatorContext c => Record c a -> Record c a -> Record c a
infixl 5 .||.

-- | Logical operator corresponding SQL <i>EXISTS</i> .
exists :: OperatorContext c => RecordList (Record Exists) r -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>NOT</i> .
not' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>OR</i> .
or' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 2 `or'`

-- | Logical operator corresponding SQL <i>AND</i> .
and' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 3 `and'`

-- | Compare operator corresponding SQL <i>&lt;&gt;</i> .
(.<>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<>.

-- | Compare operator corresponding SQL <i>&gt;=</i> .
(.>=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>=.

-- | Compare operator corresponding SQL <i>&gt;</i> .
(.>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>.

-- | Compare operator corresponding SQL <i>&lt;=</i> .
(.<=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<=.

-- | Compare operator corresponding SQL <i>&lt;</i> .
(.<.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<.

-- | Compare operator corresponding SQL <i>=</i> .
(.=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .=.

-- | Unsafely make binary operator for records from string binary operator.
unsafeBinOp :: SqlContext k => SqlBinOp -> Record k a -> Record k b -> Record k c

-- | Unsafely make unary operator for records from SQL keyword.
unsafeUniOp :: SqlContext c2 => (Keyword -> Keyword) -> Record c1 a -> Record c2 b

-- | Unsafely generate SQL expression string from record object. String
--   interface of <a>unsafeShowSql'</a>.
unsafeShowSql :: Record c a -> String

-- | Unsafely generate SQL expression term from record object.
unsafeShowSql' :: Record c a -> StringSQL

-- | RecordList with polymorphic type of SQL set value from Haskell list.
values :: (LiteralSQL t, OperatorContext c) => [t] -> RecordList (Record c) t

-- | Record with polymorphic type of SQL false value.
valueFalse :: OperatorContext c => Record c (Maybe Bool)

-- | Record with polymorphic type of SQL true value.
valueTrue :: OperatorContext c => Record c (Maybe Bool)

-- | Generate record with polymorphic type of SQL constant values from
--   Haskell value.
value :: (LiteralSQL t, OperatorContext c) => t -> Record c t

-- | Record with polymorphic phantom type of SQL null value. Semantics of
--   comparing is unsafe.
nothing :: (OperatorContext c, SqlContext c, PersistableWidth a) => Record c (Maybe a)

-- | Unsafely Project single SQL string. String interface of
--   <tt>unsafeProjectSql''</tt>.
unsafeProjectSql :: SqlContext c => String -> Record c t

-- | Unsafely Project single SQL term.
unsafeProjectSql' :: SqlContext c => StringSQL -> Record c t

-- | Binary operator type for SQL String.
type SqlBinOp = Keyword -> Keyword -> Keyword

-- | Interface to control <a>Maybe</a> of phantom type in records.
class ProjectableMaybe (p :: Type -> Type)

-- | Cast record phantom type into <a>Maybe</a>.
just :: ProjectableMaybe p => p a -> p (Maybe a)

-- | Compose nested <a>Maybe</a> phantom type on record.
flattenMaybe :: ProjectableMaybe p => p (Maybe (Maybe a)) -> p (Maybe a)

-- | Interface to compose phantom <a>Maybe</a> nested type.
class ProjectableFlattenMaybe a b
flatten :: (ProjectableFlattenMaybe a b, ProjectableMaybe p) => p a -> p b

-- | Projection path for snd of tuple.
snd' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) b

-- | Projection path for fst of tuple.
fst' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) a
tuplePi7_6' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a7
tuplePi7_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a6
tuplePi7_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a5
tuplePi7_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a4
tuplePi7_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a3
tuplePi7_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a2
tuplePi7_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a1
tuplePi6_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a6
tuplePi6_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a5
tuplePi6_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a4
tuplePi6_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a3
tuplePi6_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a2
tuplePi6_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a1
tuplePi5_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a5
tuplePi5_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a4
tuplePi5_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a3
tuplePi5_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a2
tuplePi5_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a1
tuplePi4_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a4
tuplePi4_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a3
tuplePi4_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a2
tuplePi4_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a1
tuplePi3_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a3
tuplePi3_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a2
tuplePi3_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a1
tuplePi2_1' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a2
tuplePi2_0' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a1

-- | Generate update SQL specified by single key.
updateOtherThanKeySQL :: Table r -> Pi r p -> String

-- | Type for query suffix words
type QuerySuffix = [Keyword]

-- | Make projected record list from <a>Record</a> list.
list :: [p t] -> RecordList p t

-- | Projected record list type for row list.
data RecordList (p :: Type -> Type) t

-- | Phantom typed table type
data Table r

-- | Inference rule of <a>Table</a> existence.
class PersistableWidth r => TableDerivable r
derivedTable :: TableDerivable r => Table r

-- | Dump internal structure tree.
dump :: Relation p r -> String

-- | SQL string from <a>Relation</a>.
sqlFromRelation :: Relation p r -> StringSQL

-- | Generate SQL string from <a>Relation</a> with configuration.
sqlFromRelationWith :: Relation p r -> Config -> StringSQL

-- | Simplify placeholder type applying right identity element.
leftPh :: Relation (p, ()) r -> Relation p r

-- | Simplify placeholder type applying left identity element.
rightPh :: Relation ((), p) r -> Relation p r

-- | <a>PersistableRecordWidth</a> of <a>Relation</a> type.
relationWidth :: Relation p r -> PersistableRecordWidth r

-- | Sub-query Qualify monad from relation.
untypeRelation :: Relation p r -> ConfigureQuery SubQuery

-- | Unsafely type qualified subquery into record typed relation type.
unsafeTypeRelation :: ConfigureQuery SubQuery -> Relation p r

-- | Read configuration.
askConfig :: ConfigureQuery Config

-- | Get qualifyed table form query.
qualifyQuery :: a -> ConfigureQuery (Qualified a)

-- | Run <a>ConfigureQuery</a> monad with initial state to get only result.
configureQuery :: ConfigureQuery q -> Config -> q

-- | Thin monad type for untyped structure.
type ConfigureQuery = Qualify QueryConfig Identity

-- | Relation type with place-holder parameter <tt>p</tt> and query result
--   type <tt>r</tt>.
data Relation p r

-- | Interface to project SQL terms unsafely.
class SqlContext c

-- | Unsafely project from SQL expression terms.
unsafeProjectSqlTerms :: SqlContext c => [StringSQL] -> Record c t

-- | Placeholder parameter type which has real parameter type arguemnt
--   <tt>p</tt>.
data PlaceHolders p

-- | SQL string for nested-qeury.
unitSQL :: SubQuery -> String

-- | Width of <a>Qualified</a> <tt>SubQUery</tt>.
queryWidth :: Qualified SubQuery -> Int

-- | Order direction. Ascendant or Descendant.
data Order
Asc :: Order
Desc :: Order

-- | Order of null.
data Nulls
NullsFirst :: Nulls
NullsLast :: Nulls

-- | Typeful aggregate element.
data AggregateKey a

-- | Sub-query type
data SubQuery

-- | Phantom typed record. Projected into Haskell record type <tt>t</tt>.
data Record c t

-- | Type for predicate to restrict of query result.
type Predicate c = Record c Maybe Bool

-- | Type for projection function.
type PI c a b = Record c a -> Record c b

-- | Constraint which represents scalar degree.
class PersistableWidth ct => ScalarDegree ct

-- | Deprecated.
showConstantTermsSQL :: ShowConstantTermsSQL a => a -> [StringSQL]
showConstantTermsSQL' :: ShowConstantTermsSQL a => a -> DList StringSQL

-- | Convert from haskell record to SQL literal row-value.
showLiteral :: LiteralSQL a => a -> [StringSQL]

-- | <a>LiteralSQL</a> <tt>a</tt> is implicit rule to derive function to
--   convert from haskell record type <tt>a</tt> into SQL literal
--   row-value.
--   
--   Generic programming
--   (<a>https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#generic-programming</a>)
--   with default signature is available for <a>LiteralSQL</a> class, so
--   you can make instance like below:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   import GHC.Generics (Generic)
--   --
--   data Foo = Foo { ... } deriving Generic
--   instance LiteralSQL Foo
--   </pre>
class LiteralSQL a
showLiteral' :: LiteralSQL a => a -> DList StringSQL

-- | Deprecated.
type ShowConstantTermsSQL = LiteralSQL

-- | Inferred <a>Unique</a> constraint <a>Key</a>. Record type <tt>r</tt>
--   has unique key which type is <tt>ct</tt> derived from primay key.
derivedUniqueKey :: HasConstraintKey Primary r ct => Key Unique r ct

-- | Derive <a>Unique</a> constraint <a>Key</a> from <a>Primary</a>
--   constraint <a>Key</a>
uniqueKey :: PersistableWidth ct => Key Primary r ct -> Key Unique r ct

-- | Get projection path proof object from constraint <a>Key</a>.
projectionKey :: Key c r ct -> Pi r ct

-- | Get table constraint <a>KeyConstraint</a> proof object from constraint
--   <a>Key</a>.
tableConstraint :: Key c r ct -> KeyConstraint c r

-- | Constraint Key proof object. Constraint type <tt>c</tt>, record type
--   <tt>r</tt> and columns type <tt>ct</tt>.
data Key c r ct

-- | Constraint <a>Key</a> inference interface.
class PersistableWidth ct => HasConstraintKey c r ct

-- | Infer constraint key.
constraintKey :: HasConstraintKey c r ct => Key c r ct

-- | Identity projection path.
id' :: Pi a a

-- | Compose projection path. <a>Maybe</a> phantom functors are
--   <tt>join</tt>-ed like <tt>&gt;=&gt;</tt>.
(<?.?>) :: Pi a (Maybe b) -> Pi b (Maybe c) -> Pi a (Maybe c)
infixl 8 <?.?>

-- | Compose projection path. <a>Maybe</a> phantom functor is
--   <a>map</a>-ed.
(<?.>) :: Pi a (Maybe b) -> Pi b c -> Pi a (Maybe c)
infixl 8 <?.>

-- | Compose projection path.
(<.>) :: Pi a b -> Pi b c -> Pi a c
infixl 8 <.>

-- | Expand indexes from key. Infered width version.
expandIndexes :: PersistableWidth a => Pi a b -> [Int]

-- | Expand indexes from key.
expandIndexes' :: PersistableRecordWidth a -> Pi a b -> [Int]

-- | Projection path from type <tt>r0</tt> into type <tt>r1</tt>. This type
--   also indicate key object which type is <tt>r1</tt> for record type
--   <tt>r0</tt>.
data Pi r0 r1

-- | String wrap type for SQL strings.
type StringSQL = Keyword

-- | Type tag for flat (not-aggregated) query
data Flat

-- | Type tag for aggregated query
data Aggregated

-- | Type tag for exists predicate
data Exists

-- | Type tag for window function building
data OverWindow

-- | Type tag for normal aggregatings set
data Set

-- | Type tag for aggregatings GROUPING SETS
data SetList

-- | Type tag for aggregatings power set
data Power

-- | Default configuration of <a>Config</a>. To change some behaviour of
--   relational-query, use record update syntax:
--   
--   <pre>
--   defaultConfig
--     { productUnitSupport            =  <a>PUSupported</a>
--     , chunksInsertSize              =  256
--     , schemaNameMode                =  <a>SchemaQualified</a>
--     , normalizedTableName           =  True
--     , addQueryTableAliasAS          =  False
--     , addModifyTableAliasAS         =  False
--     , enableWarning                 =  True
--     , verboseAsCompilerWarning      =  False
--     , disableOverloadedProjection   =  False
--     , disableSpecializedProjection  =  False
--     , identifierQuotation           =  <a>NoQuotation</a>
--     , nameConfig                    =
--        defaultNameConfig
--        { recordConfig     =  <a>defaultNameConfig</a>
--        , relationVarName  =  \schema table -&gt; <a>varCamelcaseName</a> $ table ++ "_" ++ scheme
--        -- ^ append the table name after the schema name. e.g. "schemaTable"
--        }
--     }
--   </pre>
defaultConfig :: Config

-- | Default implementation of <a>NameConfig</a> type.
defaultNameConfig :: NameConfig

-- | <a>NameConfig</a> type to customize names of expanded templates.
data NameConfig

-- | Unit of product is supported or not.
data ProductUnitSupport
PUSupported :: ProductUnitSupport
PUNotSupported :: ProductUnitSupport

-- | Schema name qualify mode in SQL string.
data SchemaNameMode

-- | Schema qualified table name in SQL string
SchemaQualified :: SchemaNameMode

-- | Not qualified table name in SQL string
SchemaNotQualified :: SchemaNameMode

-- | Configuration for quotation of identifiers of SQL.
data IdentifierQuotation
NoQuotation :: IdentifierQuotation
Quotation :: Char -> IdentifierQuotation

-- | Configuration type.
data Config
data Primary
data NotNull
data Unique

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery :: Relation p r -> [Keyword] -> Query p r

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object.
insertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object with no(unit) placeholder.
insertValueNoPH :: TableDerivable r => Register r () -> Insert ()

-- | Make <a>InsertQuery</a> from derived table, <a>Pi</a> and
--   <a>Relation</a>.
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation.
update :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation
--   with no(unit) placeholder.
updateNoPH :: TableDerivable r => (Record Flat r -> Assign r ()) -> Update ()

-- | Make <a>Delete</a> from derived table and <a>Restrict</a> computation.
delete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation with no(unit) placeholder.
deleteNoPH :: TableDerivable r => (Record Flat r -> Restrict ()) -> Delete ()

module Database.Relational.Schema.MySQL

-- | Configuration parameter against MySQL.
config :: Config
normalizeColumn :: String -> String
notNull :: Columns -> Bool
getType :: Map String TypeQ -> Columns -> Maybe (String, TypeQ)
columnsQuerySQL :: Query (String, String) Columns
primaryKeyQuerySQL :: Query (String, String) String


-- | <i>Deprecated: import Database.Relational.Schema.MySQL.Columns instead
--   of this module.</i>
module Database.Relational.Schema.MySQLInfo.Columns


-- | <i>Deprecated: import config from Database.Relational.Schema.MySQL
--   instead of this module.</i>
module Database.Relational.Schema.MySQLInfo.Config

-- | Configuration parameter against MySQL.
config :: Config


-- | This module provides custom APIs with appropriate configuration for
--   Oracle.
module Database.Custom.Oracle

-- | <a>UniqueRelation</a> inferred from table.
derivedUniqueRelation :: TableDerivable r => Key Unique r k -> Record c k -> UniqueRelation () c r

-- | Typed <a>KeyUpdate</a> using inferred primary key.
primaryUpdate :: HasConstraintKey Primary r p => Table r -> KeyUpdate p r

-- | Typed <a>KeyUpdate</a> using specified constraint key.
updateByConstraintKey :: Table r -> Key c r p -> KeyUpdate p r

-- | Convert from Haskell type <tt>r</tt> into SQL value <tt>q</tt> list
--   expected by update form like
--   
--   <i>UPDATE <a>table</a> SET c0 = ?, c1 = ?, ..., cn = ? WHERE key0 = ?
--   AND key1 = ? AND key2 = ? ... </i>
--   
--   using derived <tt>RecordToSql</tt> proof object.
updateValuesWithKey :: ToSql q r => Pi r p -> r -> [q]

-- | Deprecated.
primary :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Query restricted with inferred primary key.
primarySelect :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Deprecated.
primary' :: PersistableWidth p => Key Primary a p -> Relation () a -> Relation p a

-- | Deprecated.
unique :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified unique key.
uniqueSelect :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified key.
specifiedKey :: PersistableWidth p => Pi a p -> Relation () a -> Relation p a

-- | Update statement for sequence table
updateNumber :: (PersistableWidth s, Integral i, LiteralSQL i) => i -> Sequence s i -> Update ()

-- | Update statement for sequence table
updateNumber' :: (PersistableWidth s, Integral i, LiteralSQL i) => Config -> i -> Sequence s i -> Update ()

-- | Unsafely apply sequence number. Only safe to build corresponding
--   record type.
($$) :: Binding r s i => (i -> r) -> Number r i -> r

-- | Unsafely apply sequence number.
($$!) :: (i -> r) -> Number r i -> r

-- | Get untyped sequence number.
extractNumber :: Number r i -> i

-- | Unsafely specify sequence number.
unsafeSpecifyNumber :: Binding r s i => i -> Number r i

-- | Derive <a>Sequence</a> from corresponding <a>Relation</a>
fromRelation :: Binding r s i => Relation () r -> Sequence s i

-- | Derive binding using primary key.
primaryBinding :: (TableDerivable r, SequenceDerivable s i, HasConstraintKey Primary r i) => SeqBinding r s i

-- | Unsafely specify binding between normal-table and sequence-table.
unsafeSpecifyBinding :: (TableDerivable r, SequenceDerivable s i) => Pi r i -> SeqBinding r s i

-- | Infer <a>Relation</a> of sequence table
seqRelation :: TableDerivable s => Sequence s i -> Relation () s

-- | Unsafely specify sequence table.
unsafeSpecifySequence :: TableDerivable s => (s -> i) -> Pi s i -> Sequence s i

-- | Basic record to express sequence-table. actual sequence-table is a
--   table which has only one column of integer type.
data Sequence s i

-- | <a>Sequence</a> derivation rule
class TableDerivable s => SequenceDerivable s i | s -> i
derivedSequence :: SequenceDerivable s i => Sequence s i

-- | Record to express binding between normal-table and sequence-table.
data SeqBinding r s i

-- | Derivation rule for binding between <a>Table</a> and <a>Sequence</a>
class (TableDerivable r, SequenceDerivable s i) => Binding r s i | r -> s
binding :: Binding r s i => SeqBinding r s i

-- | Sequence number type for record type <tt>r</tt>
data Number r i

-- | Make typed <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
delete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Table</a> and <a>Restrict</a>
--   computation.
typedDelete :: Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, <a>Table</a> and
--   <a>Restrict</a> computation.
typedDelete' :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make untyped delete SQL string from <a>Table</a> and <a>Restrict</a>
--   computation.
deleteSQL :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> String

-- | Table type inferred <a>InsertQuery</a>.
derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Table type inferred <a>InsertQuery</a>.
insertQuery' :: TableDerivable r => Config -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a>.
typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a> with configuration parameter.
typedInsertQuery' :: Config -> Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make untyped insert select SQL string from <a>Table</a>, <a>Pi</a> and
--   <a>Relation</a>.
insertQuerySQL :: Config -> Table r -> Pi r r' -> Relation p r' -> String

-- | Make typed <a>Insert</a> list from records list.
insertValueList :: (TableDerivable r, LiteralSQL r') => Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> list from <a>Config</a> and records list.
insertValueList' :: (TableDerivable r, LiteralSQL r') => Config -> Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> from <a>defaultConfig</a>, derived table and
--   monadic builded <a>Register</a> object.
derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
insertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Table</a> and monadic builded
--   <a>InsertTarget</a> object.
typedInsertValue :: Table r -> InsertTarget p r -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, <a>Table</a> and monadic
--   builded <a>InsertTarget</a> object.
typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p

-- | Table type inferred <a>Insert</a>.
derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Table type inferred <a>Insert</a>.
insert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a>.
typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a> with configuration parameter.
typedInsert' :: PersistableWidth r => Config -> Table r -> Pi r r' -> Insert r'

-- | Unsafely make typed <a>Insert</a> from single insert and chunked
--   insert SQL.
unsafeTypedInsert' :: String -> String -> Int -> Insert a

-- | Size to use chunked insert
chunkSizeOfInsert :: Insert a -> Int

-- | Statement to use chunked insert
untypeChunkInsert :: Insert a -> String

-- | Deprecated. use <a>updateAllColumn</a>.
derivedUpdateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation without placeholder other than target
--   table columns. Update target is all column.
updateAllColumnNoPH :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict ()) -> Update r

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Deprecated. use <a>updateAllColumn'</a>.
derivedUpdateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Table</a> and <a>Restrict</a>
--   computation. Update target is all column.
typedUpdateAllColumn :: PersistableWidth r => Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
update' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> using <a>defaultConfig</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate :: Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate' :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make untyped update SQL string from <a>Table</a> and <a>Assign</a>
--   computation.
updateSQL :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> String

-- | Unsafely make typed <a>Update</a> from SQL string.
unsafeTypedUpdate :: String -> Update p

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
keyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> object using derived info specified by
--   <a>Relation</a> type.
typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from <a>Table</a> and key columns selector
--   <a>Pi</a>.
typedKeyUpdate :: Table a -> Pi a p -> KeyUpdate p a

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery' :: Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery_ :: Config -> Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into untyped SQL query string.
relationalQuerySQL :: Config -> Relation p r -> QuerySuffix -> String

-- | Unsafely make typed <a>Query</a> from SQL string.
unsafeTypedQuery :: String -> Query p a

-- | Query type with place-holder parameter <tt>p</tt> and query result
--   type <tt>a</tt>.
newtype Query p a
Query :: String -> Query p a
[untypeQuery] :: Query p a -> String

-- | Update type with key type <tt>p</tt> and update record type
--   <tt>a</tt>. Columns to update are record columns other than key
--   columns, So place-holder parameter type is the same as record type
--   <tt>a</tt>.
data KeyUpdate p a
KeyUpdate :: Pi a p -> String -> KeyUpdate p a
[updateKey] :: KeyUpdate p a -> Pi a p
[untypeKeyUpdate] :: KeyUpdate p a -> String

-- | Update type with place-holder parameter <tt>p</tt>.
newtype Update p
Update :: String -> Update p
[untypeUpdate] :: Update p -> String

-- | Insert type to insert record type <tt>a</tt>.
data Insert a
Insert :: String -> Maybe (String, Int) -> Insert a
[untypeInsert] :: Insert a -> String
[chunkedInsert] :: Insert a -> Maybe (String, Int)

-- | InsertQuery type.
newtype InsertQuery p
InsertQuery :: String -> InsertQuery p
[untypeInsertQuery] :: InsertQuery p -> String

-- | Delete type with place-holder parameter <tt>p</tt>.
newtype Delete p
Delete :: String -> Delete p
[untypeDelete] :: Delete p -> String

-- | Untype interface for typed no-result type statments with single type
--   parameter which represents place-holder parameter <tt>p</tt>.
class UntypeableNoFetch (s :: Type -> Type)
untypeNoFetch :: UntypeableNoFetch s => s p -> String

-- | Make <a>StringSQL</a> strings of SQL INSERT strings from records list
sqlChunksFromRecordList :: LiteralSQL r' => Config -> Table r -> Pi r r' -> [r'] -> [StringSQL]

-- | Make <a>StringSQL</a> string of SQL INSERT statement from
--   <a>InsertTarget</a>
sqlFromInsertTarget :: Config -> Table r -> InsertTarget p r -> StringSQL

-- | Make <a>StringSQL</a> string of SQL INSERT record chunk statement from
--   <a>InsertTarget</a>
sqlChunkFromInsertTarget :: Config -> Table r -> InsertTarget p r -> (StringSQL, Int)

-- | parametalized <a>Register</a> monad from <a>Pi</a>
piRegister :: PersistableWidth r => Pi r r' -> Register r (PlaceHolders r')

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a> with
--   place-holder parameter <tt>p</tt>.
insertTarget' :: Register r (PlaceHolders p) -> InsertTarget p r

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a>.
insertTarget :: Register r () -> InsertTarget () r

-- | SQL SET clause and WHERE clause <a>StringSQL</a> string from
--   <a>Assign</a> computation.
sqlFromUpdateTarget :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> StringSQL

-- | Deprecated.
updateTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Deprecated.
updateTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict ()) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all. With placefolder type <tt>p</tt>.
liftTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all.
liftTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders ())) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Deprecated.
updateTarget' :: (Record Flat r -> Assign r (PlaceHolders p)) -> UpdateTarget p r

-- | Deprecated.
updateTarget :: (Record Flat r -> Assign r ()) -> UpdateTarget () r

-- | SQL WHERE clause <a>StringSQL</a> string from <a>Restrict</a>
--   computation.
sqlWhereFromRestriction :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> StringSQL

-- | Deprecated.
restriction' :: (Record Flat r -> Restrict (PlaceHolders p)) -> Restriction p r

-- | Deprecated.
restriction :: (Record Flat r -> Restrict ()) -> Restriction () r

-- | Restriction type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type Restriction p r = Record Flat r -> Restrict PlaceHolders p

-- | UpdateTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type UpdateTarget p r = Record Flat r -> Assign r PlaceHolders p

-- | InsertTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
data InsertTarget p r

-- | Intersection of two relations with place-holder parameters. Not
--   distinct.
intersectAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersectAll'`

-- | Intersection of two relations with place-holder parameters.
intersect' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersect'`

-- | Subtraction of two relations with place-holder parameters. Not
--   distinct.
exceptAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `exceptAll'`

-- | Subtraction of two relations with place-holder parameters.
except' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `except'`

-- | Union of two relations with place-holder parameters. Not distinct.
unionAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `unionAll'`

-- | Union of two relations with place-holder parameters.
union' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `union'`

-- | Intersection of two relations. Not distinct.
intersectAll :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersectAll`

-- | Intersection of two relations.
intersect :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersect`

-- | Subtraction of two relations. Not distinct.
exceptAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `exceptAll`

-- | Subtraction of two relations.
except :: Relation () a -> Relation () a -> Relation () a
infixl 7 `except`

-- | Union of two relations. Not distinct.
unionAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `unionAll`

-- | Union of two relations.
union :: Relation () a -> Relation () a -> Relation () a
infixl 7 `union`

-- | Apply restriction for direct join style.
on' :: ([JoinRestriction a b] -> Relation pc (a, b)) -> [JoinRestriction a b] -> Relation pc (a, b)
infixl 8 `on'`

-- | Direct full outer join.
full :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation () (Maybe a, Maybe b)
infixl 8 `full`

-- | Direct right outer join.
right :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) b] -> Relation () (Maybe a, b)
infixl 8 `right`

-- | Direct left outer join.
left :: Relation () a -> Relation () b -> [JoinRestriction a (Maybe b)] -> Relation () (a, Maybe b)
infixl 8 `left`

-- | Direct inner join.
inner :: Relation () a -> Relation () b -> [JoinRestriction a b] -> Relation () (a, b)
infixl 8 `inner`

-- | Direct full outer join with place-holder parameters.
full' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation (pa, pb) (Maybe a, Maybe b)
infixl 8 `full'`

-- | Direct right outer join with place-holder parameters.
right' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) b] -> Relation (pa, pb) (Maybe a, b)
infixl 8 `right'`

-- | Direct left outer join with place-holder parameters.
left' :: Relation pa a -> Relation pb b -> [JoinRestriction a (Maybe b)] -> Relation (pa, pb) (a, Maybe b)
infixl 8 `left'`

-- | Direct inner join with place-holder parameters.
inner' :: Relation pa a -> Relation pb b -> [JoinRestriction a b] -> Relation (pa, pb) (a, b)
infixl 8 `inner'`

-- | Restriction predicate function type for direct style join operator,
--   used on predicates of direct join style as follows.
--   
--   <pre>
--   do xy &lt;- query $
--            relX <a>inner</a> relY <a>on</a>` [ x y -&gt; ... ] -- this lambda form has JoinRestriction type
--      ...
--   </pre>
type JoinRestriction a b = Record Flat a -> Record Flat b -> Predicate Flat

-- | Scalar sub-query.
queryScalar :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation () c r -> m (Record c (Maybe r))

-- | Scalar sub-query with place-holder parameter <tt>p</tt>.
queryScalar' :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation p c r -> m (PlaceHolders p, Record c (Maybe r))

-- | Aggregated <a>UniqueRelation</a>.
aggregatedUnique :: Relation ph r -> Pi r a -> (Record Flat a -> Record Aggregated b) -> UniqueRelation ph Flat b

-- | Finalize <a>QueryUnique</a> monad and generate <a>UniqueRelation</a>.
uniqueRelation' :: QueryUnique (PlaceHolders p, Record c r) -> UniqueRelation p c r

-- | Join unique sub-query with place-holder parameter <tt>p</tt>. Query
--   result is <a>Maybe</a>.
uniqueQueryMaybe' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c (Maybe r))

-- | Join unique sub-query with place-holder parameter <tt>p</tt>.
uniqueQuery' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c r)

-- | Discard unique attribute.
unUnique :: UniqueRelation p c r -> Relation p r

-- | Unsafely specify unique relation.
unsafeUnique :: Relation p r -> UniqueRelation p c r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a>.
aggregateRelation :: QueryAggregate (Record Aggregated r) -> Relation () r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
aggregateRelation' :: AggregatedQuery p r -> Relation p r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a>.
relation :: QuerySimple (Record Flat r) -> Relation () r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
relation' :: SimpleQuery p r -> Relation p r

-- | List sub-query, for <i>IN</i> and <i>EXIST</i>.
queryList :: MonadQualify ConfigureQuery m => Relation () r -> m (RecordList (Record c) r)

-- | List sub-query, for <i>IN</i> and <i>EXIST</i> with place-holder
--   parameter <tt>p</tt>.
queryList' :: MonadQualify ConfigureQuery m => Relation p r -> m (PlaceHolders p, RecordList (Record c) r)

-- | Join sub-query. Query result is <a>Maybe</a>. The combinations of
--   <a>query</a> and <a>queryMaybe</a> express inner joins, left outer
--   joins, right outer joins, and full outer joins. Here is an example of
--   a right outer join:
--   
--   <pre>
--   outerJoin = relation $ do
--     e &lt;- queryMaybe employee
--     d &lt;- query department
--     on $ e ?! E.deptId' .=. just (d ! D.deptId')
--     return $ (,) |$| e |*| d
--   </pre>
queryMaybe :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat (Maybe r))

-- | Join sub-query. Query result is not <a>Maybe</a>.
query :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat r)

-- | Interface to derive <a>Table</a> type object.
tableOf :: TableDerivable r => Relation () r -> Table r

-- | Inferred <a>Relation</a>.
derivedRelation :: TableDerivable r => Relation () r

-- | Simple <a>Relation</a> from <a>Table</a>.
table :: Table r -> Relation () r

-- | Unique relation type to compose scalar queries.
data UniqueRelation p c r

-- | Operator to make record of window function result using built
--   <a>Window</a> monad.
over :: SqlContext c => Record OverWindow a -> Window c () -> Record c a
infix 8 `over`

-- | Aggregated query monad type.
type QueryAggregate = Orderings Aggregated Restrictings Aggregated AggregatingSetT QueryCore

-- | Aggregated query type. <a>AggregatedQuery</a> p r ==
--   <a>QueryAggregate</a> (<a>PlaceHolders</a> p, <a>Record</a>
--   <a>Aggregated</a> r).
type AggregatedQuery p r = OrderedQuery Aggregated Restrictings Aggregated AggregatingSetT QueryCore p r

-- | Partition monad type for partition-by clause.
type Window c = Orderings c PartitioningSet c

-- | Finalize grouping set list.
groupingSets :: AggregatingSetList a -> AggregateKey a

-- | Finalize grouping power set as cube power set.
cube :: AggregatingPowerSet a -> AggregateKey a

-- | Finalize grouping power set as rollup power set.
rollup :: AggregatingPowerSet a -> AggregateKey a

-- | Specify key of rollup and cube power set.
bkey :: Record Flat r -> AggregatingPowerSet (Record Aggregated (Maybe r))

-- | Finalize and specify single grouping set.
set :: AggregatingSet a -> AggregatingSetList a

-- | Specify key of single grouping set.
key' :: AggregateKey a -> AggregatingSet a

-- | Specify key of single grouping set from Record.
key :: Record Flat r -> AggregatingSet (Record Aggregated (Maybe r))

-- | Target update monad type used from update statement and merge
--   statement.
type Assign r = Assignings r Restrict

-- | Target register monad type used from insert statement.
type Register r = Assignings r ConfigureQuery

-- | Add and assginment.
(<-#) :: forall (m :: Type -> Type) r v. Monad m => AssignTarget r v -> Record Flat v -> Assignings r m ()
infix 4 <-#

-- | Add an assignment.
assignTo :: forall (m :: Type -> Type) v r. Monad m => Record Flat v -> AssignTarget r v -> Assignings r m ()

-- | Simple (not-aggregated) query monad type.
type QuerySimple = Orderings Flat QueryCore

-- | Simple (not-aggregated) query type. <tt>SimpleQuery'</tt> p r ==
--   <a>QuerySimple</a> (<a>PlaceHolders</a> p, <a>Record</a> r).
type SimpleQuery p r = OrderedQuery Flat QueryCore p r

-- | Unique query monad type.
data QueryUnique a

-- | Extract <a>QueryCore</a> computation.
extractCore :: QueryCore a -> ConfigureQuery (((a, [Predicate Flat]), JoinProduct), Duplication)

-- | Core query monad type used from flat(not-aggregated) query and
--   aggregated query.
type QueryCore = Restrictings Flat QueryJoin ConfigureQuery

-- | OrderedQuery monad type with placeholder type <tt>p</tt>. Record must
--   be the same as <a>Orderings</a> context type parameter <tt>c</tt>.
type OrderedQuery c (m :: Type -> Type) p r = Orderings c m (PlaceHolders p, Record c r)

-- | Add descendant ordering term.
desc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ascendant ordering term.
asc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ordering terms.
orderBy :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Orderings c m ()

-- | Add ordering terms with null ordering.
orderBy' :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Nulls -> Orderings c m ()

-- | Type to accumulate ordering context. Type <tt>c</tt> is ordering term
--   record context type.
data Orderings c (m :: Type -> Type) a

-- | Restrict only monad type used from update statement and delete
--   statement.
type Restrict = Restrictings Flat ConfigureQuery

-- | Add restriction to this aggregated query. Aggregated Record type
--   version.
having :: MonadRestrict Aggregated m => Predicate Aggregated -> m ()

-- | Add restriction to this not aggregated query.
wheres :: MonadRestrict Flat m => Predicate Flat -> m ()

-- | Add restriction to last join. Record type version.
on :: MonadQuery m => Predicate Flat -> m ()

-- | Specify DISTINCT attribute to query context.
distinct :: MonadQuery m => m ()

-- | Specify ALL attribute to query context.
all' :: MonadQuery m => m ()

-- | Restrict context interface
class (Functor m, Monad m) => MonadRestrict c (m :: Type -> Type)

-- | Add restriction to this context.
restrict :: MonadRestrict c m => Predicate c -> m ()

-- | Query building interface.
class (Functor m, Monad m, MonadQualify ConfigureQuery m) => MonadQuery (m :: Type -> Type)

-- | Join sub-query with place-holder parameter <tt>p</tt>. query result is
--   not <a>Maybe</a>.
query' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat r)

-- | Join sub-query with place-holder parameter <tt>p</tt>. Query result is
--   <a>Maybe</a>.
queryMaybe' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat (Maybe r))

-- | Lift interface from base qualify monad.
class (Functor q, Monad q, Functor m, Monad m) => MonadQualify (q :: Type -> Type) (m :: Type -> Type)

-- | Aggregated query building interface extends <a>MonadQuery</a>.
class MonadQuery m => MonadAggregate (m :: Type -> Type)

-- | Add <i>GROUP BY</i> term into context and get aggregated record.
groupBy :: MonadAggregate m => Record Flat r -> m (Record Aggregated r)
groupBy' :: MonadAggregate m => AggregateKey (Record Aggregated r) -> m (Record Aggregated r)

-- | Window specification building interface.
class Monad m => MonadPartition c (m :: Type -> Type)

-- | Add <i>PARTITION BY</i> term into context.
partitionBy :: MonadPartition c m => Record c r -> m ()

-- | Same as <a>(?!?)</a>. Use this operator like '(?? #foo) mayX'.
(??) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ??

-- | Same as <a>(?!)</a>. Use this operator like '(? #foo) mayX'.
(?) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
(!??) :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c
infixl 8 !??

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
flattenPiMaybe :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c

-- | Get narrower record along with projection path and project into result
--   record type. Source record <a>Maybe</a> phantom functor and projection
--   path leaf <a>Maybe</a> functor are <tt>join</tt>-ed.
(?!?) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ?!?

-- | Get narrower record along with projection path <a>Maybe</a> phantom
--   functor is <a>map</a>-ed.
(?!) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?!

-- | Get narrower record along with projection path.
(!) :: PersistableWidth a => Record c a -> Pi a b -> Record c b
infixl 8 !

-- | Aggregation function SOME.
some' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function ANY.
any' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function EVERY.
every :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function MIN.
min' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MIN.
minMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function MAX.
max' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MAX.
maxMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function AVG.
avg :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe b)

-- | Aggregation function AVG.
avgMaybe :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe b)

-- | Aggregation function SUM.
sum' :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function SUM.
sumMaybe :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function COUNT.
count :: (Integral b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac b

-- | Unsafely make aggregation uni-operator from SQL keyword.
unsafeAggregateOp :: (AggregatedContext ac, SqlContext ac) => Keyword -> Record Flat a -> Record ac b

-- | Binary operator the same as <a>projectZip</a>.
(><) :: ProductIsoApplicative p => p a -> p b -> p (a, b)
infixl 1 ><

-- | Zipping projections.
projectZip :: ProductIsoApplicative p => p a -> p b -> p (a, b)

-- | Provide scoped placeholder and return its parameter object. Monadic
--   version.
placeholder :: (PersistableWidth t, SqlContext c, Monad m) => (Record c t -> m a) -> m (PlaceHolders t, a)

-- | Provide scoped placeholder and return its parameter object.
placeholder' :: (PersistableWidth t, SqlContext c) => (Record c t -> a) -> (PlaceHolders t, a)

-- | Provide scoped placeholder from width and return its parameter object.
pwPlaceholder :: SqlContext c => PersistableRecordWidth a -> (Record c a -> b) -> (PlaceHolders a, b)

-- | No placeholder semantics. Same as <a>unitPlaceHolder</a>
unitPH :: PlaceHolders ()

-- | No placeholder semantics
unitPlaceHolder :: PlaceHolders ()

-- | Unsafely get placeholder parameter
unsafePlaceHolders :: PlaceHolders p

-- | Unsafely add placeholder parameter to queries.
unsafeAddPlaceHolders :: Functor f => f a -> f (PlaceHolders p, a)

-- | <i>CUME_DIST()</i> term.
cumeDist :: Record OverWindow Double

-- | <i>PERCENT_RANK()</i> term.
percentRank :: Record OverWindow Double

-- | <i>ROW_NUMBER()</i> term.
rowNumber :: Integral a => Record OverWindow a

-- | <i>DENSE_RANK()</i> term.
denseRank :: Integral a => Record OverWindow a

-- | <i>RANK()</i> term.
rank :: Integral a => Record OverWindow a

-- | Operator from maybe type using record extended <tt>isNull</tt>.
fromMaybe :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c r -> Record c (Maybe r) -> Record c r

-- | Operator corresponding SQL <i>NOT (... IS NULL)</i> , and extended
--   against record type.
isJust :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Operator corresponding SQL <i>IS NULL</i> , and extended against
--   record types.
isNothing :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Binary operator corresponding SQL <i>IN</i> .
in' :: OperatorContext c => Record c t -> RecordList (Record c) t -> Record c (Maybe Bool)
infix 4 `in'`

-- | Null default version of <a>case'</a>.
caseMaybe :: (OperatorContext c, PersistableWidth b) => Record c a -> [(Record c a, Record c (Maybe b))] -> Record c (Maybe b)

-- | Uncurry version of <a>case'</a>, and you can write like ...
--   <a>casesOrElse</a>` <a>clause</a>.
casesOrElse' :: OperatorContext c => (Record c a, [(Record c a, Record c b)]) -> Record c b -> Record c b

-- | Simple case operator correnponding SQL simple <i>CASE</i>. Like,
--   <i>CASE x WHEN v THEN a WHEN w THEN b ... ELSE c END</i>
case' :: OperatorContext c => Record c a -> [(Record c a, Record c b)] -> Record c b -> Record c b

-- | Null default version of <a>caseSearch</a>.
caseSearchMaybe :: (OperatorContext c, PersistableWidth a) => [(Predicate c, Record c (Maybe a))] -> Record c (Maybe a)

-- | Same as <a>caseSearch</a>, but you can write like <a>list</a>
--   <a>casesOrElse</a> <a>clause</a>.
casesOrElse :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Search case operator correnponding SQL search <i>CASE</i>. Like,
--   <i>CASE WHEN p0 THEN a WHEN p1 THEN b ... ELSE c END</i>
caseSearch :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Unsafely show number into string-like type in records.
showNumMaybe :: (SqlContext c, Num a, IsString b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number fromIntegral uni-operator.
fromIntegralMaybe :: (SqlContext c, Integral a, Num b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negateMaybe :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a)

-- | Number operator corresponding SQL <i>*</i> .
(?*?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?*?

-- | Number operator corresponding SQL /// .
(?/?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?/?

-- | Number operator corresponding SQL <i>-</i> .
(?-?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?-?

-- | Number operator corresponding SQL <i>+</i> .
(?+?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?+?

-- | Unsafely show number into string-like type in records.
showNum :: (SqlContext c, Num a, IsString b) => Record c a -> Record c b

-- | Number fromIntegral uni-operator.
fromIntegral' :: (SqlContext c, Integral a, Num b) => Record c a -> Record c b

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negate' :: (OperatorContext c, Num a) => Record c a -> Record c a

-- | Number operator corresponding SQL <i>*</i> .
(.*.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 .*.

-- | Number operator corresponding SQL /// .
(./.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 ./.

-- | Number operator corresponding SQL <i>-</i> .
(.-.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .-.

-- | Number operator corresponding SQL <i>+</i> .
(.+.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .+.

-- | String-compare operator corresponding SQL <i>LIKE</i> . Maybe type
--   version.
likeMaybe :: (OperatorContext c, IsString a, LiteralSQL a) => Record c (Maybe a) -> a -> Record c (Maybe Bool)
infix 4 `likeMaybe`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like :: (OperatorContext c, IsString a, LiteralSQL a) => Record c a -> a -> Record c (Maybe Bool)
infix 4 `like`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
likeMaybe' :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe Bool)
infix 4 `likeMaybe'`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like' :: (OperatorContext c, IsString a) => Record c a -> Record c a -> Record c (Maybe Bool)
infix 4 `like'`

-- | Concatinate operator corresponding SQL <i>||</i> . Maybe type version.
(?||?) :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 5 ?||?

-- | Concatinate operator corresponding SQL <i>||</i> .
(.||.) :: OperatorContext c => Record c a -> Record c a -> Record c a
infixl 5 .||.

-- | Logical operator corresponding SQL <i>EXISTS</i> .
exists :: OperatorContext c => RecordList (Record Exists) r -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>NOT</i> .
not' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>OR</i> .
or' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 2 `or'`

-- | Logical operator corresponding SQL <i>AND</i> .
and' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 3 `and'`

-- | Compare operator corresponding SQL <i>&lt;&gt;</i> .
(.<>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<>.

-- | Compare operator corresponding SQL <i>&gt;=</i> .
(.>=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>=.

-- | Compare operator corresponding SQL <i>&gt;</i> .
(.>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>.

-- | Compare operator corresponding SQL <i>&lt;=</i> .
(.<=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<=.

-- | Compare operator corresponding SQL <i>&lt;</i> .
(.<.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<.

-- | Compare operator corresponding SQL <i>=</i> .
(.=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .=.

-- | Unsafely make binary operator for records from string binary operator.
unsafeBinOp :: SqlContext k => SqlBinOp -> Record k a -> Record k b -> Record k c

-- | Unsafely make unary operator for records from SQL keyword.
unsafeUniOp :: SqlContext c2 => (Keyword -> Keyword) -> Record c1 a -> Record c2 b

-- | Unsafely generate SQL expression string from record object. String
--   interface of <a>unsafeShowSql'</a>.
unsafeShowSql :: Record c a -> String

-- | Unsafely generate SQL expression term from record object.
unsafeShowSql' :: Record c a -> StringSQL

-- | RecordList with polymorphic type of SQL set value from Haskell list.
values :: (LiteralSQL t, OperatorContext c) => [t] -> RecordList (Record c) t

-- | Record with polymorphic type of SQL false value.
valueFalse :: OperatorContext c => Record c (Maybe Bool)

-- | Record with polymorphic type of SQL true value.
valueTrue :: OperatorContext c => Record c (Maybe Bool)

-- | Generate record with polymorphic type of SQL constant values from
--   Haskell value.
value :: (LiteralSQL t, OperatorContext c) => t -> Record c t

-- | Record with polymorphic phantom type of SQL null value. Semantics of
--   comparing is unsafe.
nothing :: (OperatorContext c, SqlContext c, PersistableWidth a) => Record c (Maybe a)

-- | Unsafely Project single SQL string. String interface of
--   <tt>unsafeProjectSql''</tt>.
unsafeProjectSql :: SqlContext c => String -> Record c t

-- | Unsafely Project single SQL term.
unsafeProjectSql' :: SqlContext c => StringSQL -> Record c t

-- | Binary operator type for SQL String.
type SqlBinOp = Keyword -> Keyword -> Keyword

-- | Interface to control <a>Maybe</a> of phantom type in records.
class ProjectableMaybe (p :: Type -> Type)

-- | Cast record phantom type into <a>Maybe</a>.
just :: ProjectableMaybe p => p a -> p (Maybe a)

-- | Compose nested <a>Maybe</a> phantom type on record.
flattenMaybe :: ProjectableMaybe p => p (Maybe (Maybe a)) -> p (Maybe a)

-- | Interface to compose phantom <a>Maybe</a> nested type.
class ProjectableFlattenMaybe a b
flatten :: (ProjectableFlattenMaybe a b, ProjectableMaybe p) => p a -> p b

-- | Projection path for snd of tuple.
snd' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) b

-- | Projection path for fst of tuple.
fst' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) a
tuplePi7_6' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a7
tuplePi7_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a6
tuplePi7_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a5
tuplePi7_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a4
tuplePi7_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a3
tuplePi7_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a2
tuplePi7_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a1
tuplePi6_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a6
tuplePi6_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a5
tuplePi6_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a4
tuplePi6_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a3
tuplePi6_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a2
tuplePi6_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a1
tuplePi5_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a5
tuplePi5_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a4
tuplePi5_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a3
tuplePi5_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a2
tuplePi5_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a1
tuplePi4_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a4
tuplePi4_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a3
tuplePi4_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a2
tuplePi4_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a1
tuplePi3_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a3
tuplePi3_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a2
tuplePi3_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a1
tuplePi2_1' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a2
tuplePi2_0' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a1

-- | Generate update SQL specified by single key.
updateOtherThanKeySQL :: Table r -> Pi r p -> String

-- | Type for query suffix words
type QuerySuffix = [Keyword]

-- | Make projected record list from <a>Record</a> list.
list :: [p t] -> RecordList p t

-- | Projected record list type for row list.
data RecordList (p :: Type -> Type) t

-- | Phantom typed table type
data Table r

-- | Inference rule of <a>Table</a> existence.
class PersistableWidth r => TableDerivable r
derivedTable :: TableDerivable r => Table r

-- | Dump internal structure tree.
dump :: Relation p r -> String

-- | SQL string from <a>Relation</a>.
sqlFromRelation :: Relation p r -> StringSQL

-- | Generate SQL string from <a>Relation</a> with configuration.
sqlFromRelationWith :: Relation p r -> Config -> StringSQL

-- | Simplify placeholder type applying right identity element.
leftPh :: Relation (p, ()) r -> Relation p r

-- | Simplify placeholder type applying left identity element.
rightPh :: Relation ((), p) r -> Relation p r

-- | <a>PersistableRecordWidth</a> of <a>Relation</a> type.
relationWidth :: Relation p r -> PersistableRecordWidth r

-- | Sub-query Qualify monad from relation.
untypeRelation :: Relation p r -> ConfigureQuery SubQuery

-- | Unsafely type qualified subquery into record typed relation type.
unsafeTypeRelation :: ConfigureQuery SubQuery -> Relation p r

-- | Read configuration.
askConfig :: ConfigureQuery Config

-- | Get qualifyed table form query.
qualifyQuery :: a -> ConfigureQuery (Qualified a)

-- | Run <a>ConfigureQuery</a> monad with initial state to get only result.
configureQuery :: ConfigureQuery q -> Config -> q

-- | Thin monad type for untyped structure.
type ConfigureQuery = Qualify QueryConfig Identity

-- | Relation type with place-holder parameter <tt>p</tt> and query result
--   type <tt>r</tt>.
data Relation p r

-- | Interface to project SQL terms unsafely.
class SqlContext c

-- | Unsafely project from SQL expression terms.
unsafeProjectSqlTerms :: SqlContext c => [StringSQL] -> Record c t

-- | Placeholder parameter type which has real parameter type arguemnt
--   <tt>p</tt>.
data PlaceHolders p

-- | SQL string for nested-qeury.
unitSQL :: SubQuery -> String

-- | Width of <a>Qualified</a> <tt>SubQUery</tt>.
queryWidth :: Qualified SubQuery -> Int

-- | Order direction. Ascendant or Descendant.
data Order
Asc :: Order
Desc :: Order

-- | Order of null.
data Nulls
NullsFirst :: Nulls
NullsLast :: Nulls

-- | Typeful aggregate element.
data AggregateKey a

-- | Sub-query type
data SubQuery

-- | Phantom typed record. Projected into Haskell record type <tt>t</tt>.
data Record c t

-- | Type for predicate to restrict of query result.
type Predicate c = Record c Maybe Bool

-- | Type for projection function.
type PI c a b = Record c a -> Record c b

-- | Constraint which represents scalar degree.
class PersistableWidth ct => ScalarDegree ct

-- | Deprecated.
showConstantTermsSQL :: ShowConstantTermsSQL a => a -> [StringSQL]
showConstantTermsSQL' :: ShowConstantTermsSQL a => a -> DList StringSQL

-- | Convert from haskell record to SQL literal row-value.
showLiteral :: LiteralSQL a => a -> [StringSQL]

-- | <a>LiteralSQL</a> <tt>a</tt> is implicit rule to derive function to
--   convert from haskell record type <tt>a</tt> into SQL literal
--   row-value.
--   
--   Generic programming
--   (<a>https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#generic-programming</a>)
--   with default signature is available for <a>LiteralSQL</a> class, so
--   you can make instance like below:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   import GHC.Generics (Generic)
--   --
--   data Foo = Foo { ... } deriving Generic
--   instance LiteralSQL Foo
--   </pre>
class LiteralSQL a
showLiteral' :: LiteralSQL a => a -> DList StringSQL

-- | Deprecated.
type ShowConstantTermsSQL = LiteralSQL

-- | Inferred <a>Unique</a> constraint <a>Key</a>. Record type <tt>r</tt>
--   has unique key which type is <tt>ct</tt> derived from primay key.
derivedUniqueKey :: HasConstraintKey Primary r ct => Key Unique r ct

-- | Derive <a>Unique</a> constraint <a>Key</a> from <a>Primary</a>
--   constraint <a>Key</a>
uniqueKey :: PersistableWidth ct => Key Primary r ct -> Key Unique r ct

-- | Get projection path proof object from constraint <a>Key</a>.
projectionKey :: Key c r ct -> Pi r ct

-- | Get table constraint <a>KeyConstraint</a> proof object from constraint
--   <a>Key</a>.
tableConstraint :: Key c r ct -> KeyConstraint c r

-- | Constraint Key proof object. Constraint type <tt>c</tt>, record type
--   <tt>r</tt> and columns type <tt>ct</tt>.
data Key c r ct

-- | Constraint <a>Key</a> inference interface.
class PersistableWidth ct => HasConstraintKey c r ct

-- | Infer constraint key.
constraintKey :: HasConstraintKey c r ct => Key c r ct

-- | Identity projection path.
id' :: Pi a a

-- | Compose projection path. <a>Maybe</a> phantom functors are
--   <tt>join</tt>-ed like <tt>&gt;=&gt;</tt>.
(<?.?>) :: Pi a (Maybe b) -> Pi b (Maybe c) -> Pi a (Maybe c)
infixl 8 <?.?>

-- | Compose projection path. <a>Maybe</a> phantom functor is
--   <a>map</a>-ed.
(<?.>) :: Pi a (Maybe b) -> Pi b c -> Pi a (Maybe c)
infixl 8 <?.>

-- | Compose projection path.
(<.>) :: Pi a b -> Pi b c -> Pi a c
infixl 8 <.>

-- | Expand indexes from key. Infered width version.
expandIndexes :: PersistableWidth a => Pi a b -> [Int]

-- | Expand indexes from key.
expandIndexes' :: PersistableRecordWidth a -> Pi a b -> [Int]

-- | Projection path from type <tt>r0</tt> into type <tt>r1</tt>. This type
--   also indicate key object which type is <tt>r1</tt> for record type
--   <tt>r0</tt>.
data Pi r0 r1

-- | String wrap type for SQL strings.
type StringSQL = Keyword

-- | Type tag for flat (not-aggregated) query
data Flat

-- | Type tag for aggregated query
data Aggregated

-- | Type tag for exists predicate
data Exists

-- | Type tag for window function building
data OverWindow

-- | Type tag for normal aggregatings set
data Set

-- | Type tag for aggregatings GROUPING SETS
data SetList

-- | Type tag for aggregatings power set
data Power

-- | Default configuration of <a>Config</a>. To change some behaviour of
--   relational-query, use record update syntax:
--   
--   <pre>
--   defaultConfig
--     { productUnitSupport            =  <a>PUSupported</a>
--     , chunksInsertSize              =  256
--     , schemaNameMode                =  <a>SchemaQualified</a>
--     , normalizedTableName           =  True
--     , addQueryTableAliasAS          =  False
--     , addModifyTableAliasAS         =  False
--     , enableWarning                 =  True
--     , verboseAsCompilerWarning      =  False
--     , disableOverloadedProjection   =  False
--     , disableSpecializedProjection  =  False
--     , identifierQuotation           =  <a>NoQuotation</a>
--     , nameConfig                    =
--        defaultNameConfig
--        { recordConfig     =  <a>defaultNameConfig</a>
--        , relationVarName  =  \schema table -&gt; <a>varCamelcaseName</a> $ table ++ "_" ++ scheme
--        -- ^ append the table name after the schema name. e.g. "schemaTable"
--        }
--     }
--   </pre>
defaultConfig :: Config

-- | Default implementation of <a>NameConfig</a> type.
defaultNameConfig :: NameConfig

-- | <a>NameConfig</a> type to customize names of expanded templates.
data NameConfig

-- | Unit of product is supported or not.
data ProductUnitSupport
PUSupported :: ProductUnitSupport
PUNotSupported :: ProductUnitSupport

-- | Schema name qualify mode in SQL string.
data SchemaNameMode

-- | Schema qualified table name in SQL string
SchemaQualified :: SchemaNameMode

-- | Not qualified table name in SQL string
SchemaNotQualified :: SchemaNameMode

-- | Configuration for quotation of identifiers of SQL.
data IdentifierQuotation
NoQuotation :: IdentifierQuotation
Quotation :: Char -> IdentifierQuotation

-- | Configuration type.
data Config
data Primary
data NotNull
data Unique

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery :: Relation p r -> [Keyword] -> Query p r

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object.
insertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object with no(unit) placeholder.
insertValueNoPH :: TableDerivable r => Register r () -> Insert ()

-- | Make <a>InsertQuery</a> from derived table, <a>Pi</a> and
--   <a>Relation</a>.
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation.
update :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation
--   with no(unit) placeholder.
updateNoPH :: TableDerivable r => (Record Flat r -> Assign r ()) -> Update ()

-- | Make <a>Delete</a> from derived table and <a>Restrict</a> computation.
delete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation with no(unit) placeholder.
deleteNoPH :: TableDerivable r => (Record Flat r -> Restrict ()) -> Delete ()

module Database.Relational.Schema.Oracle.TabColumns
data DbaTabColumns
DbaTabColumns :: !String -> !String -> !String -> !Maybe String -> !Maybe String -> !Maybe String -> !Int32 -> !Maybe Int32 -> !Maybe Int32 -> !Maybe String -> !Maybe Int32 -> !Maybe Int32 -> !Maybe String -> !Maybe Int32 -> !Maybe Int32 -> !Maybe Int32 -> !Maybe Int32 -> !Maybe Int32 -> !Maybe String -> !Maybe Int32 -> !Maybe String -> !Maybe String -> !Maybe Int32 -> !Maybe Int32 -> !Maybe String -> !Maybe String -> !Maybe String -> !Maybe String -> DbaTabColumns
[owner] :: DbaTabColumns -> !String
[tableName] :: DbaTabColumns -> !String
[columnName] :: DbaTabColumns -> !String
[dataType] :: DbaTabColumns -> !Maybe String
[dataTypeMod] :: DbaTabColumns -> !Maybe String
[dataTypeOwner] :: DbaTabColumns -> !Maybe String
[dataLength] :: DbaTabColumns -> !Int32
[dataPrecision] :: DbaTabColumns -> !Maybe Int32
[dataScale] :: DbaTabColumns -> !Maybe Int32
[nullable] :: DbaTabColumns -> !Maybe String
[columnId] :: DbaTabColumns -> !Maybe Int32
[defaultLength] :: DbaTabColumns -> !Maybe Int32
[dataDefault] :: DbaTabColumns -> !Maybe String
[numDistinct] :: DbaTabColumns -> !Maybe Int32
[density] :: DbaTabColumns -> !Maybe Int32
[numNulls] :: DbaTabColumns -> !Maybe Int32
[numBuckets] :: DbaTabColumns -> !Maybe Int32
[sampleSize] :: DbaTabColumns -> !Maybe Int32
[characterSetName] :: DbaTabColumns -> !Maybe String
[charColDeclLength] :: DbaTabColumns -> !Maybe Int32
[globalStats] :: DbaTabColumns -> !Maybe String
[userStats] :: DbaTabColumns -> !Maybe String
[avgColLen] :: DbaTabColumns -> !Maybe Int32
[charLength] :: DbaTabColumns -> !Maybe Int32
[charUsed] :: DbaTabColumns -> !Maybe String
[v80FmtImage] :: DbaTabColumns -> !Maybe String
[dataUpgraded] :: DbaTabColumns -> !Maybe String
[histogram] :: DbaTabColumns -> !Maybe String
histogram' :: Pi DbaTabColumns (Maybe String)
dataUpgraded' :: Pi DbaTabColumns (Maybe String)
v80FmtImage' :: Pi DbaTabColumns (Maybe String)
charUsed' :: Pi DbaTabColumns (Maybe String)
charLength' :: Pi DbaTabColumns (Maybe Int32)
avgColLen' :: Pi DbaTabColumns (Maybe Int32)
userStats' :: Pi DbaTabColumns (Maybe String)
globalStats' :: Pi DbaTabColumns (Maybe String)
charColDeclLength' :: Pi DbaTabColumns (Maybe Int32)
characterSetName' :: Pi DbaTabColumns (Maybe String)
sampleSize' :: Pi DbaTabColumns (Maybe Int32)
numBuckets' :: Pi DbaTabColumns (Maybe Int32)
numNulls' :: Pi DbaTabColumns (Maybe Int32)
density' :: Pi DbaTabColumns (Maybe Int32)
numDistinct' :: Pi DbaTabColumns (Maybe Int32)
dataDefault' :: Pi DbaTabColumns (Maybe String)
defaultLength' :: Pi DbaTabColumns (Maybe Int32)
columnId' :: Pi DbaTabColumns (Maybe Int32)
nullable' :: Pi DbaTabColumns (Maybe String)
dataScale' :: Pi DbaTabColumns (Maybe Int32)
dataPrecision' :: Pi DbaTabColumns (Maybe Int32)
dataLength' :: Pi DbaTabColumns Int32
dataTypeOwner' :: Pi DbaTabColumns (Maybe String)
dataTypeMod' :: Pi DbaTabColumns (Maybe String)
dataType' :: Pi DbaTabColumns (Maybe String)
columnName' :: Pi DbaTabColumns String
tableName' :: Pi DbaTabColumns String
owner' :: Pi DbaTabColumns String
insertQueryDbaTabColumns :: forall p_aBKN. Relation p_aBKN DbaTabColumns -> InsertQuery p_aBKN
insertDbaTabColumns :: Insert DbaTabColumns
dbaTabColumns :: Relation () DbaTabColumns
tableOfDbaTabColumns :: Table DbaTabColumns
columnOffsetsDbaTabColumns :: Array Int Int
instance GHC.Generics.Generic Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns
instance GHC.Show.Show Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns
instance Database.Record.Persistable.PersistableWidth Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns
instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Base.String -> GHC.Base.String -> GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Maybe.Maybe GHC.Base.String -> Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns)
instance Database.Relational.ProjectableClass.LiteralSQL Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns
instance Database.Relational.Table.TableDerivable Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns
instance Database.Relational.OverloadedProjection.HasProjection "owner" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "tableName" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "columnName" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "dataType" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "dataTypeMod" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "dataTypeOwner" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "dataLength" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "dataPrecision" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "dataScale" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "nullable" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "columnId" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "defaultLength" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "dataDefault" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "numDistinct" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "density" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "numNulls" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "numBuckets" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "sampleSize" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "characterSetName" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "charColDeclLength" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "globalStats" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "userStats" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "avgColLen" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "charLength" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Int.Int32)
instance Database.Relational.OverloadedProjection.HasProjection "charUsed" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "v80FmtImage" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "dataUpgraded" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "histogram" Database.Relational.Schema.Oracle.TabColumns.DbaTabColumns (GHC.Maybe.Maybe GHC.Base.String)

module Database.Relational.Schema.Oracle

-- | Configuration parameter against Oracle.
config :: Config

-- | Normalize column name string to query Oracle DB data dictionary.
normalizeColumn :: String -> String

-- | Not-null attribute information of column.
notNull :: DbaTabColumns -> Bool

-- | Get column normalized name and column Haskell type.
getType :: Map String TypeQ -> DbaTabColumns -> Maybe (String, TypeQ)

-- | Phantom typed <a>Query</a> to get <a>DbaTabColumns</a> from owner name
--   and table name.
columnsQuerySQL :: Query (String, String) DbaTabColumns

-- | Phantom typed <a>Query</a> to get primary key name from owner name and
--   table name.
primaryKeyQuerySQL :: Query (String, String) (Maybe String)


-- | <i>Deprecated: import config from Database.Relational.Schema.Oracle
--   instead of this module.</i>
module Database.Relational.Schema.OracleDataDictionary.Config

-- | Configuration parameter against Oracle.
config :: Config


-- | <i>Deprecated: import Database.Relational.Schema.Oracle.TabColumns
--   instead of this module.</i>
module Database.Relational.Schema.OracleDataDictionary.TabColumns


-- | <i>Deprecated: import config from
--   Database.Relational.Schema.PostgreSQL instead of this module.</i>
module Database.Relational.Schema.PgCatalog.Config

-- | Configuration parameter against PostgreSQL.
config :: Config


-- | This module provides custom APIs with appropriate configuration for
--   PostgreSQL.
module Database.Custom.PostgreSQL

-- | <a>UniqueRelation</a> inferred from table.
derivedUniqueRelation :: TableDerivable r => Key Unique r k -> Record c k -> UniqueRelation () c r

-- | Typed <a>KeyUpdate</a> using inferred primary key.
primaryUpdate :: HasConstraintKey Primary r p => Table r -> KeyUpdate p r

-- | Typed <a>KeyUpdate</a> using specified constraint key.
updateByConstraintKey :: Table r -> Key c r p -> KeyUpdate p r

-- | Convert from Haskell type <tt>r</tt> into SQL value <tt>q</tt> list
--   expected by update form like
--   
--   <i>UPDATE <a>table</a> SET c0 = ?, c1 = ?, ..., cn = ? WHERE key0 = ?
--   AND key1 = ? AND key2 = ? ... </i>
--   
--   using derived <tt>RecordToSql</tt> proof object.
updateValuesWithKey :: ToSql q r => Pi r p -> r -> [q]

-- | Deprecated.
primary :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Query restricted with inferred primary key.
primarySelect :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Deprecated.
primary' :: PersistableWidth p => Key Primary a p -> Relation () a -> Relation p a

-- | Deprecated.
unique :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified unique key.
uniqueSelect :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified key.
specifiedKey :: PersistableWidth p => Pi a p -> Relation () a -> Relation p a

-- | Update statement for sequence table
updateNumber :: (PersistableWidth s, Integral i, LiteralSQL i) => i -> Sequence s i -> Update ()

-- | Update statement for sequence table
updateNumber' :: (PersistableWidth s, Integral i, LiteralSQL i) => Config -> i -> Sequence s i -> Update ()

-- | Unsafely apply sequence number. Only safe to build corresponding
--   record type.
($$) :: Binding r s i => (i -> r) -> Number r i -> r

-- | Unsafely apply sequence number.
($$!) :: (i -> r) -> Number r i -> r

-- | Get untyped sequence number.
extractNumber :: Number r i -> i

-- | Unsafely specify sequence number.
unsafeSpecifyNumber :: Binding r s i => i -> Number r i

-- | Derive <a>Sequence</a> from corresponding <a>Relation</a>
fromRelation :: Binding r s i => Relation () r -> Sequence s i

-- | Derive binding using primary key.
primaryBinding :: (TableDerivable r, SequenceDerivable s i, HasConstraintKey Primary r i) => SeqBinding r s i

-- | Unsafely specify binding between normal-table and sequence-table.
unsafeSpecifyBinding :: (TableDerivable r, SequenceDerivable s i) => Pi r i -> SeqBinding r s i

-- | Infer <a>Relation</a> of sequence table
seqRelation :: TableDerivable s => Sequence s i -> Relation () s

-- | Unsafely specify sequence table.
unsafeSpecifySequence :: TableDerivable s => (s -> i) -> Pi s i -> Sequence s i

-- | Basic record to express sequence-table. actual sequence-table is a
--   table which has only one column of integer type.
data Sequence s i

-- | <a>Sequence</a> derivation rule
class TableDerivable s => SequenceDerivable s i | s -> i
derivedSequence :: SequenceDerivable s i => Sequence s i

-- | Record to express binding between normal-table and sequence-table.
data SeqBinding r s i

-- | Derivation rule for binding between <a>Table</a> and <a>Sequence</a>
class (TableDerivable r, SequenceDerivable s i) => Binding r s i | r -> s
binding :: Binding r s i => SeqBinding r s i

-- | Sequence number type for record type <tt>r</tt>
data Number r i

-- | Make typed <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
delete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Table</a> and <a>Restrict</a>
--   computation.
typedDelete :: Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, <a>Table</a> and
--   <a>Restrict</a> computation.
typedDelete' :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make untyped delete SQL string from <a>Table</a> and <a>Restrict</a>
--   computation.
deleteSQL :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> String

-- | Table type inferred <a>InsertQuery</a>.
derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Table type inferred <a>InsertQuery</a>.
insertQuery' :: TableDerivable r => Config -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a>.
typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a> with configuration parameter.
typedInsertQuery' :: Config -> Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make untyped insert select SQL string from <a>Table</a>, <a>Pi</a> and
--   <a>Relation</a>.
insertQuerySQL :: Config -> Table r -> Pi r r' -> Relation p r' -> String

-- | Make typed <a>Insert</a> list from records list.
insertValueList :: (TableDerivable r, LiteralSQL r') => Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> list from <a>Config</a> and records list.
insertValueList' :: (TableDerivable r, LiteralSQL r') => Config -> Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> from <a>defaultConfig</a>, derived table and
--   monadic builded <a>Register</a> object.
derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
insertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Table</a> and monadic builded
--   <a>InsertTarget</a> object.
typedInsertValue :: Table r -> InsertTarget p r -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, <a>Table</a> and monadic
--   builded <a>InsertTarget</a> object.
typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p

-- | Table type inferred <a>Insert</a>.
derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Table type inferred <a>Insert</a>.
insert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a>.
typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a> with configuration parameter.
typedInsert' :: PersistableWidth r => Config -> Table r -> Pi r r' -> Insert r'

-- | Unsafely make typed <a>Insert</a> from single insert and chunked
--   insert SQL.
unsafeTypedInsert' :: String -> String -> Int -> Insert a

-- | Size to use chunked insert
chunkSizeOfInsert :: Insert a -> Int

-- | Statement to use chunked insert
untypeChunkInsert :: Insert a -> String

-- | Deprecated. use <a>updateAllColumn</a>.
derivedUpdateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation without placeholder other than target
--   table columns. Update target is all column.
updateAllColumnNoPH :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict ()) -> Update r

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Deprecated. use <a>updateAllColumn'</a>.
derivedUpdateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Table</a> and <a>Restrict</a>
--   computation. Update target is all column.
typedUpdateAllColumn :: PersistableWidth r => Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
update' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> using <a>defaultConfig</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate :: Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate' :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make untyped update SQL string from <a>Table</a> and <a>Assign</a>
--   computation.
updateSQL :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> String

-- | Unsafely make typed <a>Update</a> from SQL string.
unsafeTypedUpdate :: String -> Update p

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
keyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> object using derived info specified by
--   <a>Relation</a> type.
typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from <a>Table</a> and key columns selector
--   <a>Pi</a>.
typedKeyUpdate :: Table a -> Pi a p -> KeyUpdate p a

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery' :: Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery_ :: Config -> Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into untyped SQL query string.
relationalQuerySQL :: Config -> Relation p r -> QuerySuffix -> String

-- | Unsafely make typed <a>Query</a> from SQL string.
unsafeTypedQuery :: String -> Query p a

-- | Query type with place-holder parameter <tt>p</tt> and query result
--   type <tt>a</tt>.
newtype Query p a
Query :: String -> Query p a
[untypeQuery] :: Query p a -> String

-- | Update type with key type <tt>p</tt> and update record type
--   <tt>a</tt>. Columns to update are record columns other than key
--   columns, So place-holder parameter type is the same as record type
--   <tt>a</tt>.
data KeyUpdate p a
KeyUpdate :: Pi a p -> String -> KeyUpdate p a
[updateKey] :: KeyUpdate p a -> Pi a p
[untypeKeyUpdate] :: KeyUpdate p a -> String

-- | Update type with place-holder parameter <tt>p</tt>.
newtype Update p
Update :: String -> Update p
[untypeUpdate] :: Update p -> String

-- | Insert type to insert record type <tt>a</tt>.
data Insert a
Insert :: String -> Maybe (String, Int) -> Insert a
[untypeInsert] :: Insert a -> String
[chunkedInsert] :: Insert a -> Maybe (String, Int)

-- | InsertQuery type.
newtype InsertQuery p
InsertQuery :: String -> InsertQuery p
[untypeInsertQuery] :: InsertQuery p -> String

-- | Delete type with place-holder parameter <tt>p</tt>.
newtype Delete p
Delete :: String -> Delete p
[untypeDelete] :: Delete p -> String

-- | Untype interface for typed no-result type statments with single type
--   parameter which represents place-holder parameter <tt>p</tt>.
class UntypeableNoFetch (s :: Type -> Type)
untypeNoFetch :: UntypeableNoFetch s => s p -> String

-- | Make <a>StringSQL</a> strings of SQL INSERT strings from records list
sqlChunksFromRecordList :: LiteralSQL r' => Config -> Table r -> Pi r r' -> [r'] -> [StringSQL]

-- | Make <a>StringSQL</a> string of SQL INSERT statement from
--   <a>InsertTarget</a>
sqlFromInsertTarget :: Config -> Table r -> InsertTarget p r -> StringSQL

-- | Make <a>StringSQL</a> string of SQL INSERT record chunk statement from
--   <a>InsertTarget</a>
sqlChunkFromInsertTarget :: Config -> Table r -> InsertTarget p r -> (StringSQL, Int)

-- | parametalized <a>Register</a> monad from <a>Pi</a>
piRegister :: PersistableWidth r => Pi r r' -> Register r (PlaceHolders r')

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a> with
--   place-holder parameter <tt>p</tt>.
insertTarget' :: Register r (PlaceHolders p) -> InsertTarget p r

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a>.
insertTarget :: Register r () -> InsertTarget () r

-- | SQL SET clause and WHERE clause <a>StringSQL</a> string from
--   <a>Assign</a> computation.
sqlFromUpdateTarget :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> StringSQL

-- | Deprecated.
updateTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Deprecated.
updateTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict ()) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all. With placefolder type <tt>p</tt>.
liftTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all.
liftTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders ())) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Deprecated.
updateTarget' :: (Record Flat r -> Assign r (PlaceHolders p)) -> UpdateTarget p r

-- | Deprecated.
updateTarget :: (Record Flat r -> Assign r ()) -> UpdateTarget () r

-- | SQL WHERE clause <a>StringSQL</a> string from <a>Restrict</a>
--   computation.
sqlWhereFromRestriction :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> StringSQL

-- | Deprecated.
restriction' :: (Record Flat r -> Restrict (PlaceHolders p)) -> Restriction p r

-- | Deprecated.
restriction :: (Record Flat r -> Restrict ()) -> Restriction () r

-- | Restriction type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type Restriction p r = Record Flat r -> Restrict PlaceHolders p

-- | UpdateTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type UpdateTarget p r = Record Flat r -> Assign r PlaceHolders p

-- | InsertTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
data InsertTarget p r

-- | Intersection of two relations with place-holder parameters. Not
--   distinct.
intersectAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersectAll'`

-- | Intersection of two relations with place-holder parameters.
intersect' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersect'`

-- | Subtraction of two relations with place-holder parameters. Not
--   distinct.
exceptAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `exceptAll'`

-- | Subtraction of two relations with place-holder parameters.
except' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `except'`

-- | Union of two relations with place-holder parameters. Not distinct.
unionAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `unionAll'`

-- | Union of two relations with place-holder parameters.
union' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `union'`

-- | Intersection of two relations. Not distinct.
intersectAll :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersectAll`

-- | Intersection of two relations.
intersect :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersect`

-- | Subtraction of two relations. Not distinct.
exceptAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `exceptAll`

-- | Subtraction of two relations.
except :: Relation () a -> Relation () a -> Relation () a
infixl 7 `except`

-- | Union of two relations. Not distinct.
unionAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `unionAll`

-- | Union of two relations.
union :: Relation () a -> Relation () a -> Relation () a
infixl 7 `union`

-- | Apply restriction for direct join style.
on' :: ([JoinRestriction a b] -> Relation pc (a, b)) -> [JoinRestriction a b] -> Relation pc (a, b)
infixl 8 `on'`

-- | Direct full outer join.
full :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation () (Maybe a, Maybe b)
infixl 8 `full`

-- | Direct right outer join.
right :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) b] -> Relation () (Maybe a, b)
infixl 8 `right`

-- | Direct left outer join.
left :: Relation () a -> Relation () b -> [JoinRestriction a (Maybe b)] -> Relation () (a, Maybe b)
infixl 8 `left`

-- | Direct inner join.
inner :: Relation () a -> Relation () b -> [JoinRestriction a b] -> Relation () (a, b)
infixl 8 `inner`

-- | Direct full outer join with place-holder parameters.
full' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation (pa, pb) (Maybe a, Maybe b)
infixl 8 `full'`

-- | Direct right outer join with place-holder parameters.
right' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) b] -> Relation (pa, pb) (Maybe a, b)
infixl 8 `right'`

-- | Direct left outer join with place-holder parameters.
left' :: Relation pa a -> Relation pb b -> [JoinRestriction a (Maybe b)] -> Relation (pa, pb) (a, Maybe b)
infixl 8 `left'`

-- | Direct inner join with place-holder parameters.
inner' :: Relation pa a -> Relation pb b -> [JoinRestriction a b] -> Relation (pa, pb) (a, b)
infixl 8 `inner'`

-- | Restriction predicate function type for direct style join operator,
--   used on predicates of direct join style as follows.
--   
--   <pre>
--   do xy &lt;- query $
--            relX <a>inner</a> relY <a>on</a>` [ x y -&gt; ... ] -- this lambda form has JoinRestriction type
--      ...
--   </pre>
type JoinRestriction a b = Record Flat a -> Record Flat b -> Predicate Flat

-- | Scalar sub-query.
queryScalar :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation () c r -> m (Record c (Maybe r))

-- | Scalar sub-query with place-holder parameter <tt>p</tt>.
queryScalar' :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation p c r -> m (PlaceHolders p, Record c (Maybe r))

-- | Aggregated <a>UniqueRelation</a>.
aggregatedUnique :: Relation ph r -> Pi r a -> (Record Flat a -> Record Aggregated b) -> UniqueRelation ph Flat b

-- | Finalize <a>QueryUnique</a> monad and generate <a>UniqueRelation</a>.
uniqueRelation' :: QueryUnique (PlaceHolders p, Record c r) -> UniqueRelation p c r

-- | Join unique sub-query with place-holder parameter <tt>p</tt>. Query
--   result is <a>Maybe</a>.
uniqueQueryMaybe' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c (Maybe r))

-- | Join unique sub-query with place-holder parameter <tt>p</tt>.
uniqueQuery' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c r)

-- | Discard unique attribute.
unUnique :: UniqueRelation p c r -> Relation p r

-- | Unsafely specify unique relation.
unsafeUnique :: Relation p r -> UniqueRelation p c r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a>.
aggregateRelation :: QueryAggregate (Record Aggregated r) -> Relation () r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
aggregateRelation' :: AggregatedQuery p r -> Relation p r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a>.
relation :: QuerySimple (Record Flat r) -> Relation () r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
relation' :: SimpleQuery p r -> Relation p r

-- | List sub-query, for <i>IN</i> and <i>EXIST</i>.
queryList :: MonadQualify ConfigureQuery m => Relation () r -> m (RecordList (Record c) r)

-- | List sub-query, for <i>IN</i> and <i>EXIST</i> with place-holder
--   parameter <tt>p</tt>.
queryList' :: MonadQualify ConfigureQuery m => Relation p r -> m (PlaceHolders p, RecordList (Record c) r)

-- | Join sub-query. Query result is <a>Maybe</a>. The combinations of
--   <a>query</a> and <a>queryMaybe</a> express inner joins, left outer
--   joins, right outer joins, and full outer joins. Here is an example of
--   a right outer join:
--   
--   <pre>
--   outerJoin = relation $ do
--     e &lt;- queryMaybe employee
--     d &lt;- query department
--     on $ e ?! E.deptId' .=. just (d ! D.deptId')
--     return $ (,) |$| e |*| d
--   </pre>
queryMaybe :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat (Maybe r))

-- | Join sub-query. Query result is not <a>Maybe</a>.
query :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat r)

-- | Interface to derive <a>Table</a> type object.
tableOf :: TableDerivable r => Relation () r -> Table r

-- | Inferred <a>Relation</a>.
derivedRelation :: TableDerivable r => Relation () r

-- | Simple <a>Relation</a> from <a>Table</a>.
table :: Table r -> Relation () r

-- | Unique relation type to compose scalar queries.
data UniqueRelation p c r

-- | Operator to make record of window function result using built
--   <a>Window</a> monad.
over :: SqlContext c => Record OverWindow a -> Window c () -> Record c a
infix 8 `over`

-- | Aggregated query monad type.
type QueryAggregate = Orderings Aggregated Restrictings Aggregated AggregatingSetT QueryCore

-- | Aggregated query type. <a>AggregatedQuery</a> p r ==
--   <a>QueryAggregate</a> (<a>PlaceHolders</a> p, <a>Record</a>
--   <a>Aggregated</a> r).
type AggregatedQuery p r = OrderedQuery Aggregated Restrictings Aggregated AggregatingSetT QueryCore p r

-- | Partition monad type for partition-by clause.
type Window c = Orderings c PartitioningSet c

-- | Finalize grouping set list.
groupingSets :: AggregatingSetList a -> AggregateKey a

-- | Finalize grouping power set as cube power set.
cube :: AggregatingPowerSet a -> AggregateKey a

-- | Finalize grouping power set as rollup power set.
rollup :: AggregatingPowerSet a -> AggregateKey a

-- | Specify key of rollup and cube power set.
bkey :: Record Flat r -> AggregatingPowerSet (Record Aggregated (Maybe r))

-- | Finalize and specify single grouping set.
set :: AggregatingSet a -> AggregatingSetList a

-- | Specify key of single grouping set.
key' :: AggregateKey a -> AggregatingSet a

-- | Specify key of single grouping set from Record.
key :: Record Flat r -> AggregatingSet (Record Aggregated (Maybe r))

-- | Target update monad type used from update statement and merge
--   statement.
type Assign r = Assignings r Restrict

-- | Target register monad type used from insert statement.
type Register r = Assignings r ConfigureQuery

-- | Add and assginment.
(<-#) :: forall (m :: Type -> Type) r v. Monad m => AssignTarget r v -> Record Flat v -> Assignings r m ()
infix 4 <-#

-- | Add an assignment.
assignTo :: forall (m :: Type -> Type) v r. Monad m => Record Flat v -> AssignTarget r v -> Assignings r m ()

-- | Simple (not-aggregated) query monad type.
type QuerySimple = Orderings Flat QueryCore

-- | Simple (not-aggregated) query type. <tt>SimpleQuery'</tt> p r ==
--   <a>QuerySimple</a> (<a>PlaceHolders</a> p, <a>Record</a> r).
type SimpleQuery p r = OrderedQuery Flat QueryCore p r

-- | Unique query monad type.
data QueryUnique a

-- | Extract <a>QueryCore</a> computation.
extractCore :: QueryCore a -> ConfigureQuery (((a, [Predicate Flat]), JoinProduct), Duplication)

-- | Core query monad type used from flat(not-aggregated) query and
--   aggregated query.
type QueryCore = Restrictings Flat QueryJoin ConfigureQuery

-- | OrderedQuery monad type with placeholder type <tt>p</tt>. Record must
--   be the same as <a>Orderings</a> context type parameter <tt>c</tt>.
type OrderedQuery c (m :: Type -> Type) p r = Orderings c m (PlaceHolders p, Record c r)

-- | Add descendant ordering term.
desc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ascendant ordering term.
asc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ordering terms.
orderBy :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Orderings c m ()

-- | Add ordering terms with null ordering.
orderBy' :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Nulls -> Orderings c m ()

-- | Type to accumulate ordering context. Type <tt>c</tt> is ordering term
--   record context type.
data Orderings c (m :: Type -> Type) a

-- | Restrict only monad type used from update statement and delete
--   statement.
type Restrict = Restrictings Flat ConfigureQuery

-- | Add restriction to this aggregated query. Aggregated Record type
--   version.
having :: MonadRestrict Aggregated m => Predicate Aggregated -> m ()

-- | Add restriction to this not aggregated query.
wheres :: MonadRestrict Flat m => Predicate Flat -> m ()

-- | Add restriction to last join. Record type version.
on :: MonadQuery m => Predicate Flat -> m ()

-- | Specify DISTINCT attribute to query context.
distinct :: MonadQuery m => m ()

-- | Specify ALL attribute to query context.
all' :: MonadQuery m => m ()

-- | Restrict context interface
class (Functor m, Monad m) => MonadRestrict c (m :: Type -> Type)

-- | Add restriction to this context.
restrict :: MonadRestrict c m => Predicate c -> m ()

-- | Query building interface.
class (Functor m, Monad m, MonadQualify ConfigureQuery m) => MonadQuery (m :: Type -> Type)

-- | Join sub-query with place-holder parameter <tt>p</tt>. query result is
--   not <a>Maybe</a>.
query' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat r)

-- | Join sub-query with place-holder parameter <tt>p</tt>. Query result is
--   <a>Maybe</a>.
queryMaybe' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat (Maybe r))

-- | Lift interface from base qualify monad.
class (Functor q, Monad q, Functor m, Monad m) => MonadQualify (q :: Type -> Type) (m :: Type -> Type)

-- | Aggregated query building interface extends <a>MonadQuery</a>.
class MonadQuery m => MonadAggregate (m :: Type -> Type)

-- | Add <i>GROUP BY</i> term into context and get aggregated record.
groupBy :: MonadAggregate m => Record Flat r -> m (Record Aggregated r)
groupBy' :: MonadAggregate m => AggregateKey (Record Aggregated r) -> m (Record Aggregated r)

-- | Window specification building interface.
class Monad m => MonadPartition c (m :: Type -> Type)

-- | Add <i>PARTITION BY</i> term into context.
partitionBy :: MonadPartition c m => Record c r -> m ()

-- | Same as <a>(?!?)</a>. Use this operator like '(?? #foo) mayX'.
(??) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ??

-- | Same as <a>(?!)</a>. Use this operator like '(? #foo) mayX'.
(?) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
(!??) :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c
infixl 8 !??

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
flattenPiMaybe :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c

-- | Get narrower record along with projection path and project into result
--   record type. Source record <a>Maybe</a> phantom functor and projection
--   path leaf <a>Maybe</a> functor are <tt>join</tt>-ed.
(?!?) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ?!?

-- | Get narrower record along with projection path <a>Maybe</a> phantom
--   functor is <a>map</a>-ed.
(?!) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?!

-- | Get narrower record along with projection path.
(!) :: PersistableWidth a => Record c a -> Pi a b -> Record c b
infixl 8 !

-- | Aggregation function SOME.
some' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function ANY.
any' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function EVERY.
every :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function MIN.
min' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MIN.
minMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function MAX.
max' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MAX.
maxMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function AVG.
avg :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe b)

-- | Aggregation function AVG.
avgMaybe :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe b)

-- | Aggregation function SUM.
sum' :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function SUM.
sumMaybe :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function COUNT.
count :: (Integral b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac b

-- | Unsafely make aggregation uni-operator from SQL keyword.
unsafeAggregateOp :: (AggregatedContext ac, SqlContext ac) => Keyword -> Record Flat a -> Record ac b

-- | Binary operator the same as <a>projectZip</a>.
(><) :: ProductIsoApplicative p => p a -> p b -> p (a, b)
infixl 1 ><

-- | Zipping projections.
projectZip :: ProductIsoApplicative p => p a -> p b -> p (a, b)

-- | Provide scoped placeholder and return its parameter object. Monadic
--   version.
placeholder :: (PersistableWidth t, SqlContext c, Monad m) => (Record c t -> m a) -> m (PlaceHolders t, a)

-- | Provide scoped placeholder and return its parameter object.
placeholder' :: (PersistableWidth t, SqlContext c) => (Record c t -> a) -> (PlaceHolders t, a)

-- | Provide scoped placeholder from width and return its parameter object.
pwPlaceholder :: SqlContext c => PersistableRecordWidth a -> (Record c a -> b) -> (PlaceHolders a, b)

-- | No placeholder semantics. Same as <a>unitPlaceHolder</a>
unitPH :: PlaceHolders ()

-- | No placeholder semantics
unitPlaceHolder :: PlaceHolders ()

-- | Unsafely get placeholder parameter
unsafePlaceHolders :: PlaceHolders p

-- | Unsafely add placeholder parameter to queries.
unsafeAddPlaceHolders :: Functor f => f a -> f (PlaceHolders p, a)

-- | <i>CUME_DIST()</i> term.
cumeDist :: Record OverWindow Double

-- | <i>PERCENT_RANK()</i> term.
percentRank :: Record OverWindow Double

-- | <i>ROW_NUMBER()</i> term.
rowNumber :: Integral a => Record OverWindow a

-- | <i>DENSE_RANK()</i> term.
denseRank :: Integral a => Record OverWindow a

-- | <i>RANK()</i> term.
rank :: Integral a => Record OverWindow a

-- | Operator from maybe type using record extended <tt>isNull</tt>.
fromMaybe :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c r -> Record c (Maybe r) -> Record c r

-- | Operator corresponding SQL <i>NOT (... IS NULL)</i> , and extended
--   against record type.
isJust :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Operator corresponding SQL <i>IS NULL</i> , and extended against
--   record types.
isNothing :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Binary operator corresponding SQL <i>IN</i> .
in' :: OperatorContext c => Record c t -> RecordList (Record c) t -> Record c (Maybe Bool)
infix 4 `in'`

-- | Null default version of <a>case'</a>.
caseMaybe :: (OperatorContext c, PersistableWidth b) => Record c a -> [(Record c a, Record c (Maybe b))] -> Record c (Maybe b)

-- | Uncurry version of <a>case'</a>, and you can write like ...
--   <a>casesOrElse</a>` <a>clause</a>.
casesOrElse' :: OperatorContext c => (Record c a, [(Record c a, Record c b)]) -> Record c b -> Record c b

-- | Simple case operator correnponding SQL simple <i>CASE</i>. Like,
--   <i>CASE x WHEN v THEN a WHEN w THEN b ... ELSE c END</i>
case' :: OperatorContext c => Record c a -> [(Record c a, Record c b)] -> Record c b -> Record c b

-- | Null default version of <a>caseSearch</a>.
caseSearchMaybe :: (OperatorContext c, PersistableWidth a) => [(Predicate c, Record c (Maybe a))] -> Record c (Maybe a)

-- | Same as <a>caseSearch</a>, but you can write like <a>list</a>
--   <a>casesOrElse</a> <a>clause</a>.
casesOrElse :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Search case operator correnponding SQL search <i>CASE</i>. Like,
--   <i>CASE WHEN p0 THEN a WHEN p1 THEN b ... ELSE c END</i>
caseSearch :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Unsafely show number into string-like type in records.
showNumMaybe :: (SqlContext c, Num a, IsString b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number fromIntegral uni-operator.
fromIntegralMaybe :: (SqlContext c, Integral a, Num b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negateMaybe :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a)

-- | Number operator corresponding SQL <i>*</i> .
(?*?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?*?

-- | Number operator corresponding SQL /// .
(?/?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?/?

-- | Number operator corresponding SQL <i>-</i> .
(?-?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?-?

-- | Number operator corresponding SQL <i>+</i> .
(?+?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?+?

-- | Unsafely show number into string-like type in records.
showNum :: (SqlContext c, Num a, IsString b) => Record c a -> Record c b

-- | Number fromIntegral uni-operator.
fromIntegral' :: (SqlContext c, Integral a, Num b) => Record c a -> Record c b

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negate' :: (OperatorContext c, Num a) => Record c a -> Record c a

-- | Number operator corresponding SQL <i>*</i> .
(.*.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 .*.

-- | Number operator corresponding SQL /// .
(./.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 ./.

-- | Number operator corresponding SQL <i>-</i> .
(.-.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .-.

-- | Number operator corresponding SQL <i>+</i> .
(.+.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .+.

-- | String-compare operator corresponding SQL <i>LIKE</i> . Maybe type
--   version.
likeMaybe :: (OperatorContext c, IsString a, LiteralSQL a) => Record c (Maybe a) -> a -> Record c (Maybe Bool)
infix 4 `likeMaybe`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like :: (OperatorContext c, IsString a, LiteralSQL a) => Record c a -> a -> Record c (Maybe Bool)
infix 4 `like`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
likeMaybe' :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe Bool)
infix 4 `likeMaybe'`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like' :: (OperatorContext c, IsString a) => Record c a -> Record c a -> Record c (Maybe Bool)
infix 4 `like'`

-- | Concatinate operator corresponding SQL <i>||</i> . Maybe type version.
(?||?) :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 5 ?||?

-- | Concatinate operator corresponding SQL <i>||</i> .
(.||.) :: OperatorContext c => Record c a -> Record c a -> Record c a
infixl 5 .||.

-- | Logical operator corresponding SQL <i>EXISTS</i> .
exists :: OperatorContext c => RecordList (Record Exists) r -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>NOT</i> .
not' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>OR</i> .
or' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 2 `or'`

-- | Logical operator corresponding SQL <i>AND</i> .
and' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 3 `and'`

-- | Compare operator corresponding SQL <i>&lt;&gt;</i> .
(.<>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<>.

-- | Compare operator corresponding SQL <i>&gt;=</i> .
(.>=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>=.

-- | Compare operator corresponding SQL <i>&gt;</i> .
(.>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>.

-- | Compare operator corresponding SQL <i>&lt;=</i> .
(.<=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<=.

-- | Compare operator corresponding SQL <i>&lt;</i> .
(.<.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<.

-- | Compare operator corresponding SQL <i>=</i> .
(.=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .=.

-- | Unsafely make binary operator for records from string binary operator.
unsafeBinOp :: SqlContext k => SqlBinOp -> Record k a -> Record k b -> Record k c

-- | Unsafely make unary operator for records from SQL keyword.
unsafeUniOp :: SqlContext c2 => (Keyword -> Keyword) -> Record c1 a -> Record c2 b

-- | Unsafely generate SQL expression string from record object. String
--   interface of <a>unsafeShowSql'</a>.
unsafeShowSql :: Record c a -> String

-- | Unsafely generate SQL expression term from record object.
unsafeShowSql' :: Record c a -> StringSQL

-- | RecordList with polymorphic type of SQL set value from Haskell list.
values :: (LiteralSQL t, OperatorContext c) => [t] -> RecordList (Record c) t

-- | Record with polymorphic type of SQL false value.
valueFalse :: OperatorContext c => Record c (Maybe Bool)

-- | Record with polymorphic type of SQL true value.
valueTrue :: OperatorContext c => Record c (Maybe Bool)

-- | Generate record with polymorphic type of SQL constant values from
--   Haskell value.
value :: (LiteralSQL t, OperatorContext c) => t -> Record c t

-- | Record with polymorphic phantom type of SQL null value. Semantics of
--   comparing is unsafe.
nothing :: (OperatorContext c, SqlContext c, PersistableWidth a) => Record c (Maybe a)

-- | Unsafely Project single SQL string. String interface of
--   <tt>unsafeProjectSql''</tt>.
unsafeProjectSql :: SqlContext c => String -> Record c t

-- | Unsafely Project single SQL term.
unsafeProjectSql' :: SqlContext c => StringSQL -> Record c t

-- | Binary operator type for SQL String.
type SqlBinOp = Keyword -> Keyword -> Keyword

-- | Interface to control <a>Maybe</a> of phantom type in records.
class ProjectableMaybe (p :: Type -> Type)

-- | Cast record phantom type into <a>Maybe</a>.
just :: ProjectableMaybe p => p a -> p (Maybe a)

-- | Compose nested <a>Maybe</a> phantom type on record.
flattenMaybe :: ProjectableMaybe p => p (Maybe (Maybe a)) -> p (Maybe a)

-- | Interface to compose phantom <a>Maybe</a> nested type.
class ProjectableFlattenMaybe a b
flatten :: (ProjectableFlattenMaybe a b, ProjectableMaybe p) => p a -> p b

-- | Projection path for snd of tuple.
snd' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) b

-- | Projection path for fst of tuple.
fst' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) a
tuplePi7_6' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a7
tuplePi7_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a6
tuplePi7_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a5
tuplePi7_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a4
tuplePi7_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a3
tuplePi7_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a2
tuplePi7_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a1
tuplePi6_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a6
tuplePi6_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a5
tuplePi6_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a4
tuplePi6_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a3
tuplePi6_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a2
tuplePi6_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a1
tuplePi5_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a5
tuplePi5_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a4
tuplePi5_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a3
tuplePi5_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a2
tuplePi5_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a1
tuplePi4_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a4
tuplePi4_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a3
tuplePi4_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a2
tuplePi4_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a1
tuplePi3_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a3
tuplePi3_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a2
tuplePi3_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a1
tuplePi2_1' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a2
tuplePi2_0' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a1

-- | Generate update SQL specified by single key.
updateOtherThanKeySQL :: Table r -> Pi r p -> String

-- | Type for query suffix words
type QuerySuffix = [Keyword]

-- | Make projected record list from <a>Record</a> list.
list :: [p t] -> RecordList p t

-- | Projected record list type for row list.
data RecordList (p :: Type -> Type) t

-- | Phantom typed table type
data Table r

-- | Inference rule of <a>Table</a> existence.
class PersistableWidth r => TableDerivable r
derivedTable :: TableDerivable r => Table r

-- | Dump internal structure tree.
dump :: Relation p r -> String

-- | SQL string from <a>Relation</a>.
sqlFromRelation :: Relation p r -> StringSQL

-- | Generate SQL string from <a>Relation</a> with configuration.
sqlFromRelationWith :: Relation p r -> Config -> StringSQL

-- | Simplify placeholder type applying right identity element.
leftPh :: Relation (p, ()) r -> Relation p r

-- | Simplify placeholder type applying left identity element.
rightPh :: Relation ((), p) r -> Relation p r

-- | <a>PersistableRecordWidth</a> of <a>Relation</a> type.
relationWidth :: Relation p r -> PersistableRecordWidth r

-- | Sub-query Qualify monad from relation.
untypeRelation :: Relation p r -> ConfigureQuery SubQuery

-- | Unsafely type qualified subquery into record typed relation type.
unsafeTypeRelation :: ConfigureQuery SubQuery -> Relation p r

-- | Read configuration.
askConfig :: ConfigureQuery Config

-- | Get qualifyed table form query.
qualifyQuery :: a -> ConfigureQuery (Qualified a)

-- | Run <a>ConfigureQuery</a> monad with initial state to get only result.
configureQuery :: ConfigureQuery q -> Config -> q

-- | Thin monad type for untyped structure.
type ConfigureQuery = Qualify QueryConfig Identity

-- | Relation type with place-holder parameter <tt>p</tt> and query result
--   type <tt>r</tt>.
data Relation p r

-- | Interface to project SQL terms unsafely.
class SqlContext c

-- | Unsafely project from SQL expression terms.
unsafeProjectSqlTerms :: SqlContext c => [StringSQL] -> Record c t

-- | Placeholder parameter type which has real parameter type arguemnt
--   <tt>p</tt>.
data PlaceHolders p

-- | SQL string for nested-qeury.
unitSQL :: SubQuery -> String

-- | Width of <a>Qualified</a> <tt>SubQUery</tt>.
queryWidth :: Qualified SubQuery -> Int

-- | Order direction. Ascendant or Descendant.
data Order
Asc :: Order
Desc :: Order

-- | Order of null.
data Nulls
NullsFirst :: Nulls
NullsLast :: Nulls

-- | Typeful aggregate element.
data AggregateKey a

-- | Sub-query type
data SubQuery

-- | Phantom typed record. Projected into Haskell record type <tt>t</tt>.
data Record c t

-- | Type for predicate to restrict of query result.
type Predicate c = Record c Maybe Bool

-- | Type for projection function.
type PI c a b = Record c a -> Record c b

-- | Constraint which represents scalar degree.
class PersistableWidth ct => ScalarDegree ct

-- | Deprecated.
showConstantTermsSQL :: ShowConstantTermsSQL a => a -> [StringSQL]
showConstantTermsSQL' :: ShowConstantTermsSQL a => a -> DList StringSQL

-- | Convert from haskell record to SQL literal row-value.
showLiteral :: LiteralSQL a => a -> [StringSQL]

-- | <a>LiteralSQL</a> <tt>a</tt> is implicit rule to derive function to
--   convert from haskell record type <tt>a</tt> into SQL literal
--   row-value.
--   
--   Generic programming
--   (<a>https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#generic-programming</a>)
--   with default signature is available for <a>LiteralSQL</a> class, so
--   you can make instance like below:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   import GHC.Generics (Generic)
--   --
--   data Foo = Foo { ... } deriving Generic
--   instance LiteralSQL Foo
--   </pre>
class LiteralSQL a
showLiteral' :: LiteralSQL a => a -> DList StringSQL

-- | Deprecated.
type ShowConstantTermsSQL = LiteralSQL

-- | Inferred <a>Unique</a> constraint <a>Key</a>. Record type <tt>r</tt>
--   has unique key which type is <tt>ct</tt> derived from primay key.
derivedUniqueKey :: HasConstraintKey Primary r ct => Key Unique r ct

-- | Derive <a>Unique</a> constraint <a>Key</a> from <a>Primary</a>
--   constraint <a>Key</a>
uniqueKey :: PersistableWidth ct => Key Primary r ct -> Key Unique r ct

-- | Get projection path proof object from constraint <a>Key</a>.
projectionKey :: Key c r ct -> Pi r ct

-- | Get table constraint <a>KeyConstraint</a> proof object from constraint
--   <a>Key</a>.
tableConstraint :: Key c r ct -> KeyConstraint c r

-- | Constraint Key proof object. Constraint type <tt>c</tt>, record type
--   <tt>r</tt> and columns type <tt>ct</tt>.
data Key c r ct

-- | Constraint <a>Key</a> inference interface.
class PersistableWidth ct => HasConstraintKey c r ct

-- | Infer constraint key.
constraintKey :: HasConstraintKey c r ct => Key c r ct

-- | Identity projection path.
id' :: Pi a a

-- | Compose projection path. <a>Maybe</a> phantom functors are
--   <tt>join</tt>-ed like <tt>&gt;=&gt;</tt>.
(<?.?>) :: Pi a (Maybe b) -> Pi b (Maybe c) -> Pi a (Maybe c)
infixl 8 <?.?>

-- | Compose projection path. <a>Maybe</a> phantom functor is
--   <a>map</a>-ed.
(<?.>) :: Pi a (Maybe b) -> Pi b c -> Pi a (Maybe c)
infixl 8 <?.>

-- | Compose projection path.
(<.>) :: Pi a b -> Pi b c -> Pi a c
infixl 8 <.>

-- | Expand indexes from key. Infered width version.
expandIndexes :: PersistableWidth a => Pi a b -> [Int]

-- | Expand indexes from key.
expandIndexes' :: PersistableRecordWidth a -> Pi a b -> [Int]

-- | Projection path from type <tt>r0</tt> into type <tt>r1</tt>. This type
--   also indicate key object which type is <tt>r1</tt> for record type
--   <tt>r0</tt>.
data Pi r0 r1

-- | String wrap type for SQL strings.
type StringSQL = Keyword

-- | Type tag for flat (not-aggregated) query
data Flat

-- | Type tag for aggregated query
data Aggregated

-- | Type tag for exists predicate
data Exists

-- | Type tag for window function building
data OverWindow

-- | Type tag for normal aggregatings set
data Set

-- | Type tag for aggregatings GROUPING SETS
data SetList

-- | Type tag for aggregatings power set
data Power

-- | Default configuration of <a>Config</a>. To change some behaviour of
--   relational-query, use record update syntax:
--   
--   <pre>
--   defaultConfig
--     { productUnitSupport            =  <a>PUSupported</a>
--     , chunksInsertSize              =  256
--     , schemaNameMode                =  <a>SchemaQualified</a>
--     , normalizedTableName           =  True
--     , addQueryTableAliasAS          =  False
--     , addModifyTableAliasAS         =  False
--     , enableWarning                 =  True
--     , verboseAsCompilerWarning      =  False
--     , disableOverloadedProjection   =  False
--     , disableSpecializedProjection  =  False
--     , identifierQuotation           =  <a>NoQuotation</a>
--     , nameConfig                    =
--        defaultNameConfig
--        { recordConfig     =  <a>defaultNameConfig</a>
--        , relationVarName  =  \schema table -&gt; <a>varCamelcaseName</a> $ table ++ "_" ++ scheme
--        -- ^ append the table name after the schema name. e.g. "schemaTable"
--        }
--     }
--   </pre>
defaultConfig :: Config

-- | Default implementation of <a>NameConfig</a> type.
defaultNameConfig :: NameConfig

-- | <a>NameConfig</a> type to customize names of expanded templates.
data NameConfig

-- | Unit of product is supported or not.
data ProductUnitSupport
PUSupported :: ProductUnitSupport
PUNotSupported :: ProductUnitSupport

-- | Schema name qualify mode in SQL string.
data SchemaNameMode

-- | Schema qualified table name in SQL string
SchemaQualified :: SchemaNameMode

-- | Not qualified table name in SQL string
SchemaNotQualified :: SchemaNameMode

-- | Configuration for quotation of identifiers of SQL.
data IdentifierQuotation
NoQuotation :: IdentifierQuotation
Quotation :: Char -> IdentifierQuotation

-- | Configuration type.
data Config
data Primary
data NotNull
data Unique

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery :: Relation p r -> [Keyword] -> Query p r

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object.
insertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object with no(unit) placeholder.
insertValueNoPH :: TableDerivable r => Register r () -> Insert ()

-- | Make <a>InsertQuery</a> from derived table, <a>Pi</a> and
--   <a>Relation</a>.
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation.
update :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation
--   with no(unit) placeholder.
updateNoPH :: TableDerivable r => (Record Flat r -> Assign r ()) -> Update ()

-- | Make <a>Delete</a> from derived table and <a>Restrict</a> computation.
delete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation with no(unit) placeholder.
deleteNoPH :: TableDerivable r => (Record Flat r -> Restrict ()) -> Delete ()


module Database.Relational.Schema.PostgreSQL.PgAttribute
data PgAttribute
PgAttribute :: !Int32 -> !String -> !Int32 -> !Int32 -> !Int16 -> !Int16 -> !Int32 -> !Int32 -> !Int32 -> !Bool -> !Char -> !Char -> !Bool -> !Bool -> !Bool -> !Bool -> !Int32 -> !Int32 -> PgAttribute
[attrelid] :: PgAttribute -> !Int32
[attname] :: PgAttribute -> !String
[atttypid] :: PgAttribute -> !Int32
[attstattarget] :: PgAttribute -> !Int32
[attlen] :: PgAttribute -> !Int16
[attnum] :: PgAttribute -> !Int16
[attndims] :: PgAttribute -> !Int32
[attcacheoff] :: PgAttribute -> !Int32
[atttypmod] :: PgAttribute -> !Int32
[attbyval] :: PgAttribute -> !Bool
[attstorage] :: PgAttribute -> !Char
[attalign] :: PgAttribute -> !Char
[attnotnull] :: PgAttribute -> !Bool
[atthasdef] :: PgAttribute -> !Bool
[attisdropped] :: PgAttribute -> !Bool
[attislocal] :: PgAttribute -> !Bool
[attinhcount] :: PgAttribute -> !Int32
[attcollation] :: PgAttribute -> !Int32
attcollation' :: Pi PgAttribute Int32
attinhcount' :: Pi PgAttribute Int32
attislocal' :: Pi PgAttribute Bool
attisdropped' :: Pi PgAttribute Bool
atthasdef' :: Pi PgAttribute Bool
attnotnull' :: Pi PgAttribute Bool
attalign' :: Pi PgAttribute Char
attstorage' :: Pi PgAttribute Char
attbyval' :: Pi PgAttribute Bool
atttypmod' :: Pi PgAttribute Int32
attcacheoff' :: Pi PgAttribute Int32
attndims' :: Pi PgAttribute Int32
attnum' :: Pi PgAttribute Int16
attlen' :: Pi PgAttribute Int16
attstattarget' :: Pi PgAttribute Int32
atttypid' :: Pi PgAttribute Int32
attname' :: Pi PgAttribute String
attrelid' :: Pi PgAttribute Int32
insertQueryPgAttribute :: forall p_aKXw. Relation p_aKXw PgAttribute -> InsertQuery p_aKXw
insertPgAttribute :: Insert PgAttribute
pgAttribute :: Relation () PgAttribute
tableOfPgAttribute :: Table PgAttribute
columnOffsetsPgAttribute :: Array Int Int
instance GHC.Generics.Generic Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute
instance GHC.Show.Show Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute
instance Database.Record.Persistable.PersistableWidth Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute
instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Int.Int32 -> GHC.Base.String -> GHC.Int.Int32 -> GHC.Int.Int32 -> GHC.Int.Int16 -> GHC.Int.Int16 -> GHC.Int.Int32 -> GHC.Int.Int32 -> GHC.Int.Int32 -> GHC.Types.Bool -> GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool -> GHC.Int.Int32 -> GHC.Int.Int32 -> Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute)
instance Database.Relational.ProjectableClass.LiteralSQL Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute
instance Database.Relational.Table.TableDerivable Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute
instance Database.Relational.OverloadedProjection.HasProjection "attrelid" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "attname" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "atttypid" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "attstattarget" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "attlen" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Int.Int16
instance Database.Relational.OverloadedProjection.HasProjection "attnum" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Int.Int16
instance Database.Relational.OverloadedProjection.HasProjection "attndims" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "attcacheoff" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "atttypmod" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "attbyval" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Types.Bool
instance Database.Relational.OverloadedProjection.HasProjection "attstorage" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Types.Char
instance Database.Relational.OverloadedProjection.HasProjection "attalign" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Types.Char
instance Database.Relational.OverloadedProjection.HasProjection "attnotnull" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Types.Bool
instance Database.Relational.OverloadedProjection.HasProjection "atthasdef" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Types.Bool
instance Database.Relational.OverloadedProjection.HasProjection "attisdropped" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Types.Bool
instance Database.Relational.OverloadedProjection.HasProjection "attislocal" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Types.Bool
instance Database.Relational.OverloadedProjection.HasProjection "attinhcount" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "attcollation" Database.Relational.Schema.PostgreSQL.PgAttribute.PgAttribute GHC.Int.Int32


-- | <i>Deprecated: import
--   Database.Relational.Schema.PostgreSQL.PgAttribute instead of this
--   module.</i>
module Database.Relational.Schema.PgCatalog.PgAttribute


module Database.Relational.Schema.PostgreSQL.PgType
data PgType
PgType :: !Int32 -> !String -> !Int32 -> !Int32 -> !Int16 -> !Bool -> !Char -> !Char -> !Bool -> !Bool -> !Char -> !Int32 -> !Int32 -> !Int32 -> !Char -> !Char -> !Bool -> !Int32 -> !Int32 -> !Int32 -> !Int32 -> !Maybe String -> PgType
[oid] :: PgType -> !Int32
[typname] :: PgType -> !String
[typnamespace] :: PgType -> !Int32
[typowner] :: PgType -> !Int32
[typlen] :: PgType -> !Int16
[typbyval] :: PgType -> !Bool
[typtype] :: PgType -> !Char
[typcategory] :: PgType -> !Char
[typispreferred] :: PgType -> !Bool
[typisdefined] :: PgType -> !Bool
[typdelim] :: PgType -> !Char
[typrelid] :: PgType -> !Int32
[typelem] :: PgType -> !Int32
[typarray] :: PgType -> !Int32
[typalign] :: PgType -> !Char
[typstorage] :: PgType -> !Char
[typnotnull] :: PgType -> !Bool
[typbasetype] :: PgType -> !Int32
[typtypmod] :: PgType -> !Int32
[typndims] :: PgType -> !Int32
[typcollation] :: PgType -> !Int32
[typdefault] :: PgType -> !Maybe String
typdefault' :: Pi PgType (Maybe String)
typcollation' :: Pi PgType Int32
typndims' :: Pi PgType Int32
typtypmod' :: Pi PgType Int32
typbasetype' :: Pi PgType Int32
typnotnull' :: Pi PgType Bool
typstorage' :: Pi PgType Char
typalign' :: Pi PgType Char
typarray' :: Pi PgType Int32
typelem' :: Pi PgType Int32
typrelid' :: Pi PgType Int32
typdelim' :: Pi PgType Char
typisdefined' :: Pi PgType Bool
typispreferred' :: Pi PgType Bool
typcategory' :: Pi PgType Char
typtype' :: Pi PgType Char
typbyval' :: Pi PgType Bool
typlen' :: Pi PgType Int16
typowner' :: Pi PgType Int32
typnamespace' :: Pi PgType Int32
typname' :: Pi PgType String
oid' :: Pi PgType Int32
insertQueryPgType :: forall p_aRwm. Relation p_aRwm PgType -> InsertQuery p_aRwm
insertPgType :: Insert PgType
pgType :: Relation () PgType
tableOfPgType :: Table PgType
columnOffsetsPgType :: Array Int Int
instance GHC.Generics.Generic Database.Relational.Schema.PostgreSQL.PgType.PgType
instance GHC.Show.Show Database.Relational.Schema.PostgreSQL.PgType.PgType
instance Database.Record.Persistable.PersistableWidth Database.Relational.Schema.PostgreSQL.PgType.PgType
instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Int.Int32 -> GHC.Base.String -> GHC.Int.Int32 -> GHC.Int.Int32 -> GHC.Int.Int16 -> GHC.Types.Bool -> GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Char -> GHC.Int.Int32 -> GHC.Int.Int32 -> GHC.Int.Int32 -> GHC.Types.Char -> GHC.Types.Char -> GHC.Types.Bool -> GHC.Int.Int32 -> GHC.Int.Int32 -> GHC.Int.Int32 -> GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Base.String -> Database.Relational.Schema.PostgreSQL.PgType.PgType)
instance Database.Relational.ProjectableClass.LiteralSQL Database.Relational.Schema.PostgreSQL.PgType.PgType
instance Database.Relational.Table.TableDerivable Database.Relational.Schema.PostgreSQL.PgType.PgType
instance Database.Relational.OverloadedProjection.HasProjection "oid" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "typname" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "typnamespace" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "typowner" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "typlen" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int16
instance Database.Relational.OverloadedProjection.HasProjection "typbyval" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Types.Bool
instance Database.Relational.OverloadedProjection.HasProjection "typtype" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Types.Char
instance Database.Relational.OverloadedProjection.HasProjection "typcategory" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Types.Char
instance Database.Relational.OverloadedProjection.HasProjection "typispreferred" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Types.Bool
instance Database.Relational.OverloadedProjection.HasProjection "typisdefined" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Types.Bool
instance Database.Relational.OverloadedProjection.HasProjection "typdelim" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Types.Char
instance Database.Relational.OverloadedProjection.HasProjection "typrelid" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "typelem" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "typarray" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "typalign" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Types.Char
instance Database.Relational.OverloadedProjection.HasProjection "typstorage" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Types.Char
instance Database.Relational.OverloadedProjection.HasProjection "typnotnull" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Types.Bool
instance Database.Relational.OverloadedProjection.HasProjection "typbasetype" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "typtypmod" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "typndims" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "typcollation" Database.Relational.Schema.PostgreSQL.PgType.PgType GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "typdefault" Database.Relational.Schema.PostgreSQL.PgType.PgType (GHC.Maybe.Maybe GHC.Base.String)


-- | This module implements queries to get table schema and table
--   constraint informations from system catalog of PostgreSQL.
module Database.Relational.Schema.PostgreSQL

-- | Configuration parameter against PostgreSQL.
config :: Config

-- | Type to represent Column information.
type Column = (PgAttribute, PgType)

-- | Normalize column name string to query PostgreSQL system catalog.
normalizeColumn :: String -> String

-- | Not-null attribute information of column.
notNull :: Column -> Bool

-- | Get column normalized name and column Haskell type.
getType :: Map String TypeQ -> Column -> Maybe (String, TypeQ)

-- | Phantom typed <a>Query</a> to get <a>Column</a> from schema name and
--   table name.
columnQuerySQL :: Query (String, String) Column

-- | Phantom typed <a>Query</a> to get primary key length from schema name
--   and table name.
primaryKeyLengthQuerySQL :: Query (String, String) Int32

-- | Phantom typed <a>Query</a> to get primary key name from schema name
--   and table name.
primaryKeyQuerySQL :: Int32 -> Query (String, String) String


-- | <i>Deprecated: import Database.Relational.Schema.PostgreSQL.PgType
--   instead of this module.</i>
module Database.Relational.Schema.PgCatalog.PgType

module Database.Relational.Schema.SQLServer.Columns
data Columns
Columns :: !Int32 -> !Maybe String -> !Int32 -> !Int32 -> !Maybe Bool -> Columns
[objectId] :: Columns -> !Int32
[name] :: Columns -> !Maybe String
[columnId] :: Columns -> !Int32
[userTypeId] :: Columns -> !Int32
[isNullable] :: Columns -> !Maybe Bool
isNullable' :: Pi Columns (Maybe Bool)
userTypeId' :: Pi Columns Int32
columnId' :: Pi Columns Int32
name' :: Pi Columns (Maybe String)
objectId' :: Pi Columns Int32
insertQueryColumns :: forall p_aZSD. Relation p_aZSD Columns -> InsertQuery p_aZSD
insertColumns :: Insert Columns
columns :: Relation () Columns
tableOfColumns :: Table Columns
columnOffsetsColumns :: Array Int Int
instance GHC.Generics.Generic Database.Relational.Schema.SQLServer.Columns.Columns
instance GHC.Show.Show Database.Relational.Schema.SQLServer.Columns.Columns
instance Database.Record.Persistable.PersistableWidth Database.Relational.Schema.SQLServer.Columns.Columns
instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Int.Int32 -> GHC.Int.Int32 -> GHC.Maybe.Maybe GHC.Types.Bool -> Database.Relational.Schema.SQLServer.Columns.Columns)
instance Database.Relational.ProjectableClass.LiteralSQL Database.Relational.Schema.SQLServer.Columns.Columns
instance Database.Relational.Table.TableDerivable Database.Relational.Schema.SQLServer.Columns.Columns
instance Database.Relational.OverloadedProjection.HasProjection "objectId" Database.Relational.Schema.SQLServer.Columns.Columns GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "name" Database.Relational.Schema.SQLServer.Columns.Columns (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "columnId" Database.Relational.Schema.SQLServer.Columns.Columns GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "userTypeId" Database.Relational.Schema.SQLServer.Columns.Columns GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "isNullable" Database.Relational.Schema.SQLServer.Columns.Columns (GHC.Maybe.Maybe GHC.Types.Bool)


-- | This module provides custom APIs with appropriate configuration for
--   SQLServer.
module Database.Custom.SQLServer

-- | <a>UniqueRelation</a> inferred from table.
derivedUniqueRelation :: TableDerivable r => Key Unique r k -> Record c k -> UniqueRelation () c r

-- | Typed <a>KeyUpdate</a> using inferred primary key.
primaryUpdate :: HasConstraintKey Primary r p => Table r -> KeyUpdate p r

-- | Typed <a>KeyUpdate</a> using specified constraint key.
updateByConstraintKey :: Table r -> Key c r p -> KeyUpdate p r

-- | Convert from Haskell type <tt>r</tt> into SQL value <tt>q</tt> list
--   expected by update form like
--   
--   <i>UPDATE <a>table</a> SET c0 = ?, c1 = ?, ..., cn = ? WHERE key0 = ?
--   AND key1 = ? AND key2 = ? ... </i>
--   
--   using derived <tt>RecordToSql</tt> proof object.
updateValuesWithKey :: ToSql q r => Pi r p -> r -> [q]

-- | Deprecated.
primary :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Query restricted with inferred primary key.
primarySelect :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Deprecated.
primary' :: PersistableWidth p => Key Primary a p -> Relation () a -> Relation p a

-- | Deprecated.
unique :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified unique key.
uniqueSelect :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified key.
specifiedKey :: PersistableWidth p => Pi a p -> Relation () a -> Relation p a

-- | Update statement for sequence table
updateNumber :: (PersistableWidth s, Integral i, LiteralSQL i) => i -> Sequence s i -> Update ()

-- | Update statement for sequence table
updateNumber' :: (PersistableWidth s, Integral i, LiteralSQL i) => Config -> i -> Sequence s i -> Update ()

-- | Unsafely apply sequence number. Only safe to build corresponding
--   record type.
($$) :: Binding r s i => (i -> r) -> Number r i -> r

-- | Unsafely apply sequence number.
($$!) :: (i -> r) -> Number r i -> r

-- | Get untyped sequence number.
extractNumber :: Number r i -> i

-- | Unsafely specify sequence number.
unsafeSpecifyNumber :: Binding r s i => i -> Number r i

-- | Derive <a>Sequence</a> from corresponding <a>Relation</a>
fromRelation :: Binding r s i => Relation () r -> Sequence s i

-- | Derive binding using primary key.
primaryBinding :: (TableDerivable r, SequenceDerivable s i, HasConstraintKey Primary r i) => SeqBinding r s i

-- | Unsafely specify binding between normal-table and sequence-table.
unsafeSpecifyBinding :: (TableDerivable r, SequenceDerivable s i) => Pi r i -> SeqBinding r s i

-- | Infer <a>Relation</a> of sequence table
seqRelation :: TableDerivable s => Sequence s i -> Relation () s

-- | Unsafely specify sequence table.
unsafeSpecifySequence :: TableDerivable s => (s -> i) -> Pi s i -> Sequence s i

-- | Basic record to express sequence-table. actual sequence-table is a
--   table which has only one column of integer type.
data Sequence s i

-- | <a>Sequence</a> derivation rule
class TableDerivable s => SequenceDerivable s i | s -> i
derivedSequence :: SequenceDerivable s i => Sequence s i

-- | Record to express binding between normal-table and sequence-table.
data SeqBinding r s i

-- | Derivation rule for binding between <a>Table</a> and <a>Sequence</a>
class (TableDerivable r, SequenceDerivable s i) => Binding r s i | r -> s
binding :: Binding r s i => SeqBinding r s i

-- | Sequence number type for record type <tt>r</tt>
data Number r i

-- | Make typed <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
delete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Table</a> and <a>Restrict</a>
--   computation.
typedDelete :: Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, <a>Table</a> and
--   <a>Restrict</a> computation.
typedDelete' :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make untyped delete SQL string from <a>Table</a> and <a>Restrict</a>
--   computation.
deleteSQL :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> String

-- | Table type inferred <a>InsertQuery</a>.
derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Table type inferred <a>InsertQuery</a>.
insertQuery' :: TableDerivable r => Config -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a>.
typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a> with configuration parameter.
typedInsertQuery' :: Config -> Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make untyped insert select SQL string from <a>Table</a>, <a>Pi</a> and
--   <a>Relation</a>.
insertQuerySQL :: Config -> Table r -> Pi r r' -> Relation p r' -> String

-- | Make typed <a>Insert</a> list from records list.
insertValueList :: (TableDerivable r, LiteralSQL r') => Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> list from <a>Config</a> and records list.
insertValueList' :: (TableDerivable r, LiteralSQL r') => Config -> Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> from <a>defaultConfig</a>, derived table and
--   monadic builded <a>Register</a> object.
derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
insertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Table</a> and monadic builded
--   <a>InsertTarget</a> object.
typedInsertValue :: Table r -> InsertTarget p r -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, <a>Table</a> and monadic
--   builded <a>InsertTarget</a> object.
typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p

-- | Table type inferred <a>Insert</a>.
derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Table type inferred <a>Insert</a>.
insert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a>.
typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a> with configuration parameter.
typedInsert' :: PersistableWidth r => Config -> Table r -> Pi r r' -> Insert r'

-- | Unsafely make typed <a>Insert</a> from single insert and chunked
--   insert SQL.
unsafeTypedInsert' :: String -> String -> Int -> Insert a

-- | Size to use chunked insert
chunkSizeOfInsert :: Insert a -> Int

-- | Statement to use chunked insert
untypeChunkInsert :: Insert a -> String

-- | Deprecated. use <a>updateAllColumn</a>.
derivedUpdateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation without placeholder other than target
--   table columns. Update target is all column.
updateAllColumnNoPH :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict ()) -> Update r

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Deprecated. use <a>updateAllColumn'</a>.
derivedUpdateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Table</a> and <a>Restrict</a>
--   computation. Update target is all column.
typedUpdateAllColumn :: PersistableWidth r => Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
update' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> using <a>defaultConfig</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate :: Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate' :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make untyped update SQL string from <a>Table</a> and <a>Assign</a>
--   computation.
updateSQL :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> String

-- | Unsafely make typed <a>Update</a> from SQL string.
unsafeTypedUpdate :: String -> Update p

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
keyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> object using derived info specified by
--   <a>Relation</a> type.
typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from <a>Table</a> and key columns selector
--   <a>Pi</a>.
typedKeyUpdate :: Table a -> Pi a p -> KeyUpdate p a

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery' :: Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery_ :: Config -> Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into untyped SQL query string.
relationalQuerySQL :: Config -> Relation p r -> QuerySuffix -> String

-- | Unsafely make typed <a>Query</a> from SQL string.
unsafeTypedQuery :: String -> Query p a

-- | Query type with place-holder parameter <tt>p</tt> and query result
--   type <tt>a</tt>.
newtype Query p a
Query :: String -> Query p a
[untypeQuery] :: Query p a -> String

-- | Update type with key type <tt>p</tt> and update record type
--   <tt>a</tt>. Columns to update are record columns other than key
--   columns, So place-holder parameter type is the same as record type
--   <tt>a</tt>.
data KeyUpdate p a
KeyUpdate :: Pi a p -> String -> KeyUpdate p a
[updateKey] :: KeyUpdate p a -> Pi a p
[untypeKeyUpdate] :: KeyUpdate p a -> String

-- | Update type with place-holder parameter <tt>p</tt>.
newtype Update p
Update :: String -> Update p
[untypeUpdate] :: Update p -> String

-- | Insert type to insert record type <tt>a</tt>.
data Insert a
Insert :: String -> Maybe (String, Int) -> Insert a
[untypeInsert] :: Insert a -> String
[chunkedInsert] :: Insert a -> Maybe (String, Int)

-- | InsertQuery type.
newtype InsertQuery p
InsertQuery :: String -> InsertQuery p
[untypeInsertQuery] :: InsertQuery p -> String

-- | Delete type with place-holder parameter <tt>p</tt>.
newtype Delete p
Delete :: String -> Delete p
[untypeDelete] :: Delete p -> String

-- | Untype interface for typed no-result type statments with single type
--   parameter which represents place-holder parameter <tt>p</tt>.
class UntypeableNoFetch (s :: Type -> Type)
untypeNoFetch :: UntypeableNoFetch s => s p -> String

-- | Make <a>StringSQL</a> strings of SQL INSERT strings from records list
sqlChunksFromRecordList :: LiteralSQL r' => Config -> Table r -> Pi r r' -> [r'] -> [StringSQL]

-- | Make <a>StringSQL</a> string of SQL INSERT statement from
--   <a>InsertTarget</a>
sqlFromInsertTarget :: Config -> Table r -> InsertTarget p r -> StringSQL

-- | Make <a>StringSQL</a> string of SQL INSERT record chunk statement from
--   <a>InsertTarget</a>
sqlChunkFromInsertTarget :: Config -> Table r -> InsertTarget p r -> (StringSQL, Int)

-- | parametalized <a>Register</a> monad from <a>Pi</a>
piRegister :: PersistableWidth r => Pi r r' -> Register r (PlaceHolders r')

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a> with
--   place-holder parameter <tt>p</tt>.
insertTarget' :: Register r (PlaceHolders p) -> InsertTarget p r

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a>.
insertTarget :: Register r () -> InsertTarget () r

-- | SQL SET clause and WHERE clause <a>StringSQL</a> string from
--   <a>Assign</a> computation.
sqlFromUpdateTarget :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> StringSQL

-- | Deprecated.
updateTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Deprecated.
updateTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict ()) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all. With placefolder type <tt>p</tt>.
liftTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all.
liftTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders ())) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Deprecated.
updateTarget' :: (Record Flat r -> Assign r (PlaceHolders p)) -> UpdateTarget p r

-- | Deprecated.
updateTarget :: (Record Flat r -> Assign r ()) -> UpdateTarget () r

-- | SQL WHERE clause <a>StringSQL</a> string from <a>Restrict</a>
--   computation.
sqlWhereFromRestriction :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> StringSQL

-- | Deprecated.
restriction' :: (Record Flat r -> Restrict (PlaceHolders p)) -> Restriction p r

-- | Deprecated.
restriction :: (Record Flat r -> Restrict ()) -> Restriction () r

-- | Restriction type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type Restriction p r = Record Flat r -> Restrict PlaceHolders p

-- | UpdateTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type UpdateTarget p r = Record Flat r -> Assign r PlaceHolders p

-- | InsertTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
data InsertTarget p r

-- | Intersection of two relations with place-holder parameters. Not
--   distinct.
intersectAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersectAll'`

-- | Intersection of two relations with place-holder parameters.
intersect' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersect'`

-- | Subtraction of two relations with place-holder parameters. Not
--   distinct.
exceptAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `exceptAll'`

-- | Subtraction of two relations with place-holder parameters.
except' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `except'`

-- | Union of two relations with place-holder parameters. Not distinct.
unionAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `unionAll'`

-- | Union of two relations with place-holder parameters.
union' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `union'`

-- | Intersection of two relations. Not distinct.
intersectAll :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersectAll`

-- | Intersection of two relations.
intersect :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersect`

-- | Subtraction of two relations. Not distinct.
exceptAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `exceptAll`

-- | Subtraction of two relations.
except :: Relation () a -> Relation () a -> Relation () a
infixl 7 `except`

-- | Union of two relations. Not distinct.
unionAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `unionAll`

-- | Union of two relations.
union :: Relation () a -> Relation () a -> Relation () a
infixl 7 `union`

-- | Apply restriction for direct join style.
on' :: ([JoinRestriction a b] -> Relation pc (a, b)) -> [JoinRestriction a b] -> Relation pc (a, b)
infixl 8 `on'`

-- | Direct full outer join.
full :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation () (Maybe a, Maybe b)
infixl 8 `full`

-- | Direct right outer join.
right :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) b] -> Relation () (Maybe a, b)
infixl 8 `right`

-- | Direct left outer join.
left :: Relation () a -> Relation () b -> [JoinRestriction a (Maybe b)] -> Relation () (a, Maybe b)
infixl 8 `left`

-- | Direct inner join.
inner :: Relation () a -> Relation () b -> [JoinRestriction a b] -> Relation () (a, b)
infixl 8 `inner`

-- | Direct full outer join with place-holder parameters.
full' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation (pa, pb) (Maybe a, Maybe b)
infixl 8 `full'`

-- | Direct right outer join with place-holder parameters.
right' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) b] -> Relation (pa, pb) (Maybe a, b)
infixl 8 `right'`

-- | Direct left outer join with place-holder parameters.
left' :: Relation pa a -> Relation pb b -> [JoinRestriction a (Maybe b)] -> Relation (pa, pb) (a, Maybe b)
infixl 8 `left'`

-- | Direct inner join with place-holder parameters.
inner' :: Relation pa a -> Relation pb b -> [JoinRestriction a b] -> Relation (pa, pb) (a, b)
infixl 8 `inner'`

-- | Restriction predicate function type for direct style join operator,
--   used on predicates of direct join style as follows.
--   
--   <pre>
--   do xy &lt;- query $
--            relX <a>inner</a> relY <a>on</a>` [ x y -&gt; ... ] -- this lambda form has JoinRestriction type
--      ...
--   </pre>
type JoinRestriction a b = Record Flat a -> Record Flat b -> Predicate Flat

-- | Scalar sub-query.
queryScalar :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation () c r -> m (Record c (Maybe r))

-- | Scalar sub-query with place-holder parameter <tt>p</tt>.
queryScalar' :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation p c r -> m (PlaceHolders p, Record c (Maybe r))

-- | Aggregated <a>UniqueRelation</a>.
aggregatedUnique :: Relation ph r -> Pi r a -> (Record Flat a -> Record Aggregated b) -> UniqueRelation ph Flat b

-- | Finalize <a>QueryUnique</a> monad and generate <a>UniqueRelation</a>.
uniqueRelation' :: QueryUnique (PlaceHolders p, Record c r) -> UniqueRelation p c r

-- | Join unique sub-query with place-holder parameter <tt>p</tt>. Query
--   result is <a>Maybe</a>.
uniqueQueryMaybe' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c (Maybe r))

-- | Join unique sub-query with place-holder parameter <tt>p</tt>.
uniqueQuery' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c r)

-- | Discard unique attribute.
unUnique :: UniqueRelation p c r -> Relation p r

-- | Unsafely specify unique relation.
unsafeUnique :: Relation p r -> UniqueRelation p c r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a>.
aggregateRelation :: QueryAggregate (Record Aggregated r) -> Relation () r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
aggregateRelation' :: AggregatedQuery p r -> Relation p r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a>.
relation :: QuerySimple (Record Flat r) -> Relation () r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
relation' :: SimpleQuery p r -> Relation p r

-- | List sub-query, for <i>IN</i> and <i>EXIST</i>.
queryList :: MonadQualify ConfigureQuery m => Relation () r -> m (RecordList (Record c) r)

-- | List sub-query, for <i>IN</i> and <i>EXIST</i> with place-holder
--   parameter <tt>p</tt>.
queryList' :: MonadQualify ConfigureQuery m => Relation p r -> m (PlaceHolders p, RecordList (Record c) r)

-- | Join sub-query. Query result is <a>Maybe</a>. The combinations of
--   <a>query</a> and <a>queryMaybe</a> express inner joins, left outer
--   joins, right outer joins, and full outer joins. Here is an example of
--   a right outer join:
--   
--   <pre>
--   outerJoin = relation $ do
--     e &lt;- queryMaybe employee
--     d &lt;- query department
--     on $ e ?! E.deptId' .=. just (d ! D.deptId')
--     return $ (,) |$| e |*| d
--   </pre>
queryMaybe :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat (Maybe r))

-- | Join sub-query. Query result is not <a>Maybe</a>.
query :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat r)

-- | Interface to derive <a>Table</a> type object.
tableOf :: TableDerivable r => Relation () r -> Table r

-- | Inferred <a>Relation</a>.
derivedRelation :: TableDerivable r => Relation () r

-- | Simple <a>Relation</a> from <a>Table</a>.
table :: Table r -> Relation () r

-- | Unique relation type to compose scalar queries.
data UniqueRelation p c r

-- | Operator to make record of window function result using built
--   <a>Window</a> monad.
over :: SqlContext c => Record OverWindow a -> Window c () -> Record c a
infix 8 `over`

-- | Aggregated query monad type.
type QueryAggregate = Orderings Aggregated Restrictings Aggregated AggregatingSetT QueryCore

-- | Aggregated query type. <a>AggregatedQuery</a> p r ==
--   <a>QueryAggregate</a> (<a>PlaceHolders</a> p, <a>Record</a>
--   <a>Aggregated</a> r).
type AggregatedQuery p r = OrderedQuery Aggregated Restrictings Aggregated AggregatingSetT QueryCore p r

-- | Partition monad type for partition-by clause.
type Window c = Orderings c PartitioningSet c

-- | Finalize grouping set list.
groupingSets :: AggregatingSetList a -> AggregateKey a

-- | Finalize grouping power set as cube power set.
cube :: AggregatingPowerSet a -> AggregateKey a

-- | Finalize grouping power set as rollup power set.
rollup :: AggregatingPowerSet a -> AggregateKey a

-- | Specify key of rollup and cube power set.
bkey :: Record Flat r -> AggregatingPowerSet (Record Aggregated (Maybe r))

-- | Finalize and specify single grouping set.
set :: AggregatingSet a -> AggregatingSetList a

-- | Specify key of single grouping set.
key' :: AggregateKey a -> AggregatingSet a

-- | Specify key of single grouping set from Record.
key :: Record Flat r -> AggregatingSet (Record Aggregated (Maybe r))

-- | Target update monad type used from update statement and merge
--   statement.
type Assign r = Assignings r Restrict

-- | Target register monad type used from insert statement.
type Register r = Assignings r ConfigureQuery

-- | Add and assginment.
(<-#) :: forall (m :: Type -> Type) r v. Monad m => AssignTarget r v -> Record Flat v -> Assignings r m ()
infix 4 <-#

-- | Add an assignment.
assignTo :: forall (m :: Type -> Type) v r. Monad m => Record Flat v -> AssignTarget r v -> Assignings r m ()

-- | Simple (not-aggregated) query monad type.
type QuerySimple = Orderings Flat QueryCore

-- | Simple (not-aggregated) query type. <tt>SimpleQuery'</tt> p r ==
--   <a>QuerySimple</a> (<a>PlaceHolders</a> p, <a>Record</a> r).
type SimpleQuery p r = OrderedQuery Flat QueryCore p r

-- | Unique query monad type.
data QueryUnique a

-- | Extract <a>QueryCore</a> computation.
extractCore :: QueryCore a -> ConfigureQuery (((a, [Predicate Flat]), JoinProduct), Duplication)

-- | Core query monad type used from flat(not-aggregated) query and
--   aggregated query.
type QueryCore = Restrictings Flat QueryJoin ConfigureQuery

-- | OrderedQuery monad type with placeholder type <tt>p</tt>. Record must
--   be the same as <a>Orderings</a> context type parameter <tt>c</tt>.
type OrderedQuery c (m :: Type -> Type) p r = Orderings c m (PlaceHolders p, Record c r)

-- | Add descendant ordering term.
desc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ascendant ordering term.
asc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ordering terms.
orderBy :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Orderings c m ()

-- | Add ordering terms with null ordering.
orderBy' :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Nulls -> Orderings c m ()

-- | Type to accumulate ordering context. Type <tt>c</tt> is ordering term
--   record context type.
data Orderings c (m :: Type -> Type) a

-- | Restrict only monad type used from update statement and delete
--   statement.
type Restrict = Restrictings Flat ConfigureQuery

-- | Add restriction to this aggregated query. Aggregated Record type
--   version.
having :: MonadRestrict Aggregated m => Predicate Aggregated -> m ()

-- | Add restriction to this not aggregated query.
wheres :: MonadRestrict Flat m => Predicate Flat -> m ()

-- | Add restriction to last join. Record type version.
on :: MonadQuery m => Predicate Flat -> m ()

-- | Specify DISTINCT attribute to query context.
distinct :: MonadQuery m => m ()

-- | Specify ALL attribute to query context.
all' :: MonadQuery m => m ()

-- | Restrict context interface
class (Functor m, Monad m) => MonadRestrict c (m :: Type -> Type)

-- | Add restriction to this context.
restrict :: MonadRestrict c m => Predicate c -> m ()

-- | Query building interface.
class (Functor m, Monad m, MonadQualify ConfigureQuery m) => MonadQuery (m :: Type -> Type)

-- | Join sub-query with place-holder parameter <tt>p</tt>. query result is
--   not <a>Maybe</a>.
query' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat r)

-- | Join sub-query with place-holder parameter <tt>p</tt>. Query result is
--   <a>Maybe</a>.
queryMaybe' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat (Maybe r))

-- | Lift interface from base qualify monad.
class (Functor q, Monad q, Functor m, Monad m) => MonadQualify (q :: Type -> Type) (m :: Type -> Type)

-- | Aggregated query building interface extends <a>MonadQuery</a>.
class MonadQuery m => MonadAggregate (m :: Type -> Type)

-- | Add <i>GROUP BY</i> term into context and get aggregated record.
groupBy :: MonadAggregate m => Record Flat r -> m (Record Aggregated r)
groupBy' :: MonadAggregate m => AggregateKey (Record Aggregated r) -> m (Record Aggregated r)

-- | Window specification building interface.
class Monad m => MonadPartition c (m :: Type -> Type)

-- | Add <i>PARTITION BY</i> term into context.
partitionBy :: MonadPartition c m => Record c r -> m ()

-- | Same as <a>(?!?)</a>. Use this operator like '(?? #foo) mayX'.
(??) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ??

-- | Same as <a>(?!)</a>. Use this operator like '(? #foo) mayX'.
(?) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
(!??) :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c
infixl 8 !??

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
flattenPiMaybe :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c

-- | Get narrower record along with projection path and project into result
--   record type. Source record <a>Maybe</a> phantom functor and projection
--   path leaf <a>Maybe</a> functor are <tt>join</tt>-ed.
(?!?) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ?!?

-- | Get narrower record along with projection path <a>Maybe</a> phantom
--   functor is <a>map</a>-ed.
(?!) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?!

-- | Get narrower record along with projection path.
(!) :: PersistableWidth a => Record c a -> Pi a b -> Record c b
infixl 8 !

-- | Aggregation function SOME.
some' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function ANY.
any' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function EVERY.
every :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function MIN.
min' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MIN.
minMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function MAX.
max' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MAX.
maxMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function AVG.
avg :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe b)

-- | Aggregation function AVG.
avgMaybe :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe b)

-- | Aggregation function SUM.
sum' :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function SUM.
sumMaybe :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function COUNT.
count :: (Integral b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac b

-- | Unsafely make aggregation uni-operator from SQL keyword.
unsafeAggregateOp :: (AggregatedContext ac, SqlContext ac) => Keyword -> Record Flat a -> Record ac b

-- | Binary operator the same as <a>projectZip</a>.
(><) :: ProductIsoApplicative p => p a -> p b -> p (a, b)
infixl 1 ><

-- | Zipping projections.
projectZip :: ProductIsoApplicative p => p a -> p b -> p (a, b)

-- | Provide scoped placeholder and return its parameter object. Monadic
--   version.
placeholder :: (PersistableWidth t, SqlContext c, Monad m) => (Record c t -> m a) -> m (PlaceHolders t, a)

-- | Provide scoped placeholder and return its parameter object.
placeholder' :: (PersistableWidth t, SqlContext c) => (Record c t -> a) -> (PlaceHolders t, a)

-- | Provide scoped placeholder from width and return its parameter object.
pwPlaceholder :: SqlContext c => PersistableRecordWidth a -> (Record c a -> b) -> (PlaceHolders a, b)

-- | No placeholder semantics. Same as <a>unitPlaceHolder</a>
unitPH :: PlaceHolders ()

-- | No placeholder semantics
unitPlaceHolder :: PlaceHolders ()

-- | Unsafely get placeholder parameter
unsafePlaceHolders :: PlaceHolders p

-- | Unsafely add placeholder parameter to queries.
unsafeAddPlaceHolders :: Functor f => f a -> f (PlaceHolders p, a)

-- | <i>CUME_DIST()</i> term.
cumeDist :: Record OverWindow Double

-- | <i>PERCENT_RANK()</i> term.
percentRank :: Record OverWindow Double

-- | <i>ROW_NUMBER()</i> term.
rowNumber :: Integral a => Record OverWindow a

-- | <i>DENSE_RANK()</i> term.
denseRank :: Integral a => Record OverWindow a

-- | <i>RANK()</i> term.
rank :: Integral a => Record OverWindow a

-- | Operator from maybe type using record extended <tt>isNull</tt>.
fromMaybe :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c r -> Record c (Maybe r) -> Record c r

-- | Operator corresponding SQL <i>NOT (... IS NULL)</i> , and extended
--   against record type.
isJust :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Operator corresponding SQL <i>IS NULL</i> , and extended against
--   record types.
isNothing :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Binary operator corresponding SQL <i>IN</i> .
in' :: OperatorContext c => Record c t -> RecordList (Record c) t -> Record c (Maybe Bool)
infix 4 `in'`

-- | Null default version of <a>case'</a>.
caseMaybe :: (OperatorContext c, PersistableWidth b) => Record c a -> [(Record c a, Record c (Maybe b))] -> Record c (Maybe b)

-- | Uncurry version of <a>case'</a>, and you can write like ...
--   <a>casesOrElse</a>` <a>clause</a>.
casesOrElse' :: OperatorContext c => (Record c a, [(Record c a, Record c b)]) -> Record c b -> Record c b

-- | Simple case operator correnponding SQL simple <i>CASE</i>. Like,
--   <i>CASE x WHEN v THEN a WHEN w THEN b ... ELSE c END</i>
case' :: OperatorContext c => Record c a -> [(Record c a, Record c b)] -> Record c b -> Record c b

-- | Null default version of <a>caseSearch</a>.
caseSearchMaybe :: (OperatorContext c, PersistableWidth a) => [(Predicate c, Record c (Maybe a))] -> Record c (Maybe a)

-- | Same as <a>caseSearch</a>, but you can write like <a>list</a>
--   <a>casesOrElse</a> <a>clause</a>.
casesOrElse :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Search case operator correnponding SQL search <i>CASE</i>. Like,
--   <i>CASE WHEN p0 THEN a WHEN p1 THEN b ... ELSE c END</i>
caseSearch :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Unsafely show number into string-like type in records.
showNumMaybe :: (SqlContext c, Num a, IsString b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number fromIntegral uni-operator.
fromIntegralMaybe :: (SqlContext c, Integral a, Num b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negateMaybe :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a)

-- | Number operator corresponding SQL <i>*</i> .
(?*?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?*?

-- | Number operator corresponding SQL /// .
(?/?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?/?

-- | Number operator corresponding SQL <i>-</i> .
(?-?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?-?

-- | Number operator corresponding SQL <i>+</i> .
(?+?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?+?

-- | Unsafely show number into string-like type in records.
showNum :: (SqlContext c, Num a, IsString b) => Record c a -> Record c b

-- | Number fromIntegral uni-operator.
fromIntegral' :: (SqlContext c, Integral a, Num b) => Record c a -> Record c b

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negate' :: (OperatorContext c, Num a) => Record c a -> Record c a

-- | Number operator corresponding SQL <i>*</i> .
(.*.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 .*.

-- | Number operator corresponding SQL /// .
(./.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 ./.

-- | Number operator corresponding SQL <i>-</i> .
(.-.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .-.

-- | Number operator corresponding SQL <i>+</i> .
(.+.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .+.

-- | String-compare operator corresponding SQL <i>LIKE</i> . Maybe type
--   version.
likeMaybe :: (OperatorContext c, IsString a, LiteralSQL a) => Record c (Maybe a) -> a -> Record c (Maybe Bool)
infix 4 `likeMaybe`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like :: (OperatorContext c, IsString a, LiteralSQL a) => Record c a -> a -> Record c (Maybe Bool)
infix 4 `like`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
likeMaybe' :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe Bool)
infix 4 `likeMaybe'`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like' :: (OperatorContext c, IsString a) => Record c a -> Record c a -> Record c (Maybe Bool)
infix 4 `like'`

-- | Concatinate operator corresponding SQL <i>||</i> . Maybe type version.
(?||?) :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 5 ?||?

-- | Concatinate operator corresponding SQL <i>||</i> .
(.||.) :: OperatorContext c => Record c a -> Record c a -> Record c a
infixl 5 .||.

-- | Logical operator corresponding SQL <i>EXISTS</i> .
exists :: OperatorContext c => RecordList (Record Exists) r -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>NOT</i> .
not' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>OR</i> .
or' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 2 `or'`

-- | Logical operator corresponding SQL <i>AND</i> .
and' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 3 `and'`

-- | Compare operator corresponding SQL <i>&lt;&gt;</i> .
(.<>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<>.

-- | Compare operator corresponding SQL <i>&gt;=</i> .
(.>=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>=.

-- | Compare operator corresponding SQL <i>&gt;</i> .
(.>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>.

-- | Compare operator corresponding SQL <i>&lt;=</i> .
(.<=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<=.

-- | Compare operator corresponding SQL <i>&lt;</i> .
(.<.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<.

-- | Compare operator corresponding SQL <i>=</i> .
(.=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .=.

-- | Unsafely make binary operator for records from string binary operator.
unsafeBinOp :: SqlContext k => SqlBinOp -> Record k a -> Record k b -> Record k c

-- | Unsafely make unary operator for records from SQL keyword.
unsafeUniOp :: SqlContext c2 => (Keyword -> Keyword) -> Record c1 a -> Record c2 b

-- | Unsafely generate SQL expression string from record object. String
--   interface of <a>unsafeShowSql'</a>.
unsafeShowSql :: Record c a -> String

-- | Unsafely generate SQL expression term from record object.
unsafeShowSql' :: Record c a -> StringSQL

-- | RecordList with polymorphic type of SQL set value from Haskell list.
values :: (LiteralSQL t, OperatorContext c) => [t] -> RecordList (Record c) t

-- | Record with polymorphic type of SQL false value.
valueFalse :: OperatorContext c => Record c (Maybe Bool)

-- | Record with polymorphic type of SQL true value.
valueTrue :: OperatorContext c => Record c (Maybe Bool)

-- | Generate record with polymorphic type of SQL constant values from
--   Haskell value.
value :: (LiteralSQL t, OperatorContext c) => t -> Record c t

-- | Record with polymorphic phantom type of SQL null value. Semantics of
--   comparing is unsafe.
nothing :: (OperatorContext c, SqlContext c, PersistableWidth a) => Record c (Maybe a)

-- | Unsafely Project single SQL string. String interface of
--   <tt>unsafeProjectSql''</tt>.
unsafeProjectSql :: SqlContext c => String -> Record c t

-- | Unsafely Project single SQL term.
unsafeProjectSql' :: SqlContext c => StringSQL -> Record c t

-- | Binary operator type for SQL String.
type SqlBinOp = Keyword -> Keyword -> Keyword

-- | Interface to control <a>Maybe</a> of phantom type in records.
class ProjectableMaybe (p :: Type -> Type)

-- | Cast record phantom type into <a>Maybe</a>.
just :: ProjectableMaybe p => p a -> p (Maybe a)

-- | Compose nested <a>Maybe</a> phantom type on record.
flattenMaybe :: ProjectableMaybe p => p (Maybe (Maybe a)) -> p (Maybe a)

-- | Interface to compose phantom <a>Maybe</a> nested type.
class ProjectableFlattenMaybe a b
flatten :: (ProjectableFlattenMaybe a b, ProjectableMaybe p) => p a -> p b

-- | Projection path for snd of tuple.
snd' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) b

-- | Projection path for fst of tuple.
fst' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) a
tuplePi7_6' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a7
tuplePi7_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a6
tuplePi7_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a5
tuplePi7_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a4
tuplePi7_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a3
tuplePi7_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a2
tuplePi7_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a1
tuplePi6_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a6
tuplePi6_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a5
tuplePi6_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a4
tuplePi6_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a3
tuplePi6_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a2
tuplePi6_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a1
tuplePi5_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a5
tuplePi5_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a4
tuplePi5_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a3
tuplePi5_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a2
tuplePi5_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a1
tuplePi4_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a4
tuplePi4_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a3
tuplePi4_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a2
tuplePi4_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a1
tuplePi3_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a3
tuplePi3_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a2
tuplePi3_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a1
tuplePi2_1' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a2
tuplePi2_0' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a1

-- | Generate update SQL specified by single key.
updateOtherThanKeySQL :: Table r -> Pi r p -> String

-- | Type for query suffix words
type QuerySuffix = [Keyword]

-- | Make projected record list from <a>Record</a> list.
list :: [p t] -> RecordList p t

-- | Projected record list type for row list.
data RecordList (p :: Type -> Type) t

-- | Phantom typed table type
data Table r

-- | Inference rule of <a>Table</a> existence.
class PersistableWidth r => TableDerivable r
derivedTable :: TableDerivable r => Table r

-- | Dump internal structure tree.
dump :: Relation p r -> String

-- | SQL string from <a>Relation</a>.
sqlFromRelation :: Relation p r -> StringSQL

-- | Generate SQL string from <a>Relation</a> with configuration.
sqlFromRelationWith :: Relation p r -> Config -> StringSQL

-- | Simplify placeholder type applying right identity element.
leftPh :: Relation (p, ()) r -> Relation p r

-- | Simplify placeholder type applying left identity element.
rightPh :: Relation ((), p) r -> Relation p r

-- | <a>PersistableRecordWidth</a> of <a>Relation</a> type.
relationWidth :: Relation p r -> PersistableRecordWidth r

-- | Sub-query Qualify monad from relation.
untypeRelation :: Relation p r -> ConfigureQuery SubQuery

-- | Unsafely type qualified subquery into record typed relation type.
unsafeTypeRelation :: ConfigureQuery SubQuery -> Relation p r

-- | Read configuration.
askConfig :: ConfigureQuery Config

-- | Get qualifyed table form query.
qualifyQuery :: a -> ConfigureQuery (Qualified a)

-- | Run <a>ConfigureQuery</a> monad with initial state to get only result.
configureQuery :: ConfigureQuery q -> Config -> q

-- | Thin monad type for untyped structure.
type ConfigureQuery = Qualify QueryConfig Identity

-- | Relation type with place-holder parameter <tt>p</tt> and query result
--   type <tt>r</tt>.
data Relation p r

-- | Interface to project SQL terms unsafely.
class SqlContext c

-- | Unsafely project from SQL expression terms.
unsafeProjectSqlTerms :: SqlContext c => [StringSQL] -> Record c t

-- | Placeholder parameter type which has real parameter type arguemnt
--   <tt>p</tt>.
data PlaceHolders p

-- | SQL string for nested-qeury.
unitSQL :: SubQuery -> String

-- | Width of <a>Qualified</a> <tt>SubQUery</tt>.
queryWidth :: Qualified SubQuery -> Int

-- | Order direction. Ascendant or Descendant.
data Order
Asc :: Order
Desc :: Order

-- | Order of null.
data Nulls
NullsFirst :: Nulls
NullsLast :: Nulls

-- | Typeful aggregate element.
data AggregateKey a

-- | Sub-query type
data SubQuery

-- | Phantom typed record. Projected into Haskell record type <tt>t</tt>.
data Record c t

-- | Type for predicate to restrict of query result.
type Predicate c = Record c Maybe Bool

-- | Type for projection function.
type PI c a b = Record c a -> Record c b

-- | Constraint which represents scalar degree.
class PersistableWidth ct => ScalarDegree ct

-- | Deprecated.
showConstantTermsSQL :: ShowConstantTermsSQL a => a -> [StringSQL]
showConstantTermsSQL' :: ShowConstantTermsSQL a => a -> DList StringSQL

-- | Convert from haskell record to SQL literal row-value.
showLiteral :: LiteralSQL a => a -> [StringSQL]

-- | <a>LiteralSQL</a> <tt>a</tt> is implicit rule to derive function to
--   convert from haskell record type <tt>a</tt> into SQL literal
--   row-value.
--   
--   Generic programming
--   (<a>https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#generic-programming</a>)
--   with default signature is available for <a>LiteralSQL</a> class, so
--   you can make instance like below:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   import GHC.Generics (Generic)
--   --
--   data Foo = Foo { ... } deriving Generic
--   instance LiteralSQL Foo
--   </pre>
class LiteralSQL a
showLiteral' :: LiteralSQL a => a -> DList StringSQL

-- | Deprecated.
type ShowConstantTermsSQL = LiteralSQL

-- | Inferred <a>Unique</a> constraint <a>Key</a>. Record type <tt>r</tt>
--   has unique key which type is <tt>ct</tt> derived from primay key.
derivedUniqueKey :: HasConstraintKey Primary r ct => Key Unique r ct

-- | Derive <a>Unique</a> constraint <a>Key</a> from <a>Primary</a>
--   constraint <a>Key</a>
uniqueKey :: PersistableWidth ct => Key Primary r ct -> Key Unique r ct

-- | Get projection path proof object from constraint <a>Key</a>.
projectionKey :: Key c r ct -> Pi r ct

-- | Get table constraint <a>KeyConstraint</a> proof object from constraint
--   <a>Key</a>.
tableConstraint :: Key c r ct -> KeyConstraint c r

-- | Constraint Key proof object. Constraint type <tt>c</tt>, record type
--   <tt>r</tt> and columns type <tt>ct</tt>.
data Key c r ct

-- | Constraint <a>Key</a> inference interface.
class PersistableWidth ct => HasConstraintKey c r ct

-- | Infer constraint key.
constraintKey :: HasConstraintKey c r ct => Key c r ct

-- | Identity projection path.
id' :: Pi a a

-- | Compose projection path. <a>Maybe</a> phantom functors are
--   <tt>join</tt>-ed like <tt>&gt;=&gt;</tt>.
(<?.?>) :: Pi a (Maybe b) -> Pi b (Maybe c) -> Pi a (Maybe c)
infixl 8 <?.?>

-- | Compose projection path. <a>Maybe</a> phantom functor is
--   <a>map</a>-ed.
(<?.>) :: Pi a (Maybe b) -> Pi b c -> Pi a (Maybe c)
infixl 8 <?.>

-- | Compose projection path.
(<.>) :: Pi a b -> Pi b c -> Pi a c
infixl 8 <.>

-- | Expand indexes from key. Infered width version.
expandIndexes :: PersistableWidth a => Pi a b -> [Int]

-- | Expand indexes from key.
expandIndexes' :: PersistableRecordWidth a -> Pi a b -> [Int]

-- | Projection path from type <tt>r0</tt> into type <tt>r1</tt>. This type
--   also indicate key object which type is <tt>r1</tt> for record type
--   <tt>r0</tt>.
data Pi r0 r1

-- | String wrap type for SQL strings.
type StringSQL = Keyword

-- | Type tag for flat (not-aggregated) query
data Flat

-- | Type tag for aggregated query
data Aggregated

-- | Type tag for exists predicate
data Exists

-- | Type tag for window function building
data OverWindow

-- | Type tag for normal aggregatings set
data Set

-- | Type tag for aggregatings GROUPING SETS
data SetList

-- | Type tag for aggregatings power set
data Power

-- | Default configuration of <a>Config</a>. To change some behaviour of
--   relational-query, use record update syntax:
--   
--   <pre>
--   defaultConfig
--     { productUnitSupport            =  <a>PUSupported</a>
--     , chunksInsertSize              =  256
--     , schemaNameMode                =  <a>SchemaQualified</a>
--     , normalizedTableName           =  True
--     , addQueryTableAliasAS          =  False
--     , addModifyTableAliasAS         =  False
--     , enableWarning                 =  True
--     , verboseAsCompilerWarning      =  False
--     , disableOverloadedProjection   =  False
--     , disableSpecializedProjection  =  False
--     , identifierQuotation           =  <a>NoQuotation</a>
--     , nameConfig                    =
--        defaultNameConfig
--        { recordConfig     =  <a>defaultNameConfig</a>
--        , relationVarName  =  \schema table -&gt; <a>varCamelcaseName</a> $ table ++ "_" ++ scheme
--        -- ^ append the table name after the schema name. e.g. "schemaTable"
--        }
--     }
--   </pre>
defaultConfig :: Config

-- | Default implementation of <a>NameConfig</a> type.
defaultNameConfig :: NameConfig

-- | <a>NameConfig</a> type to customize names of expanded templates.
data NameConfig

-- | Unit of product is supported or not.
data ProductUnitSupport
PUSupported :: ProductUnitSupport
PUNotSupported :: ProductUnitSupport

-- | Schema name qualify mode in SQL string.
data SchemaNameMode

-- | Schema qualified table name in SQL string
SchemaQualified :: SchemaNameMode

-- | Not qualified table name in SQL string
SchemaNotQualified :: SchemaNameMode

-- | Configuration for quotation of identifiers of SQL.
data IdentifierQuotation
NoQuotation :: IdentifierQuotation
Quotation :: Char -> IdentifierQuotation

-- | Configuration type.
data Config
data Primary
data NotNull
data Unique

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery :: Relation p r -> [Keyword] -> Query p r

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object.
insertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object with no(unit) placeholder.
insertValueNoPH :: TableDerivable r => Register r () -> Insert ()

-- | Make <a>InsertQuery</a> from derived table, <a>Pi</a> and
--   <a>Relation</a>.
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation.
update :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation
--   with no(unit) placeholder.
updateNoPH :: TableDerivable r => (Record Flat r -> Assign r ()) -> Update ()

-- | Make <a>Delete</a> from derived table and <a>Restrict</a> computation.
delete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation with no(unit) placeholder.
deleteNoPH :: TableDerivable r => (Record Flat r -> Restrict ()) -> Delete ()

module Database.Relational.Schema.SQLServer.Types
data Types
Types :: !String -> !Int32 -> !Int32 -> Types
[name] :: Types -> !String
[userTypeId] :: Types -> !Int32
[schemaId] :: Types -> !Int32
schemaId' :: Pi Types Int32
userTypeId' :: Pi Types Int32
name' :: Pi Types String
insertQueryTypes :: forall p_a13Dq. Relation p_a13Dq Types -> InsertQuery p_a13Dq
insertTypes :: Insert Types
types :: Relation () Types
tableOfTypes :: Table Types
columnOffsetsTypes :: Array Int Int
instance GHC.Generics.Generic Database.Relational.Schema.SQLServer.Types.Types
instance GHC.Show.Show Database.Relational.Schema.SQLServer.Types.Types
instance Database.Record.Persistable.PersistableWidth Database.Relational.Schema.SQLServer.Types.Types
instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Base.String -> GHC.Int.Int32 -> GHC.Int.Int32 -> Database.Relational.Schema.SQLServer.Types.Types)
instance Database.Relational.ProjectableClass.LiteralSQL Database.Relational.Schema.SQLServer.Types.Types
instance Database.Relational.Table.TableDerivable Database.Relational.Schema.SQLServer.Types.Types
instance Database.Relational.OverloadedProjection.HasProjection "name" Database.Relational.Schema.SQLServer.Types.Types GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "userTypeId" Database.Relational.Schema.SQLServer.Types.Types GHC.Int.Int32
instance Database.Relational.OverloadedProjection.HasProjection "schemaId" Database.Relational.Schema.SQLServer.Types.Types GHC.Int.Int32

module Database.Relational.Schema.SQLServer

-- | Configuration parameter against SQLServer.
config :: Config
getType :: Map String TypeQ -> ((Columns, Types), String) -> Maybe (String, TypeQ)
normalizeColumn :: String -> String
notNull :: ((Columns, Types), String) -> Bool
columnTypeQuerySQL :: Query (String, String) ((Columns, Types), String)
primaryKeyQuerySQL :: Query (String, String) (Maybe String)


-- | <i>Deprecated: import Database.Relational.Schema.SQLServer.Columns
--   instead of this module.</i>
module Database.Relational.Schema.SQLServerSyscat.Columns


-- | <i>Deprecated: import config from Database.Relational.Schema.SQLServer
--   instead of this module.</i>
module Database.Relational.Schema.SQLServerSyscat.Config

-- | Configuration parameter against SQLServer.
config :: Config


-- | <i>Deprecated: import Database.Relational.Schema.SQLServer.Types
--   instead of this module.</i>
module Database.Relational.Schema.SQLServerSyscat.Types


-- | This module provides custom APIs with appropriate configuration for
--   SQLite3.
module Database.Custom.SQLite3

-- | <a>UniqueRelation</a> inferred from table.
derivedUniqueRelation :: TableDerivable r => Key Unique r k -> Record c k -> UniqueRelation () c r

-- | Typed <a>KeyUpdate</a> using inferred primary key.
primaryUpdate :: HasConstraintKey Primary r p => Table r -> KeyUpdate p r

-- | Typed <a>KeyUpdate</a> using specified constraint key.
updateByConstraintKey :: Table r -> Key c r p -> KeyUpdate p r

-- | Convert from Haskell type <tt>r</tt> into SQL value <tt>q</tt> list
--   expected by update form like
--   
--   <i>UPDATE <a>table</a> SET c0 = ?, c1 = ?, ..., cn = ? WHERE key0 = ?
--   AND key1 = ? AND key2 = ? ... </i>
--   
--   using derived <tt>RecordToSql</tt> proof object.
updateValuesWithKey :: ToSql q r => Pi r p -> r -> [q]

-- | Deprecated.
primary :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Query restricted with inferred primary key.
primarySelect :: HasConstraintKey Primary a p => Relation () a -> Relation p a

-- | Deprecated.
primary' :: PersistableWidth p => Key Primary a p -> Relation () a -> Relation p a

-- | Deprecated.
unique :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified unique key.
uniqueSelect :: PersistableWidth p => Key Unique a p -> Relation () a -> Relation p a

-- | Query restricted with specified key.
specifiedKey :: PersistableWidth p => Pi a p -> Relation () a -> Relation p a

-- | Update statement for sequence table
updateNumber :: (PersistableWidth s, Integral i, LiteralSQL i) => i -> Sequence s i -> Update ()

-- | Update statement for sequence table
updateNumber' :: (PersistableWidth s, Integral i, LiteralSQL i) => Config -> i -> Sequence s i -> Update ()

-- | Unsafely apply sequence number. Only safe to build corresponding
--   record type.
($$) :: Binding r s i => (i -> r) -> Number r i -> r

-- | Unsafely apply sequence number.
($$!) :: (i -> r) -> Number r i -> r

-- | Get untyped sequence number.
extractNumber :: Number r i -> i

-- | Unsafely specify sequence number.
unsafeSpecifyNumber :: Binding r s i => i -> Number r i

-- | Derive <a>Sequence</a> from corresponding <a>Relation</a>
fromRelation :: Binding r s i => Relation () r -> Sequence s i

-- | Derive binding using primary key.
primaryBinding :: (TableDerivable r, SequenceDerivable s i, HasConstraintKey Primary r i) => SeqBinding r s i

-- | Unsafely specify binding between normal-table and sequence-table.
unsafeSpecifyBinding :: (TableDerivable r, SequenceDerivable s i) => Pi r i -> SeqBinding r s i

-- | Infer <a>Relation</a> of sequence table
seqRelation :: TableDerivable s => Sequence s i -> Relation () s

-- | Unsafely specify sequence table.
unsafeSpecifySequence :: TableDerivable s => (s -> i) -> Pi s i -> Sequence s i

-- | Basic record to express sequence-table. actual sequence-table is a
--   table which has only one column of integer type.
data Sequence s i

-- | <a>Sequence</a> derivation rule
class TableDerivable s => SequenceDerivable s i | s -> i
derivedSequence :: SequenceDerivable s i => Sequence s i

-- | Record to express binding between normal-table and sequence-table.
data SeqBinding r s i

-- | Derivation rule for binding between <a>Table</a> and <a>Sequence</a>
class (TableDerivable r, SequenceDerivable s i) => Binding r s i | r -> s
binding :: Binding r s i => SeqBinding r s i

-- | Sequence number type for record type <tt>r</tt>
data Number r i

-- | Make typed <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
derivedDelete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation.
delete' :: TableDerivable r => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Table</a> and <a>Restrict</a>
--   computation.
typedDelete :: Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make typed <a>Delete</a> from <a>Config</a>, <a>Table</a> and
--   <a>Restrict</a> computation.
typedDelete' :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make untyped delete SQL string from <a>Table</a> and <a>Restrict</a>
--   computation.
deleteSQL :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> String

-- | Table type inferred <a>InsertQuery</a>.
derivedInsertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Table type inferred <a>InsertQuery</a>.
insertQuery' :: TableDerivable r => Config -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a>.
typedInsertQuery :: Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make typed <a>InsertQuery</a> from columns selector <a>Table</a>,
--   <a>Pi</a> and <a>Relation</a> with configuration parameter.
typedInsertQuery' :: Config -> Table r -> Pi r r' -> Relation p r' -> InsertQuery p

-- | Make untyped insert select SQL string from <a>Table</a>, <a>Pi</a> and
--   <a>Relation</a>.
insertQuerySQL :: Config -> Table r -> Pi r r' -> Relation p r' -> String

-- | Make typed <a>Insert</a> list from records list.
insertValueList :: (TableDerivable r, LiteralSQL r') => Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> list from <a>Config</a> and records list.
insertValueList' :: (TableDerivable r, LiteralSQL r') => Config -> Pi r r' -> [r'] -> [Insert ()]

-- | Make typed <a>Insert</a> from <a>defaultConfig</a>, derived table and
--   monadic builded <a>Register</a> object.
derivedInsertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
derivedInsertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, derived table and monadic
--   builded <a>Register</a> object.
insertValue' :: TableDerivable r => Config -> Register r (PlaceHolders p) -> Insert p

-- | Make typed <a>Insert</a> from <a>Table</a> and monadic builded
--   <a>InsertTarget</a> object.
typedInsertValue :: Table r -> InsertTarget p r -> Insert p

-- | Make typed <a>Insert</a> from <a>Config</a>, <a>Table</a> and monadic
--   builded <a>InsertTarget</a> object.
typedInsertValue' :: Config -> Table r -> InsertTarget p r -> Insert p

-- | Table type inferred <a>Insert</a>.
derivedInsert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Table type inferred <a>Insert</a>.
insert :: (PersistableWidth r, TableDerivable r) => Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a>.
typedInsert :: PersistableWidth r => Table r -> Pi r r' -> Insert r'

-- | Make typed <a>Insert</a> from <a>Table</a> and columns selector
--   <a>Pi</a> with configuration parameter.
typedInsert' :: PersistableWidth r => Config -> Table r -> Pi r r' -> Insert r'

-- | Unsafely make typed <a>Insert</a> from single insert and chunked
--   insert SQL.
unsafeTypedInsert' :: String -> String -> Int -> Insert a

-- | Size to use chunked insert
chunkSizeOfInsert :: Insert a -> Int

-- | Statement to use chunked insert
untypeChunkInsert :: Insert a -> String

-- | Deprecated. use <a>updateAllColumn</a>.
derivedUpdateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation without placeholder other than target
--   table columns. Update target is all column.
updateAllColumnNoPH :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict ()) -> Update r

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn :: (PersistableWidth r, TableDerivable r) => (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Deprecated. use <a>updateAllColumn'</a>.
derivedUpdateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Restrict</a> computation. Update target is all column.
updateAllColumn' :: (PersistableWidth r, TableDerivable r) => Config -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>Table</a> and <a>Restrict</a>
--   computation. Update target is all column.
typedUpdateAllColumn :: PersistableWidth r => Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> Update (r, p)

-- | Make typed <a>Update</a> from <a>defaultConfig</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
derivedUpdate' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, derived table and
--   <a>Assign</a> computation.
update' :: TableDerivable r => Config -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> using <a>defaultConfig</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate :: Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make typed <a>Update</a> from <a>Config</a>, <a>Table</a> and
--   <a>Assign</a> computation.
typedUpdate' :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make untyped update SQL string from <a>Table</a> and <a>Assign</a>
--   computation.
updateSQL :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> String

-- | Unsafely make typed <a>Update</a> from SQL string.
unsafeTypedUpdate :: String -> Update p

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
derivedKeyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from derived table and key columns
--   selector <a>Pi</a>.
keyUpdate :: TableDerivable r => Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> object using derived info specified by
--   <a>Relation</a> type.
typedKeyUpdateTable :: TableDerivable r => Relation () r -> Pi r p -> KeyUpdate p r

-- | Make typed <a>KeyUpdate</a> from <a>Table</a> and key columns selector
--   <a>Pi</a>.
typedKeyUpdate :: Table a -> Pi a p -> KeyUpdate p a

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery' :: Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery_ :: Config -> Relation p r -> QuerySuffix -> Query p r

-- | From <a>Relation</a> into untyped SQL query string.
relationalQuerySQL :: Config -> Relation p r -> QuerySuffix -> String

-- | Unsafely make typed <a>Query</a> from SQL string.
unsafeTypedQuery :: String -> Query p a

-- | Query type with place-holder parameter <tt>p</tt> and query result
--   type <tt>a</tt>.
newtype Query p a
Query :: String -> Query p a
[untypeQuery] :: Query p a -> String

-- | Update type with key type <tt>p</tt> and update record type
--   <tt>a</tt>. Columns to update are record columns other than key
--   columns, So place-holder parameter type is the same as record type
--   <tt>a</tt>.
data KeyUpdate p a
KeyUpdate :: Pi a p -> String -> KeyUpdate p a
[updateKey] :: KeyUpdate p a -> Pi a p
[untypeKeyUpdate] :: KeyUpdate p a -> String

-- | Update type with place-holder parameter <tt>p</tt>.
newtype Update p
Update :: String -> Update p
[untypeUpdate] :: Update p -> String

-- | Insert type to insert record type <tt>a</tt>.
data Insert a
Insert :: String -> Maybe (String, Int) -> Insert a
[untypeInsert] :: Insert a -> String
[chunkedInsert] :: Insert a -> Maybe (String, Int)

-- | InsertQuery type.
newtype InsertQuery p
InsertQuery :: String -> InsertQuery p
[untypeInsertQuery] :: InsertQuery p -> String

-- | Delete type with place-holder parameter <tt>p</tt>.
newtype Delete p
Delete :: String -> Delete p
[untypeDelete] :: Delete p -> String

-- | Untype interface for typed no-result type statments with single type
--   parameter which represents place-holder parameter <tt>p</tt>.
class UntypeableNoFetch (s :: Type -> Type)
untypeNoFetch :: UntypeableNoFetch s => s p -> String

-- | Make <a>StringSQL</a> strings of SQL INSERT strings from records list
sqlChunksFromRecordList :: LiteralSQL r' => Config -> Table r -> Pi r r' -> [r'] -> [StringSQL]

-- | Make <a>StringSQL</a> string of SQL INSERT statement from
--   <a>InsertTarget</a>
sqlFromInsertTarget :: Config -> Table r -> InsertTarget p r -> StringSQL

-- | Make <a>StringSQL</a> string of SQL INSERT record chunk statement from
--   <a>InsertTarget</a>
sqlChunkFromInsertTarget :: Config -> Table r -> InsertTarget p r -> (StringSQL, Int)

-- | parametalized <a>Register</a> monad from <a>Pi</a>
piRegister :: PersistableWidth r => Pi r r' -> Register r (PlaceHolders r')

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a> with
--   place-holder parameter <tt>p</tt>.
insertTarget' :: Register r (PlaceHolders p) -> InsertTarget p r

-- | Finalize <a>Register</a> monad and generate <a>InsertTarget</a>.
insertTarget :: Register r () -> InsertTarget () r

-- | SQL SET clause and WHERE clause <a>StringSQL</a> string from
--   <a>Assign</a> computation.
sqlFromUpdateTarget :: Config -> Table r -> (Record Flat r -> Assign r (PlaceHolders p)) -> StringSQL

-- | Deprecated.
updateTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Deprecated.
updateTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict ()) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all. With placefolder type <tt>p</tt>.
liftTargetAllColumn' :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders p)) -> Record Flat r -> Assign r (PlaceHolders (r, p))

-- | Lift <a>Restrict</a> computation to <a>Assign</a> computation. Assign
--   target columns are all.
liftTargetAllColumn :: PersistableWidth r => (Record Flat r -> Restrict (PlaceHolders ())) -> Record Flat r -> Assign r (PlaceHolders r)

-- | Deprecated.
updateTarget' :: (Record Flat r -> Assign r (PlaceHolders p)) -> UpdateTarget p r

-- | Deprecated.
updateTarget :: (Record Flat r -> Assign r ()) -> UpdateTarget () r

-- | SQL WHERE clause <a>StringSQL</a> string from <a>Restrict</a>
--   computation.
sqlWhereFromRestriction :: Config -> Table r -> (Record Flat r -> Restrict (PlaceHolders p)) -> StringSQL

-- | Deprecated.
restriction' :: (Record Flat r -> Restrict (PlaceHolders p)) -> Restriction p r

-- | Deprecated.
restriction :: (Record Flat r -> Restrict ()) -> Restriction () r

-- | Restriction type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type Restriction p r = Record Flat r -> Restrict PlaceHolders p

-- | UpdateTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
type UpdateTarget p r = Record Flat r -> Assign r PlaceHolders p

-- | InsertTarget type with place-holder parameter <tt>p</tt> and projected
--   record type <tt>r</tt>.
data InsertTarget p r

-- | Intersection of two relations with place-holder parameters. Not
--   distinct.
intersectAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersectAll'`

-- | Intersection of two relations with place-holder parameters.
intersect' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 8 `intersect'`

-- | Subtraction of two relations with place-holder parameters. Not
--   distinct.
exceptAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `exceptAll'`

-- | Subtraction of two relations with place-holder parameters.
except' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `except'`

-- | Union of two relations with place-holder parameters. Not distinct.
unionAll' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `unionAll'`

-- | Union of two relations with place-holder parameters.
union' :: Relation p a -> Relation q a -> Relation (p, q) a
infixl 7 `union'`

-- | Intersection of two relations. Not distinct.
intersectAll :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersectAll`

-- | Intersection of two relations.
intersect :: Relation () a -> Relation () a -> Relation () a
infixl 8 `intersect`

-- | Subtraction of two relations. Not distinct.
exceptAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `exceptAll`

-- | Subtraction of two relations.
except :: Relation () a -> Relation () a -> Relation () a
infixl 7 `except`

-- | Union of two relations. Not distinct.
unionAll :: Relation () a -> Relation () a -> Relation () a
infixl 7 `unionAll`

-- | Union of two relations.
union :: Relation () a -> Relation () a -> Relation () a
infixl 7 `union`

-- | Apply restriction for direct join style.
on' :: ([JoinRestriction a b] -> Relation pc (a, b)) -> [JoinRestriction a b] -> Relation pc (a, b)
infixl 8 `on'`

-- | Direct full outer join.
full :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation () (Maybe a, Maybe b)
infixl 8 `full`

-- | Direct right outer join.
right :: Relation () a -> Relation () b -> [JoinRestriction (Maybe a) b] -> Relation () (Maybe a, b)
infixl 8 `right`

-- | Direct left outer join.
left :: Relation () a -> Relation () b -> [JoinRestriction a (Maybe b)] -> Relation () (a, Maybe b)
infixl 8 `left`

-- | Direct inner join.
inner :: Relation () a -> Relation () b -> [JoinRestriction a b] -> Relation () (a, b)
infixl 8 `inner`

-- | Direct full outer join with place-holder parameters.
full' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) (Maybe b)] -> Relation (pa, pb) (Maybe a, Maybe b)
infixl 8 `full'`

-- | Direct right outer join with place-holder parameters.
right' :: Relation pa a -> Relation pb b -> [JoinRestriction (Maybe a) b] -> Relation (pa, pb) (Maybe a, b)
infixl 8 `right'`

-- | Direct left outer join with place-holder parameters.
left' :: Relation pa a -> Relation pb b -> [JoinRestriction a (Maybe b)] -> Relation (pa, pb) (a, Maybe b)
infixl 8 `left'`

-- | Direct inner join with place-holder parameters.
inner' :: Relation pa a -> Relation pb b -> [JoinRestriction a b] -> Relation (pa, pb) (a, b)
infixl 8 `inner'`

-- | Restriction predicate function type for direct style join operator,
--   used on predicates of direct join style as follows.
--   
--   <pre>
--   do xy &lt;- query $
--            relX <a>inner</a> relY <a>on</a>` [ x y -&gt; ... ] -- this lambda form has JoinRestriction type
--      ...
--   </pre>
type JoinRestriction a b = Record Flat a -> Record Flat b -> Predicate Flat

-- | Scalar sub-query.
queryScalar :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation () c r -> m (Record c (Maybe r))

-- | Scalar sub-query with place-holder parameter <tt>p</tt>.
queryScalar' :: (MonadQualify ConfigureQuery m, ScalarDegree r) => UniqueRelation p c r -> m (PlaceHolders p, Record c (Maybe r))

-- | Aggregated <a>UniqueRelation</a>.
aggregatedUnique :: Relation ph r -> Pi r a -> (Record Flat a -> Record Aggregated b) -> UniqueRelation ph Flat b

-- | Finalize <a>QueryUnique</a> monad and generate <a>UniqueRelation</a>.
uniqueRelation' :: QueryUnique (PlaceHolders p, Record c r) -> UniqueRelation p c r

-- | Join unique sub-query with place-holder parameter <tt>p</tt>. Query
--   result is <a>Maybe</a>.
uniqueQueryMaybe' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c (Maybe r))

-- | Join unique sub-query with place-holder parameter <tt>p</tt>.
uniqueQuery' :: UniqueRelation p c r -> QueryUnique (PlaceHolders p, Record c r)

-- | Discard unique attribute.
unUnique :: UniqueRelation p c r -> Relation p r

-- | Unsafely specify unique relation.
unsafeUnique :: Relation p r -> UniqueRelation p c r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a>.
aggregateRelation :: QueryAggregate (Record Aggregated r) -> Relation () r

-- | Finalize <a>QueryAggregate</a> monad and geneate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
aggregateRelation' :: AggregatedQuery p r -> Relation p r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a>.
relation :: QuerySimple (Record Flat r) -> Relation () r

-- | Finalize <a>QuerySimple</a> monad and generate <a>Relation</a> with
--   place-holder parameter <tt>p</tt>.
relation' :: SimpleQuery p r -> Relation p r

-- | List sub-query, for <i>IN</i> and <i>EXIST</i>.
queryList :: MonadQualify ConfigureQuery m => Relation () r -> m (RecordList (Record c) r)

-- | List sub-query, for <i>IN</i> and <i>EXIST</i> with place-holder
--   parameter <tt>p</tt>.
queryList' :: MonadQualify ConfigureQuery m => Relation p r -> m (PlaceHolders p, RecordList (Record c) r)

-- | Join sub-query. Query result is <a>Maybe</a>. The combinations of
--   <a>query</a> and <a>queryMaybe</a> express inner joins, left outer
--   joins, right outer joins, and full outer joins. Here is an example of
--   a right outer join:
--   
--   <pre>
--   outerJoin = relation $ do
--     e &lt;- queryMaybe employee
--     d &lt;- query department
--     on $ e ?! E.deptId' .=. just (d ! D.deptId')
--     return $ (,) |$| e |*| d
--   </pre>
queryMaybe :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat (Maybe r))

-- | Join sub-query. Query result is not <a>Maybe</a>.
query :: (MonadQualify ConfigureQuery m, MonadQuery m) => Relation () r -> m (Record Flat r)

-- | Interface to derive <a>Table</a> type object.
tableOf :: TableDerivable r => Relation () r -> Table r

-- | Inferred <a>Relation</a>.
derivedRelation :: TableDerivable r => Relation () r

-- | Simple <a>Relation</a> from <a>Table</a>.
table :: Table r -> Relation () r

-- | Unique relation type to compose scalar queries.
data UniqueRelation p c r

-- | Operator to make record of window function result using built
--   <a>Window</a> monad.
over :: SqlContext c => Record OverWindow a -> Window c () -> Record c a
infix 8 `over`

-- | Aggregated query monad type.
type QueryAggregate = Orderings Aggregated Restrictings Aggregated AggregatingSetT QueryCore

-- | Aggregated query type. <a>AggregatedQuery</a> p r ==
--   <a>QueryAggregate</a> (<a>PlaceHolders</a> p, <a>Record</a>
--   <a>Aggregated</a> r).
type AggregatedQuery p r = OrderedQuery Aggregated Restrictings Aggregated AggregatingSetT QueryCore p r

-- | Partition monad type for partition-by clause.
type Window c = Orderings c PartitioningSet c

-- | Finalize grouping set list.
groupingSets :: AggregatingSetList a -> AggregateKey a

-- | Finalize grouping power set as cube power set.
cube :: AggregatingPowerSet a -> AggregateKey a

-- | Finalize grouping power set as rollup power set.
rollup :: AggregatingPowerSet a -> AggregateKey a

-- | Specify key of rollup and cube power set.
bkey :: Record Flat r -> AggregatingPowerSet (Record Aggregated (Maybe r))

-- | Finalize and specify single grouping set.
set :: AggregatingSet a -> AggregatingSetList a

-- | Specify key of single grouping set.
key' :: AggregateKey a -> AggregatingSet a

-- | Specify key of single grouping set from Record.
key :: Record Flat r -> AggregatingSet (Record Aggregated (Maybe r))

-- | Target update monad type used from update statement and merge
--   statement.
type Assign r = Assignings r Restrict

-- | Target register monad type used from insert statement.
type Register r = Assignings r ConfigureQuery

-- | Add and assginment.
(<-#) :: forall (m :: Type -> Type) r v. Monad m => AssignTarget r v -> Record Flat v -> Assignings r m ()
infix 4 <-#

-- | Add an assignment.
assignTo :: forall (m :: Type -> Type) v r. Monad m => Record Flat v -> AssignTarget r v -> Assignings r m ()

-- | Simple (not-aggregated) query monad type.
type QuerySimple = Orderings Flat QueryCore

-- | Simple (not-aggregated) query type. <tt>SimpleQuery'</tt> p r ==
--   <a>QuerySimple</a> (<a>PlaceHolders</a> p, <a>Record</a> r).
type SimpleQuery p r = OrderedQuery Flat QueryCore p r

-- | Unique query monad type.
data QueryUnique a

-- | Extract <a>QueryCore</a> computation.
extractCore :: QueryCore a -> ConfigureQuery (((a, [Predicate Flat]), JoinProduct), Duplication)

-- | Core query monad type used from flat(not-aggregated) query and
--   aggregated query.
type QueryCore = Restrictings Flat QueryJoin ConfigureQuery

-- | OrderedQuery monad type with placeholder type <tt>p</tt>. Record must
--   be the same as <a>Orderings</a> context type parameter <tt>c</tt>.
type OrderedQuery c (m :: Type -> Type) p r = Orderings c m (PlaceHolders p, Record c r)

-- | Add descendant ordering term.
desc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ascendant ordering term.
asc :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Orderings c m ()

-- | Add ordering terms.
orderBy :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Orderings c m ()

-- | Add ordering terms with null ordering.
orderBy' :: forall (m :: Type -> Type) c t. Monad m => Record c t -> Order -> Nulls -> Orderings c m ()

-- | Type to accumulate ordering context. Type <tt>c</tt> is ordering term
--   record context type.
data Orderings c (m :: Type -> Type) a

-- | Restrict only monad type used from update statement and delete
--   statement.
type Restrict = Restrictings Flat ConfigureQuery

-- | Add restriction to this aggregated query. Aggregated Record type
--   version.
having :: MonadRestrict Aggregated m => Predicate Aggregated -> m ()

-- | Add restriction to this not aggregated query.
wheres :: MonadRestrict Flat m => Predicate Flat -> m ()

-- | Add restriction to last join. Record type version.
on :: MonadQuery m => Predicate Flat -> m ()

-- | Specify DISTINCT attribute to query context.
distinct :: MonadQuery m => m ()

-- | Specify ALL attribute to query context.
all' :: MonadQuery m => m ()

-- | Restrict context interface
class (Functor m, Monad m) => MonadRestrict c (m :: Type -> Type)

-- | Add restriction to this context.
restrict :: MonadRestrict c m => Predicate c -> m ()

-- | Query building interface.
class (Functor m, Monad m, MonadQualify ConfigureQuery m) => MonadQuery (m :: Type -> Type)

-- | Join sub-query with place-holder parameter <tt>p</tt>. query result is
--   not <a>Maybe</a>.
query' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat r)

-- | Join sub-query with place-holder parameter <tt>p</tt>. Query result is
--   <a>Maybe</a>.
queryMaybe' :: MonadQuery m => Relation p r -> m (PlaceHolders p, Record Flat (Maybe r))

-- | Lift interface from base qualify monad.
class (Functor q, Monad q, Functor m, Monad m) => MonadQualify (q :: Type -> Type) (m :: Type -> Type)

-- | Aggregated query building interface extends <a>MonadQuery</a>.
class MonadQuery m => MonadAggregate (m :: Type -> Type)

-- | Add <i>GROUP BY</i> term into context and get aggregated record.
groupBy :: MonadAggregate m => Record Flat r -> m (Record Aggregated r)
groupBy' :: MonadAggregate m => AggregateKey (Record Aggregated r) -> m (Record Aggregated r)

-- | Window specification building interface.
class Monad m => MonadPartition c (m :: Type -> Type)

-- | Add <i>PARTITION BY</i> term into context.
partitionBy :: MonadPartition c m => Record c r -> m ()

-- | Same as <a>(?!?)</a>. Use this operator like '(?? #foo) mayX'.
(??) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ??

-- | Same as <a>(?!)</a>. Use this operator like '(? #foo) mayX'.
(?) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
(!??) :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c
infixl 8 !??

-- | Get narrower record with flatten leaf phantom Maybe types along with
--   projection path.
flattenPiMaybe :: (PersistableWidth a, ProjectableFlattenMaybe (Maybe b) c) => Record cont (Maybe a) -> Pi a b -> Record cont c

-- | Get narrower record along with projection path and project into result
--   record type. Source record <a>Maybe</a> phantom functor and projection
--   path leaf <a>Maybe</a> functor are <tt>join</tt>-ed.
(?!?) :: PersistableWidth a => Record c (Maybe a) -> Pi a (Maybe b) -> Record c (Maybe b)
infixl 8 ?!?

-- | Get narrower record along with projection path <a>Maybe</a> phantom
--   functor is <a>map</a>-ed.
(?!) :: PersistableWidth a => Record c (Maybe a) -> Pi a b -> Record c (Maybe b)
infixl 8 ?!

-- | Get narrower record along with projection path.
(!) :: PersistableWidth a => Record c a -> Pi a b -> Record c b
infixl 8 !

-- | Aggregation function SOME.
some' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function ANY.
any' :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function EVERY.
every :: (AggregatedContext ac, SqlContext ac) => Predicate Flat -> Record ac (Maybe Bool)

-- | Aggregation function MIN.
min' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MIN.
minMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function MAX.
max' :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function MAX.
maxMaybe :: (Ord a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function AVG.
avg :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe b)

-- | Aggregation function AVG.
avgMaybe :: (Num a, Fractional b, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe b)

-- | Aggregation function SUM.
sum' :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac (Maybe a)

-- | Aggregation function SUM.
sumMaybe :: (Num a, AggregatedContext ac, SqlContext ac) => Record Flat (Maybe a) -> Record ac (Maybe a)

-- | Aggregation function COUNT.
count :: (Integral b, AggregatedContext ac, SqlContext ac) => Record Flat a -> Record ac b

-- | Unsafely make aggregation uni-operator from SQL keyword.
unsafeAggregateOp :: (AggregatedContext ac, SqlContext ac) => Keyword -> Record Flat a -> Record ac b

-- | Binary operator the same as <a>projectZip</a>.
(><) :: ProductIsoApplicative p => p a -> p b -> p (a, b)
infixl 1 ><

-- | Zipping projections.
projectZip :: ProductIsoApplicative p => p a -> p b -> p (a, b)

-- | Provide scoped placeholder and return its parameter object. Monadic
--   version.
placeholder :: (PersistableWidth t, SqlContext c, Monad m) => (Record c t -> m a) -> m (PlaceHolders t, a)

-- | Provide scoped placeholder and return its parameter object.
placeholder' :: (PersistableWidth t, SqlContext c) => (Record c t -> a) -> (PlaceHolders t, a)

-- | Provide scoped placeholder from width and return its parameter object.
pwPlaceholder :: SqlContext c => PersistableRecordWidth a -> (Record c a -> b) -> (PlaceHolders a, b)

-- | No placeholder semantics. Same as <a>unitPlaceHolder</a>
unitPH :: PlaceHolders ()

-- | No placeholder semantics
unitPlaceHolder :: PlaceHolders ()

-- | Unsafely get placeholder parameter
unsafePlaceHolders :: PlaceHolders p

-- | Unsafely add placeholder parameter to queries.
unsafeAddPlaceHolders :: Functor f => f a -> f (PlaceHolders p, a)

-- | <i>CUME_DIST()</i> term.
cumeDist :: Record OverWindow Double

-- | <i>PERCENT_RANK()</i> term.
percentRank :: Record OverWindow Double

-- | <i>ROW_NUMBER()</i> term.
rowNumber :: Integral a => Record OverWindow a

-- | <i>DENSE_RANK()</i> term.
denseRank :: Integral a => Record OverWindow a

-- | <i>RANK()</i> term.
rank :: Integral a => Record OverWindow a

-- | Operator from maybe type using record extended <tt>isNull</tt>.
fromMaybe :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c r -> Record c (Maybe r) -> Record c r

-- | Operator corresponding SQL <i>NOT (... IS NULL)</i> , and extended
--   against record type.
isJust :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Operator corresponding SQL <i>IS NULL</i> , and extended against
--   record types.
isNothing :: (OperatorContext c, HasColumnConstraint NotNull r) => Record c (Maybe r) -> Predicate c

-- | Binary operator corresponding SQL <i>IN</i> .
in' :: OperatorContext c => Record c t -> RecordList (Record c) t -> Record c (Maybe Bool)
infix 4 `in'`

-- | Null default version of <a>case'</a>.
caseMaybe :: (OperatorContext c, PersistableWidth b) => Record c a -> [(Record c a, Record c (Maybe b))] -> Record c (Maybe b)

-- | Uncurry version of <a>case'</a>, and you can write like ...
--   <a>casesOrElse</a>` <a>clause</a>.
casesOrElse' :: OperatorContext c => (Record c a, [(Record c a, Record c b)]) -> Record c b -> Record c b

-- | Simple case operator correnponding SQL simple <i>CASE</i>. Like,
--   <i>CASE x WHEN v THEN a WHEN w THEN b ... ELSE c END</i>
case' :: OperatorContext c => Record c a -> [(Record c a, Record c b)] -> Record c b -> Record c b

-- | Null default version of <a>caseSearch</a>.
caseSearchMaybe :: (OperatorContext c, PersistableWidth a) => [(Predicate c, Record c (Maybe a))] -> Record c (Maybe a)

-- | Same as <a>caseSearch</a>, but you can write like <a>list</a>
--   <a>casesOrElse</a> <a>clause</a>.
casesOrElse :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Search case operator correnponding SQL search <i>CASE</i>. Like,
--   <i>CASE WHEN p0 THEN a WHEN p1 THEN b ... ELSE c END</i>
caseSearch :: OperatorContext c => [(Predicate c, Record c a)] -> Record c a -> Record c a

-- | Unsafely show number into string-like type in records.
showNumMaybe :: (SqlContext c, Num a, IsString b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number fromIntegral uni-operator.
fromIntegralMaybe :: (SqlContext c, Integral a, Num b) => Record c (Maybe a) -> Record c (Maybe b)

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negateMaybe :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a)

-- | Number operator corresponding SQL <i>*</i> .
(?*?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?*?

-- | Number operator corresponding SQL /// .
(?/?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 7 ?/?

-- | Number operator corresponding SQL <i>-</i> .
(?-?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?-?

-- | Number operator corresponding SQL <i>+</i> .
(?+?) :: (OperatorContext c, Num a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 6 ?+?

-- | Unsafely show number into string-like type in records.
showNum :: (SqlContext c, Num a, IsString b) => Record c a -> Record c b

-- | Number fromIntegral uni-operator.
fromIntegral' :: (SqlContext c, Integral a, Num b) => Record c a -> Record c b

-- | Number negate uni-operator corresponding SQL <i>-</i>.
negate' :: (OperatorContext c, Num a) => Record c a -> Record c a

-- | Number operator corresponding SQL <i>*</i> .
(.*.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 .*.

-- | Number operator corresponding SQL /// .
(./.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 7 ./.

-- | Number operator corresponding SQL <i>-</i> .
(.-.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .-.

-- | Number operator corresponding SQL <i>+</i> .
(.+.) :: (OperatorContext c, Num a) => Record c a -> Record c a -> Record c a
infixl 6 .+.

-- | String-compare operator corresponding SQL <i>LIKE</i> . Maybe type
--   version.
likeMaybe :: (OperatorContext c, IsString a, LiteralSQL a) => Record c (Maybe a) -> a -> Record c (Maybe Bool)
infix 4 `likeMaybe`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like :: (OperatorContext c, IsString a, LiteralSQL a) => Record c a -> a -> Record c (Maybe Bool)
infix 4 `like`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
likeMaybe' :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe Bool)
infix 4 `likeMaybe'`

-- | String-compare operator corresponding SQL <i>LIKE</i> .
like' :: (OperatorContext c, IsString a) => Record c a -> Record c a -> Record c (Maybe Bool)
infix 4 `like'`

-- | Concatinate operator corresponding SQL <i>||</i> . Maybe type version.
(?||?) :: (OperatorContext c, IsString a) => Record c (Maybe a) -> Record c (Maybe a) -> Record c (Maybe a)
infixl 5 ?||?

-- | Concatinate operator corresponding SQL <i>||</i> .
(.||.) :: OperatorContext c => Record c a -> Record c a -> Record c a
infixl 5 .||.

-- | Logical operator corresponding SQL <i>EXISTS</i> .
exists :: OperatorContext c => RecordList (Record Exists) r -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>NOT</i> .
not' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool)

-- | Logical operator corresponding SQL <i>OR</i> .
or' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 2 `or'`

-- | Logical operator corresponding SQL <i>AND</i> .
and' :: OperatorContext c => Record c (Maybe Bool) -> Record c (Maybe Bool) -> Record c (Maybe Bool)
infixr 3 `and'`

-- | Compare operator corresponding SQL <i>&lt;&gt;</i> .
(.<>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<>.

-- | Compare operator corresponding SQL <i>&gt;=</i> .
(.>=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>=.

-- | Compare operator corresponding SQL <i>&gt;</i> .
(.>.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .>.

-- | Compare operator corresponding SQL <i>&lt;=</i> .
(.<=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<=.

-- | Compare operator corresponding SQL <i>&lt;</i> .
(.<.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .<.

-- | Compare operator corresponding SQL <i>=</i> .
(.=.) :: OperatorContext c => Record c ft -> Record c ft -> Record c (Maybe Bool)
infix 4 .=.

-- | Unsafely make binary operator for records from string binary operator.
unsafeBinOp :: SqlContext k => SqlBinOp -> Record k a -> Record k b -> Record k c

-- | Unsafely make unary operator for records from SQL keyword.
unsafeUniOp :: SqlContext c2 => (Keyword -> Keyword) -> Record c1 a -> Record c2 b

-- | Unsafely generate SQL expression string from record object. String
--   interface of <a>unsafeShowSql'</a>.
unsafeShowSql :: Record c a -> String

-- | Unsafely generate SQL expression term from record object.
unsafeShowSql' :: Record c a -> StringSQL

-- | RecordList with polymorphic type of SQL set value from Haskell list.
values :: (LiteralSQL t, OperatorContext c) => [t] -> RecordList (Record c) t

-- | Record with polymorphic type of SQL false value.
valueFalse :: OperatorContext c => Record c (Maybe Bool)

-- | Record with polymorphic type of SQL true value.
valueTrue :: OperatorContext c => Record c (Maybe Bool)

-- | Generate record with polymorphic type of SQL constant values from
--   Haskell value.
value :: (LiteralSQL t, OperatorContext c) => t -> Record c t

-- | Record with polymorphic phantom type of SQL null value. Semantics of
--   comparing is unsafe.
nothing :: (OperatorContext c, SqlContext c, PersistableWidth a) => Record c (Maybe a)

-- | Unsafely Project single SQL string. String interface of
--   <tt>unsafeProjectSql''</tt>.
unsafeProjectSql :: SqlContext c => String -> Record c t

-- | Unsafely Project single SQL term.
unsafeProjectSql' :: SqlContext c => StringSQL -> Record c t

-- | Binary operator type for SQL String.
type SqlBinOp = Keyword -> Keyword -> Keyword

-- | Interface to control <a>Maybe</a> of phantom type in records.
class ProjectableMaybe (p :: Type -> Type)

-- | Cast record phantom type into <a>Maybe</a>.
just :: ProjectableMaybe p => p a -> p (Maybe a)

-- | Compose nested <a>Maybe</a> phantom type on record.
flattenMaybe :: ProjectableMaybe p => p (Maybe (Maybe a)) -> p (Maybe a)

-- | Interface to compose phantom <a>Maybe</a> nested type.
class ProjectableFlattenMaybe a b
flatten :: (ProjectableFlattenMaybe a b, ProjectableMaybe p) => p a -> p b

-- | Projection path for snd of tuple.
snd' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) b

-- | Projection path for fst of tuple.
fst' :: (PersistableWidth a, PersistableWidth b) => Pi (a, b) a
tuplePi7_6' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a7
tuplePi7_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a6
tuplePi7_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a5
tuplePi7_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a4
tuplePi7_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a3
tuplePi7_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a2
tuplePi7_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6, PersistableWidth a7) => Pi (a1, a2, a3, a4, a5, a6, a7) a1
tuplePi6_5' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a6
tuplePi6_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a5
tuplePi6_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a4
tuplePi6_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a3
tuplePi6_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a2
tuplePi6_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5, PersistableWidth a6) => Pi (a1, a2, a3, a4, a5, a6) a1
tuplePi5_4' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a5
tuplePi5_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a4
tuplePi5_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a3
tuplePi5_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a2
tuplePi5_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4, PersistableWidth a5) => Pi (a1, a2, a3, a4, a5) a1
tuplePi4_3' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a4
tuplePi4_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a3
tuplePi4_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a2
tuplePi4_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3, PersistableWidth a4) => Pi (a1, a2, a3, a4) a1
tuplePi3_2' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a3
tuplePi3_1' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a2
tuplePi3_0' :: (PersistableWidth a1, PersistableWidth a2, PersistableWidth a3) => Pi (a1, a2, a3) a1
tuplePi2_1' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a2
tuplePi2_0' :: (PersistableWidth a1, PersistableWidth a2) => Pi (a1, a2) a1

-- | Generate update SQL specified by single key.
updateOtherThanKeySQL :: Table r -> Pi r p -> String

-- | Type for query suffix words
type QuerySuffix = [Keyword]

-- | Make projected record list from <a>Record</a> list.
list :: [p t] -> RecordList p t

-- | Projected record list type for row list.
data RecordList (p :: Type -> Type) t

-- | Phantom typed table type
data Table r

-- | Inference rule of <a>Table</a> existence.
class PersistableWidth r => TableDerivable r
derivedTable :: TableDerivable r => Table r

-- | Dump internal structure tree.
dump :: Relation p r -> String

-- | SQL string from <a>Relation</a>.
sqlFromRelation :: Relation p r -> StringSQL

-- | Generate SQL string from <a>Relation</a> with configuration.
sqlFromRelationWith :: Relation p r -> Config -> StringSQL

-- | Simplify placeholder type applying right identity element.
leftPh :: Relation (p, ()) r -> Relation p r

-- | Simplify placeholder type applying left identity element.
rightPh :: Relation ((), p) r -> Relation p r

-- | <a>PersistableRecordWidth</a> of <a>Relation</a> type.
relationWidth :: Relation p r -> PersistableRecordWidth r

-- | Sub-query Qualify monad from relation.
untypeRelation :: Relation p r -> ConfigureQuery SubQuery

-- | Unsafely type qualified subquery into record typed relation type.
unsafeTypeRelation :: ConfigureQuery SubQuery -> Relation p r

-- | Read configuration.
askConfig :: ConfigureQuery Config

-- | Get qualifyed table form query.
qualifyQuery :: a -> ConfigureQuery (Qualified a)

-- | Run <a>ConfigureQuery</a> monad with initial state to get only result.
configureQuery :: ConfigureQuery q -> Config -> q

-- | Thin monad type for untyped structure.
type ConfigureQuery = Qualify QueryConfig Identity

-- | Relation type with place-holder parameter <tt>p</tt> and query result
--   type <tt>r</tt>.
data Relation p r

-- | Interface to project SQL terms unsafely.
class SqlContext c

-- | Unsafely project from SQL expression terms.
unsafeProjectSqlTerms :: SqlContext c => [StringSQL] -> Record c t

-- | Placeholder parameter type which has real parameter type arguemnt
--   <tt>p</tt>.
data PlaceHolders p

-- | SQL string for nested-qeury.
unitSQL :: SubQuery -> String

-- | Width of <a>Qualified</a> <tt>SubQUery</tt>.
queryWidth :: Qualified SubQuery -> Int

-- | Order direction. Ascendant or Descendant.
data Order
Asc :: Order
Desc :: Order

-- | Order of null.
data Nulls
NullsFirst :: Nulls
NullsLast :: Nulls

-- | Typeful aggregate element.
data AggregateKey a

-- | Sub-query type
data SubQuery

-- | Phantom typed record. Projected into Haskell record type <tt>t</tt>.
data Record c t

-- | Type for predicate to restrict of query result.
type Predicate c = Record c Maybe Bool

-- | Type for projection function.
type PI c a b = Record c a -> Record c b

-- | Constraint which represents scalar degree.
class PersistableWidth ct => ScalarDegree ct

-- | Deprecated.
showConstantTermsSQL :: ShowConstantTermsSQL a => a -> [StringSQL]
showConstantTermsSQL' :: ShowConstantTermsSQL a => a -> DList StringSQL

-- | Convert from haskell record to SQL literal row-value.
showLiteral :: LiteralSQL a => a -> [StringSQL]

-- | <a>LiteralSQL</a> <tt>a</tt> is implicit rule to derive function to
--   convert from haskell record type <tt>a</tt> into SQL literal
--   row-value.
--   
--   Generic programming
--   (<a>https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#generic-programming</a>)
--   with default signature is available for <a>LiteralSQL</a> class, so
--   you can make instance like below:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   import GHC.Generics (Generic)
--   --
--   data Foo = Foo { ... } deriving Generic
--   instance LiteralSQL Foo
--   </pre>
class LiteralSQL a
showLiteral' :: LiteralSQL a => a -> DList StringSQL

-- | Deprecated.
type ShowConstantTermsSQL = LiteralSQL

-- | Inferred <a>Unique</a> constraint <a>Key</a>. Record type <tt>r</tt>
--   has unique key which type is <tt>ct</tt> derived from primay key.
derivedUniqueKey :: HasConstraintKey Primary r ct => Key Unique r ct

-- | Derive <a>Unique</a> constraint <a>Key</a> from <a>Primary</a>
--   constraint <a>Key</a>
uniqueKey :: PersistableWidth ct => Key Primary r ct -> Key Unique r ct

-- | Get projection path proof object from constraint <a>Key</a>.
projectionKey :: Key c r ct -> Pi r ct

-- | Get table constraint <a>KeyConstraint</a> proof object from constraint
--   <a>Key</a>.
tableConstraint :: Key c r ct -> KeyConstraint c r

-- | Constraint Key proof object. Constraint type <tt>c</tt>, record type
--   <tt>r</tt> and columns type <tt>ct</tt>.
data Key c r ct

-- | Constraint <a>Key</a> inference interface.
class PersistableWidth ct => HasConstraintKey c r ct

-- | Infer constraint key.
constraintKey :: HasConstraintKey c r ct => Key c r ct

-- | Identity projection path.
id' :: Pi a a

-- | Compose projection path. <a>Maybe</a> phantom functors are
--   <tt>join</tt>-ed like <tt>&gt;=&gt;</tt>.
(<?.?>) :: Pi a (Maybe b) -> Pi b (Maybe c) -> Pi a (Maybe c)
infixl 8 <?.?>

-- | Compose projection path. <a>Maybe</a> phantom functor is
--   <a>map</a>-ed.
(<?.>) :: Pi a (Maybe b) -> Pi b c -> Pi a (Maybe c)
infixl 8 <?.>

-- | Compose projection path.
(<.>) :: Pi a b -> Pi b c -> Pi a c
infixl 8 <.>

-- | Expand indexes from key. Infered width version.
expandIndexes :: PersistableWidth a => Pi a b -> [Int]

-- | Expand indexes from key.
expandIndexes' :: PersistableRecordWidth a -> Pi a b -> [Int]

-- | Projection path from type <tt>r0</tt> into type <tt>r1</tt>. This type
--   also indicate key object which type is <tt>r1</tt> for record type
--   <tt>r0</tt>.
data Pi r0 r1

-- | String wrap type for SQL strings.
type StringSQL = Keyword

-- | Type tag for flat (not-aggregated) query
data Flat

-- | Type tag for aggregated query
data Aggregated

-- | Type tag for exists predicate
data Exists

-- | Type tag for window function building
data OverWindow

-- | Type tag for normal aggregatings set
data Set

-- | Type tag for aggregatings GROUPING SETS
data SetList

-- | Type tag for aggregatings power set
data Power

-- | Default configuration of <a>Config</a>. To change some behaviour of
--   relational-query, use record update syntax:
--   
--   <pre>
--   defaultConfig
--     { productUnitSupport            =  <a>PUSupported</a>
--     , chunksInsertSize              =  256
--     , schemaNameMode                =  <a>SchemaQualified</a>
--     , normalizedTableName           =  True
--     , addQueryTableAliasAS          =  False
--     , addModifyTableAliasAS         =  False
--     , enableWarning                 =  True
--     , verboseAsCompilerWarning      =  False
--     , disableOverloadedProjection   =  False
--     , disableSpecializedProjection  =  False
--     , identifierQuotation           =  <a>NoQuotation</a>
--     , nameConfig                    =
--        defaultNameConfig
--        { recordConfig     =  <a>defaultNameConfig</a>
--        , relationVarName  =  \schema table -&gt; <a>varCamelcaseName</a> $ table ++ "_" ++ scheme
--        -- ^ append the table name after the schema name. e.g. "schemaTable"
--        }
--     }
--   </pre>
defaultConfig :: Config

-- | Default implementation of <a>NameConfig</a> type.
defaultNameConfig :: NameConfig

-- | <a>NameConfig</a> type to customize names of expanded templates.
data NameConfig

-- | Unit of product is supported or not.
data ProductUnitSupport
PUSupported :: ProductUnitSupport
PUNotSupported :: ProductUnitSupport

-- | Schema name qualify mode in SQL string.
data SchemaNameMode

-- | Schema qualified table name in SQL string
SchemaQualified :: SchemaNameMode

-- | Not qualified table name in SQL string
SchemaNotQualified :: SchemaNameMode

-- | Configuration for quotation of identifiers of SQL.
data IdentifierQuotation
NoQuotation :: IdentifierQuotation
Quotation :: Char -> IdentifierQuotation

-- | Configuration type.
data Config
data Primary
data NotNull
data Unique

-- | From <a>Relation</a> into typed <a>Query</a> with suffix SQL words.
relationalQuery :: Relation p r -> [Keyword] -> Query p r

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object.
insertValue :: TableDerivable r => Register r (PlaceHolders p) -> Insert p

-- | Make <a>Insert</a> from derived table and monadic builded
--   <a>Register</a> object with no(unit) placeholder.
insertValueNoPH :: TableDerivable r => Register r () -> Insert ()

-- | Make <a>InsertQuery</a> from derived table, <a>Pi</a> and
--   <a>Relation</a>.
insertQuery :: TableDerivable r => Pi r r' -> Relation p r' -> InsertQuery p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation.
update :: TableDerivable r => (Record Flat r -> Assign r (PlaceHolders p)) -> Update p

-- | Make <a>Update</a> from derived table and <a>Assign</a> computation
--   with no(unit) placeholder.
updateNoPH :: TableDerivable r => (Record Flat r -> Assign r ()) -> Update ()

-- | Make <a>Delete</a> from derived table and <a>Restrict</a> computation.
delete :: TableDerivable r => (Record Flat r -> Restrict (PlaceHolders p)) -> Delete p

-- | Make <a>Delete</a> from <a>defaultConfig</a>, derived table and
--   <a>Restrict</a> computation with no(unit) placeholder.
deleteNoPH :: TableDerivable r => (Record Flat r -> Restrict ()) -> Delete ()

module Database.Relational.Schema.SQLite3.IndexInfo
data IndexInfo
IndexInfo :: !Int64 -> !Int64 -> !String -> IndexInfo
[seqno] :: IndexInfo -> !Int64
[cid] :: IndexInfo -> !Int64
[name] :: IndexInfo -> !String
name' :: Pi IndexInfo String
cid' :: Pi IndexInfo Int64
seqno' :: Pi IndexInfo Int64
insertQueryIndexInfo :: forall p_a16ZW. Relation p_a16ZW IndexInfo -> InsertQuery p_a16ZW
insertIndexInfo :: Insert IndexInfo
indexInfo :: Relation () IndexInfo
tableOfIndexInfo :: Table IndexInfo
columnOffsetsIndexInfo :: Array Int Int
instance GHC.Generics.Generic Database.Relational.Schema.SQLite3.IndexInfo.IndexInfo
instance GHC.Show.Show Database.Relational.Schema.SQLite3.IndexInfo.IndexInfo
instance Database.Record.Persistable.PersistableWidth Database.Relational.Schema.SQLite3.IndexInfo.IndexInfo
instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Int.Int64 -> GHC.Int.Int64 -> GHC.Base.String -> Database.Relational.Schema.SQLite3.IndexInfo.IndexInfo)
instance Database.Relational.ProjectableClass.LiteralSQL Database.Relational.Schema.SQLite3.IndexInfo.IndexInfo
instance Database.Relational.Table.TableDerivable Database.Relational.Schema.SQLite3.IndexInfo.IndexInfo
instance Database.Relational.OverloadedProjection.HasProjection "seqno" Database.Relational.Schema.SQLite3.IndexInfo.IndexInfo GHC.Int.Int64
instance Database.Relational.OverloadedProjection.HasProjection "cid" Database.Relational.Schema.SQLite3.IndexInfo.IndexInfo GHC.Int.Int64
instance Database.Relational.OverloadedProjection.HasProjection "name" Database.Relational.Schema.SQLite3.IndexInfo.IndexInfo GHC.Base.String

module Database.Relational.Schema.SQLite3.IndexList
data IndexList
IndexList :: !Int64 -> !String -> !Int64 -> IndexList
[seq] :: IndexList -> !Int64
[name] :: IndexList -> !String
[unique] :: IndexList -> !Int64
unique' :: Pi IndexList Int64
name' :: Pi IndexList String
seq' :: Pi IndexList Int64
insertQueryIndexList :: forall p_a17VC. Relation p_a17VC IndexList -> InsertQuery p_a17VC
insertIndexList :: Insert IndexList
indexList :: Relation () IndexList
tableOfIndexList :: Table IndexList
columnOffsetsIndexList :: Array Int Int
instance GHC.Generics.Generic Database.Relational.Schema.SQLite3.IndexList.IndexList
instance GHC.Show.Show Database.Relational.Schema.SQLite3.IndexList.IndexList
instance Database.Record.Persistable.PersistableWidth Database.Relational.Schema.SQLite3.IndexList.IndexList
instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Int.Int64 -> GHC.Base.String -> GHC.Int.Int64 -> Database.Relational.Schema.SQLite3.IndexList.IndexList)
instance Database.Relational.ProjectableClass.LiteralSQL Database.Relational.Schema.SQLite3.IndexList.IndexList
instance Database.Relational.Table.TableDerivable Database.Relational.Schema.SQLite3.IndexList.IndexList
instance Database.Relational.OverloadedProjection.HasProjection "seq" Database.Relational.Schema.SQLite3.IndexList.IndexList GHC.Int.Int64
instance Database.Relational.OverloadedProjection.HasProjection "name" Database.Relational.Schema.SQLite3.IndexList.IndexList GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "unique" Database.Relational.Schema.SQLite3.IndexList.IndexList GHC.Int.Int64

module Database.Relational.Schema.SQLite3.TableInfo
data TableInfo
TableInfo :: !Int64 -> !String -> !String -> !Int16 -> !Maybe String -> !Int16 -> TableInfo
[cid] :: TableInfo -> !Int64
[name] :: TableInfo -> !String
[ctype] :: TableInfo -> !String
[notnull] :: TableInfo -> !Int16
[dfltValue] :: TableInfo -> !Maybe String
[pk] :: TableInfo -> !Int16
pk' :: Pi TableInfo Int16
dfltValue' :: Pi TableInfo (Maybe String)
notnull' :: Pi TableInfo Int16
ctype' :: Pi TableInfo String
name' :: Pi TableInfo String
cid' :: Pi TableInfo Int64
insertQueryTableInfo :: forall p_a18RM. Relation p_a18RM TableInfo -> InsertQuery p_a18RM
insertTableInfo :: Insert TableInfo
tableInfo :: Relation () TableInfo
tableOfTableInfo :: Table TableInfo
columnOffsetsTableInfo :: Array Int Int
instance GHC.Generics.Generic Database.Relational.Schema.SQLite3.TableInfo.TableInfo
instance GHC.Show.Show Database.Relational.Schema.SQLite3.TableInfo.TableInfo
instance Database.Record.Persistable.PersistableWidth Database.Relational.Schema.SQLite3.TableInfo.TableInfo
instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Int.Int64 -> GHC.Base.String -> GHC.Base.String -> GHC.Int.Int16 -> GHC.Maybe.Maybe GHC.Base.String -> GHC.Int.Int16 -> Database.Relational.Schema.SQLite3.TableInfo.TableInfo)
instance Database.Relational.ProjectableClass.LiteralSQL Database.Relational.Schema.SQLite3.TableInfo.TableInfo
instance Database.Relational.Table.TableDerivable Database.Relational.Schema.SQLite3.TableInfo.TableInfo
instance Database.Relational.OverloadedProjection.HasProjection "cid" Database.Relational.Schema.SQLite3.TableInfo.TableInfo GHC.Int.Int64
instance Database.Relational.OverloadedProjection.HasProjection "name" Database.Relational.Schema.SQLite3.TableInfo.TableInfo GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "ctype" Database.Relational.Schema.SQLite3.TableInfo.TableInfo GHC.Base.String
instance Database.Relational.OverloadedProjection.HasProjection "notnull" Database.Relational.Schema.SQLite3.TableInfo.TableInfo GHC.Int.Int16
instance Database.Relational.OverloadedProjection.HasProjection "dfltValue" Database.Relational.Schema.SQLite3.TableInfo.TableInfo (GHC.Maybe.Maybe GHC.Base.String)
instance Database.Relational.OverloadedProjection.HasProjection "pk" Database.Relational.Schema.SQLite3.TableInfo.TableInfo GHC.Int.Int16

module Database.Relational.Schema.SQLite3

-- | Configuration parameter against SQLite3.
config :: Config
getType :: Map String TypeQ -> TableInfo -> Maybe (String, TypeQ)
normalizeColumn :: String -> String
normalizeType :: String -> String
notNull :: TableInfo -> Bool
tableInfoQuerySQL :: String -> String -> Query () TableInfo
indexListQuerySQL :: String -> String -> Query () IndexList
indexInfoQuerySQL :: String -> String -> Query () IndexInfo


-- | <i>Deprecated: import config from Database.Relational.Schema.SQLite3
--   instead of this module.</i>
module Database.Relational.Schema.SQLite3Syscat.Config

-- | Configuration parameter against SQLite3.
config :: Config


-- | <i>Deprecated: import Database.Relational.Schema.SQLite3.IndexInfo
--   instead of this module.</i>
module Database.Relational.Schema.SQLite3Syscat.IndexInfo


-- | <i>Deprecated: import Database.Relational.Schema.SQLite3.IndexList
--   instead of this module.</i>
module Database.Relational.Schema.SQLite3Syscat.IndexList


-- | <i>Deprecated: import Database.Relational.Schema.SQLite3.TableInfo
--   instead of this module.</i>
module Database.Relational.Schema.SQLite3Syscat.TableInfo
