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


-- | Type-safe EDSL for SQL queries on persistent backends.
--   
--   <tt>esqueleto</tt> is a bare bones, type-safe EDSL for SQL queries
--   that works with unmodified <tt>persistent</tt> SQL backends. Its
--   language closely resembles SQL, so you don't have to learn new
--   concepts, just new syntax, and it's fairly easy to predict the
--   generated SQL and optimize it for your backend. Most kinds of errors
--   committed when writing SQL are caught as compile-time
--   errors---although it is possible to write type-checked
--   <tt>esqueleto</tt> queries that fail at runtime.
--   
--   <tt>persistent</tt> is a library for type-safe data serialization. It
--   has many kinds of backends, such as SQL backends
--   (<tt>persistent-mysql</tt>, <tt>persistent-postgresql</tt>,
--   <tt>persistent-sqlite</tt>) and NoSQL backends
--   (<tt>persistent-mongoDB</tt>). While <tt>persistent</tt> is a nice
--   library for storing and retrieving records, including with filters, it
--   does not try to support some of the features that are specific to SQL
--   backends. In particular, <tt>esqueleto</tt> is the recommended library
--   for type-safe <tt>JOIN</tt>s on <tt>persistent</tt> SQL backends. (The
--   alternative is using raw SQL, but that's error prone and does not
--   offer any composability.)
--   
--   Currently, <tt>SELECT</tt>s, <tt>UPDATE</tt>s, <tt>INSERT</tt>s and
--   <tt>DELETE</tt>s are supported. Not all SQL features are available,
--   but most of them can be easily added (especially functions), so please
--   open an issue or send a pull request if you need anything that is not
--   covered by <tt>esqueleto</tt> on
--   <a>https://github.com/prowdsponsor/esqueleto/</a>.
--   
--   The name of this library means "skeleton" in Portuguese and contains
--   all three SQL letters in the correct order =). It was inspired by
--   Scala's Squeryl but created from scratch.
@package esqueleto
@version 2.4.3


-- | This is an internal module, anything exported by this module may
--   change without a major version bump. Please use only
--   <a>Database.Esqueleto</a> if possible.
module Database.Esqueleto.Internal.Language

-- | Finally tagless representation of <tt>esqueleto</tt>'s EDSL.
class (Functor query, Applicative query, Monad query) => Esqueleto query expr backend | query -> expr backend, expr -> query backend

-- | (Internal) Start a <a>from</a> query with an entity. <a>from</a> does
--   two kinds of magic using <a>fromStart</a>, <a>fromJoin</a> and
--   <a>fromFinish</a>:
--   
--   <ol>
--   <li>The simple but tedious magic of allowing tuples to be used.</li>
--   <li>The more advanced magic of creating <tt>JOIN</tt>s. The
--   <tt>JOIN</tt> is processed from right to left. The rightmost entity of
--   the <tt>JOIN</tt> is created with <a>fromStart</a>. Each <tt>JOIN</tt>
--   step is then translated into a call to <a>fromJoin</a>. In the end,
--   <a>fromFinish</a> is called to materialize the <tt>JOIN</tt>.</li>
--   </ol>
fromStart :: (Esqueleto query expr backend, PersistEntity a, PersistEntityBackend a ~ backend) => query (expr (PreprocessedFrom (expr (Entity a))))

-- | (Internal) Same as <a>fromStart</a>, but entity may be missing.
fromStartMaybe :: (Esqueleto query expr backend, PersistEntity a, PersistEntityBackend a ~ backend) => query (expr (PreprocessedFrom (expr (Maybe (Entity a)))))

-- | (Internal) Do a <tt>JOIN</tt>.
fromJoin :: (Esqueleto query expr backend, IsJoinKind join) => expr (PreprocessedFrom a) -> expr (PreprocessedFrom b) -> query (expr (PreprocessedFrom (join a b)))

-- | (Internal) Finish a <tt>JOIN</tt>.
fromFinish :: Esqueleto query expr backend => expr (PreprocessedFrom a) -> query a

-- | <tt>WHERE</tt> clause: restrict the query's result.
where_ :: Esqueleto query expr backend => expr (Value Bool) -> query ()

-- | <tt>ON</tt> clause: restrict the a <tt>JOIN</tt>'s result. The
--   <tt>ON</tt> clause will be applied to the <i>last</i> <tt>JOIN</tt>
--   that does not have an <tt>ON</tt> clause yet. If there are no
--   <tt>JOIN</tt>s without <tt>ON</tt> clauses (either because you didn't
--   do any <tt>JOIN</tt>, or because all <tt>JOIN</tt>s already have their
--   own <tt>ON</tt> clauses), a runtime exception
--   <a>OnClauseWithoutMatchingJoinException</a> is thrown. <tt>ON</tt>
--   clauses are optional when doing <tt>JOIN</tt>s.
--   
--   On the simple case of doing just one <tt>JOIN</tt>, for example
--   
--   <pre>
--   select $
--   <a>from</a> $ \(foo `<a>InnerJoin</a>` bar) -&gt; do
--     <a>on</a> (foo <a>^.</a> FooId <a>==.</a> bar <a>^.</a> BarFooId)
--     ...
--   </pre>
--   
--   there's no ambiguity and the rules above just mean that you're allowed
--   to call <a>on</a> only once (as in SQL). If you have many joins, then
--   the <a>on</a>s are applied on the <i>reverse</i> order that the
--   <tt>JOIN</tt>s appear. For example:
--   
--   <pre>
--   select $
--   <a>from</a> $ \(foo `<a>InnerJoin</a>` bar `<a>InnerJoin</a>` baz) -&gt; do
--     <a>on</a> (baz <a>^.</a> BazId <a>==.</a> bar <a>^.</a> BarBazId)
--     <a>on</a> (foo <a>^.</a> FooId <a>==.</a> bar <a>^.</a> BarFooId)
--     ...
--   </pre>
--   
--   The order is <i>reversed</i> in order to improve composability. For
--   example, consider <tt>query1</tt> and <tt>query2</tt> below:
--   
--   <pre>
--   let query1 =
--         <a>from</a> $ \(foo `<a>InnerJoin</a>` bar) -&gt; do
--           <a>on</a> (foo <a>^.</a> FooId <a>==.</a> bar <a>^.</a> BarFooId)
--       query2 =
--         <a>from</a> $ \(mbaz `<a>LeftOuterJoin</a>` quux) -&gt; do
--           return (mbaz <a>?.</a> BazName, quux)
--       test1 =      (,) &lt;$&gt; query1 &lt;*&gt; query2
--       test2 = flip (,) &lt;$&gt; query2 &lt;*&gt; query1
--   </pre>
--   
--   If the order was <i>not</i> reversed, then <tt>test2</tt> would be
--   broken: <tt>query1</tt>'s <a>on</a> would refer to <tt>query2</tt>'s
--   <a>LeftOuterJoin</a>.
on :: Esqueleto query expr backend => expr (Value Bool) -> query ()

-- | <tt>GROUP BY</tt> clause. You can enclose multiple columns in a tuple.
--   
--   <pre>
--   select $ <a>from</a> \(foo `<a>InnerJoin</a>` bar) -&gt; do
--     <a>on</a> (foo <a>^.</a> FooBarId <a>==.</a> bar <a>^.</a> BarId)
--     <a>groupBy</a> (bar <a>^.</a> BarId, bar <a>^.</a> BarName)
--     return (bar <a>^.</a> BarId, bar <a>^.</a> BarName, countRows)
--   </pre>
--   
--   With groupBy you can sort by aggregate functions, like so (we used
--   <tt>let</tt> to restrict the more general <a>countRows</a> to
--   <tt>SqlExpr (Value Int)</tt> to avoid ambiguity---the second use of
--   <a>countRows</a> has its type restricted by the <tt>:: Int</tt>
--   below):
--   
--   <pre>
--   r &lt;- select $ <a>from</a> \(foo `<a>InnerJoin</a>` bar) -&gt; do
--     <a>on</a> (foo <a>^.</a> FooBarId <a>==.</a> bar <a>^.</a> BarId)
--     <a>groupBy</a> $ bar <a>^.</a> BarName
--     let countRows' = <a>countRows</a>
--     <a>orderBy</a> [<a>asc</a> countRows']
--     return (bar <a>^.</a> BarName, countRows')
--   forM_ r $ \(<a>Value</a> name, <a>Value</a> count) -&gt; do
--     print name
--     print (count :: Int)
--   </pre>
groupBy :: (Esqueleto query expr backend, ToSomeValues expr a) => a -> query ()

-- | <tt>ORDER BY</tt> clause. See also <a>asc</a> and <a>desc</a>.
--   
--   Multiple calls to <a>orderBy</a> get concatenated on the final query,
--   including <a>distinctOnOrderBy</a>.
orderBy :: Esqueleto query expr backend => [expr OrderBy] -> query ()

-- | Ascending order of this field or expression.
asc :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr OrderBy

-- | Descending order of this field or expression.
desc :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr OrderBy

-- | <tt>LIMIT</tt>. Limit the number of returned rows.
limit :: Esqueleto query expr backend => Int64 -> query ()

-- | <tt>OFFSET</tt>. Usually used with <a>limit</a>.
offset :: Esqueleto query expr backend => Int64 -> query ()

-- | <tt>DISTINCT</tt>. Change the current <tt>SELECT</tt> into <tt>SELECT
--   DISTINCT</tt>. For example:
--   
--   <pre>
--   select $ distinct $
--     <a>from</a> \foo -&gt; do
--     ...
--   </pre>
--   
--   Note that this also has the same effect:
--   
--   <pre>
--   select $
--     <a>from</a> \foo -&gt; do
--     distinct (return ())
--     ...
--   </pre>
--   
--   <i>Since: 2.2.4</i>
distinct :: Esqueleto query expr backend => query a -> query a

-- | <tt>DISTINCT ON</tt>. Change the current <tt>SELECT</tt> into
--   <tt>SELECT DISTINCT ON (expressions)</tt>. For example:
--   
--   <pre>
--   select $
--     <a>from</a> \foo -&gt;
--     <a>distinctOn</a> [<a>don</a> (foo ^. FooName), <a>don</a> (foo ^. FooState)] $ do
--     ...
--   </pre>
--   
--   You can also chain different calls to <a>distinctOn</a>. The above is
--   equivalent to:
--   
--   <pre>
--   select $
--     <a>from</a> \foo -&gt;
--     <a>distinctOn</a> [<a>don</a> (foo ^. FooName)] $
--     <a>distinctOn</a> [<a>don</a> (foo ^. FooState)] $ do
--     ...
--   </pre>
--   
--   Each call to <a>distinctOn</a> adds more expressions. Calls to
--   <a>distinctOn</a> override any calls to <a>distinct</a>.
--   
--   Note that PostgreSQL requires the expressions on <tt>DISTINCT ON</tt>
--   to be the first ones to appear on a <tt>ORDER BY</tt>. This is not
--   managed automatically by esqueleto, keeping its spirit of trying to be
--   close to raw SQL.
--   
--   Supported by PostgreSQL only.
--   
--   <i>Since: 2.2.4</i>
distinctOn :: Esqueleto query expr backend => [expr DistinctOn] -> query a -> query a

-- | Erase an expression's type so that it's suitable to be used by
--   <a>distinctOn</a>.
--   
--   <i>Since: 2.2.4</i>
don :: Esqueleto query expr backend => expr (Value a) -> expr DistinctOn

-- | A convenience function that calls both <a>distinctOn</a> and
--   <a>orderBy</a>. In other words,
--   
--   <pre>
--   <a>distinctOnOrderBy</a> [asc foo, desc bar, desc quux] $ do
--     ...
--   </pre>
--   
--   is the same as:
--   
--   <pre>
--   <a>distinctOn</a> [don foo, don  bar, don  quux] $ do
--     <a>orderBy</a>  [asc foo, desc bar, desc quux]
--     ...
--   </pre>
--   
--   <i>Since: 2.2.4</i>
distinctOnOrderBy :: Esqueleto query expr backend => [expr OrderBy] -> query a -> query a

-- | <tt>ORDER BY random()</tt> clause.
--   
--   <i>Since: 1.3.10</i>
rand :: Esqueleto query expr backend => expr OrderBy

-- | <tt>HAVING</tt>.
--   
--   <i>Since: 1.2.2</i>
having :: Esqueleto query expr backend => expr (Value Bool) -> query ()

-- | Add a locking clause to the query. Please read <a>LockingKind</a>
--   documentation and your RDBMS manual.
--   
--   If multiple calls to <a>locking</a> are made on the same query, the
--   last one is used.
--   
--   <i>Since: 2.2.7</i>
locking :: Esqueleto query expr backend => LockingKind -> query ()

-- | Execute a subquery <tt>SELECT</tt> in an expression. Returns a simple
--   value so should be used only when the <tt>SELECT</tt> query is
--   guaranteed to return just one row.
sub_select :: (Esqueleto query expr backend, PersistField a) => query (expr (Value a)) -> expr (Value a)

-- | Same as <a>sub_select</a> but using <tt>SELECT DISTINCT</tt>.

-- | <i>Deprecated: Since 2.2.4: use <a>sub_select</a> and
--   <a>distinct</a>.</i>
sub_selectDistinct :: (Esqueleto query expr backend, PersistField a) => query (expr (Value a)) -> expr (Value a)

-- | Project a field of an entity.
(^.) :: (Esqueleto query expr backend, PersistEntity val, PersistField typ) => expr (Entity val) -> EntityField val typ -> expr (Value typ)

-- | Project a field of an entity that may be null.
(?.) :: (Esqueleto query expr backend, PersistEntity val, PersistField typ) => expr (Maybe (Entity val)) -> EntityField val typ -> expr (Value (Maybe typ))

-- | Lift a constant value from Haskell-land to the query.
val :: (Esqueleto query expr backend, PersistField typ) => typ -> expr (Value typ)

-- | <tt>IS NULL</tt> comparison.
isNothing :: (Esqueleto query expr backend, PersistField typ) => expr (Value (Maybe typ)) -> expr (Value Bool)

-- | Analogous to <a>Just</a>, promotes a value of type <tt>typ</tt> into
--   one of type <tt>Maybe typ</tt>. It should hold that <tt><a>val</a> .
--   Just === just . <a>val</a></tt>.
just :: Esqueleto query expr backend => expr (Value typ) -> expr (Value (Maybe typ))

-- | <tt>NULL</tt> value.
nothing :: Esqueleto query expr backend => expr (Value (Maybe typ))

-- | Join nested <a>Maybe</a>s in a <a>Value</a> into one. This is useful
--   when calling aggregate functions on nullable fields.
joinV :: Esqueleto query expr backend => expr (Value (Maybe (Maybe typ))) -> expr (Value (Maybe typ))

-- | <tt>COUNT(*)</tt> value.
countRows :: (Esqueleto query expr backend, Num a) => expr (Value a)

-- | <tt>COUNT</tt>.
count :: (Esqueleto query expr backend, Num a) => expr (Value typ) -> expr (Value a)

-- | <tt>COUNT(DISTINCT x)</tt>.
--   
--   <i>Since: 2.4.1</i>
countDistinct :: (Esqueleto query expr backend, Num a) => expr (Value typ) -> expr (Value a)
not_ :: Esqueleto query expr backend => expr (Value Bool) -> expr (Value Bool)
(==.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(>=.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(>.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(<=.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(<.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(!=.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(&&.) :: Esqueleto query expr backend => expr (Value Bool) -> expr (Value Bool) -> expr (Value Bool)
(||.) :: Esqueleto query expr backend => expr (Value Bool) -> expr (Value Bool) -> expr (Value Bool)
(+.) :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value a) -> expr (Value a)
(-.) :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value a) -> expr (Value a)
(/.) :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value a) -> expr (Value a)
(*.) :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value a) -> expr (Value a)
random_ :: (Esqueleto query expr backend, PersistField a, Num a) => expr (Value a)
round_ :: (Esqueleto query expr backend, PersistField a, Num a, PersistField b, Num b) => expr (Value a) -> expr (Value b)
ceiling_ :: (Esqueleto query expr backend, PersistField a, Num a, PersistField b, Num b) => expr (Value a) -> expr (Value b)
floor_ :: (Esqueleto query expr backend, PersistField a, Num a, PersistField b, Num b) => expr (Value a) -> expr (Value b)
sum_ :: (Esqueleto query expr backend, PersistField a, PersistField b) => expr (Value a) -> expr (Value (Maybe b))
min_ :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value (Maybe a))
max_ :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value (Maybe a))
avg_ :: (Esqueleto query expr backend, PersistField a, PersistField b) => expr (Value a) -> expr (Value (Maybe b))

-- | Allow a number of one type to be used as one of another type via an
--   implicit cast. An explicit cast is not made, this function changes
--   only the types on the Haskell side.
--   
--   <i>Caveat</i>: Trying to use <tt>castNum</tt> from <tt>Double</tt> to
--   <tt>Int</tt> will not result in an integer, the original fractional
--   number will still be used! Use <a>round_</a>, <a>ceiling_</a> or
--   <a>floor_</a> instead.
--   
--   <i>Safety</i>: This operation is mostly safe due to the <a>Num</a>
--   constraint between the types and the fact that RDBMSs usually allow
--   numbers of different types to be used interchangeably. However, there
--   may still be issues with the query not being accepted by the RDBMS or
--   <tt>persistent</tt> not being able to parse it.
--   
--   <i>Since: 2.2.9</i>
castNum :: (Esqueleto query expr backend, Num a, Num b) => expr (Value a) -> expr (Value b)

-- | Same as <a>castNum</a>, but for nullable values.
--   
--   <i>Since: 2.2.9</i>
castNumM :: (Esqueleto query expr backend, Num a, Num b) => expr (Value (Maybe a)) -> expr (Value (Maybe b))

-- | <tt>COALESCE</tt> function. Evaluates the arguments in order and
--   returns the value of the first non-NULL expression, or NULL (Nothing)
--   otherwise. Some RDBMSs (such as SQLite) require at least two
--   arguments; please refer to the appropriate documentation.
--   
--   <i>Since: 1.4.3</i>
coalesce :: (Esqueleto query expr backend, PersistField a) => [expr (Value (Maybe a))] -> expr (Value (Maybe a))

-- | Like <tt>coalesce</tt>, but takes a non-nullable expression placed at
--   the end of the expression list, which guarantees a non-NULL result.
--   
--   <i>Since: 1.4.3</i>
coalesceDefault :: (Esqueleto query expr backend, PersistField a) => [expr (Value (Maybe a))] -> expr (Value a) -> expr (Value a)

-- | <tt>LOWER</tt> function.
lower_ :: (Esqueleto query expr backend, SqlString s) => expr (Value s) -> expr (Value s)

-- | <tt>LIKE</tt> operator.
like :: (Esqueleto query expr backend, SqlString s) => expr (Value s) -> expr (Value s) -> expr (Value Bool)

-- | <tt>ILIKE</tt> operator (case-insensitive <tt>LIKE</tt>).
--   
--   Supported by PostgreSQL only.
--   
--   <i>Since: 2.2.3</i>
ilike :: (Esqueleto query expr backend, SqlString s) => expr (Value s) -> expr (Value s) -> expr (Value Bool)

-- | The string <tt><a>%</a></tt>. May be useful while using <a>like</a>
--   and concatenation (<a>concat_</a> or <a>++.</a>, depending on your
--   database). Note that you always have to type the parenthesis, for
--   example:
--   
--   <pre>
--   name `<a>like</a>` (%) ++. <a>val</a> "John" ++. (%)
--   </pre>
(%) :: (Esqueleto query expr backend, SqlString s) => expr (Value s)

-- | The <tt>CONCAT</tt> function with a variable number of parameters.
--   Supported by MySQL and PostgreSQL.
concat_ :: (Esqueleto query expr backend, SqlString s) => [expr (Value s)] -> expr (Value s)

-- | The <tt>||</tt> string concatenation operator (named after Haskell's
--   <a>++</a> in order to avoid naming clash with <a>||.</a>). Supported
--   by SQLite and PostgreSQL.
(++.) :: (Esqueleto query expr backend, SqlString s) => expr (Value s) -> expr (Value s) -> expr (Value s)

-- | Cast a string type into <tt>Text</tt>. This function is very useful if
--   you want to use <tt>newtype</tt>s, or if you want to apply functions
--   such as <a>like</a> to strings of different types.
--   
--   <i>Safety:</i> This is a slightly unsafe function, especially if you
--   have defined your own instances of <a>SqlString</a>. Also, since
--   <a>Maybe</a> is an instance of <a>SqlString</a>, it's possible to turn
--   a nullable value into a non-nullable one. Avoid using this function if
--   possible.
castString :: (Esqueleto query expr backend, SqlString s, SqlString r) => expr (Value s) -> expr (Value r)

-- | Execute a subquery <tt>SELECT</tt> in an expression. Returns a list of
--   values.
subList_select :: (Esqueleto query expr backend, PersistField a) => query (expr (Value a)) -> expr (ValueList a)

-- | Same as <tt>sublist_select</tt> but using <tt>SELECT DISTINCT</tt>.

-- | <i>Deprecated: Since 2.2.4: use <a>subList_select</a> and
--   <a>distinct</a>.</i>
subList_selectDistinct :: (Esqueleto query expr backend, PersistField a) => query (expr (Value a)) -> expr (ValueList a)

-- | Lift a list of constant value from Haskell-land to the query.
valList :: (Esqueleto query expr backend, PersistField typ) => [typ] -> expr (ValueList typ)

-- | Same as <a>just</a> but for <a>ValueList</a>. Most of the time you
--   won't need it, though, because you can use <a>just</a> from inside
--   <a>subList_select</a> or <a>Just</a> from inside <a>valList</a>.
--   
--   <i>Since: 2.2.12</i>
justList :: Esqueleto query expr backend => expr (ValueList typ) -> expr (ValueList (Maybe typ))

-- | <tt>IN</tt> operator. For example if you want to select all
--   <tt>Person</tt>s by a list of IDs:
--   
--   <pre>
--   SELECT *
--   FROM Person
--   WHERE Person.id IN (?)
--   </pre>
--   
--   In <tt>esqueleto</tt>, we may write the same query above as:
--   
--   <pre>
--   select $
--   <a>from</a> $ \person -&gt; do
--   <a>where_</a> $ person <a>^.</a> PersonId <a>in_</a> <a>valList</a> personIds
--   return person
--   </pre>
--   
--   Where <tt>personIds</tt> is of type <tt>[Key Person]</tt>.
in_ :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (ValueList typ) -> expr (Value Bool)

-- | <tt>NOT IN</tt> operator.
notIn :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (ValueList typ) -> expr (Value Bool)

-- | <tt>EXISTS</tt> operator. For example:
--   
--   <pre>
--   select $
--   <a>from</a> $ \person -&gt; do
--   <a>where_</a> $ <a>exists</a> $
--            <a>from</a> $ \post -&gt; do
--            <a>where_</a> (post <a>^.</a> BlogPostAuthorId <a>==.</a> person <a>^.</a> PersonId)
--   return person
--   </pre>
exists :: Esqueleto query expr backend => query () -> expr (Value Bool)

-- | <tt>NOT EXISTS</tt> operator.
notExists :: Esqueleto query expr backend => query () -> expr (Value Bool)

-- | <tt>SET</tt> clause used on <tt>UPDATE</tt>s. Note that while it's not
--   a type error to use this function on a <tt>SELECT</tt>, it will most
--   certainly result in a runtime error.
set :: (Esqueleto query expr backend, PersistEntity val) => expr (Entity val) -> [expr (Update val)] -> query ()
(=.) :: (Esqueleto query expr backend, PersistEntity val, PersistField typ) => EntityField val typ -> expr (Value typ) -> expr (Update val)
(+=.) :: (Esqueleto query expr backend, PersistEntity val, PersistField a) => EntityField val a -> expr (Value a) -> expr (Update val)
(-=.) :: (Esqueleto query expr backend, PersistEntity val, PersistField a) => EntityField val a -> expr (Value a) -> expr (Update val)
(*=.) :: (Esqueleto query expr backend, PersistEntity val, PersistField a) => EntityField val a -> expr (Value a) -> expr (Update val)
(/=.) :: (Esqueleto query expr backend, PersistEntity val, PersistField a) => EntityField val a -> expr (Value a) -> expr (Update val)

-- | Apply a <a>PersistField</a> constructor to <tt>expr Value</tt>
--   arguments.
(<#) :: Esqueleto query expr backend => (a -> b) -> expr (Value a) -> expr (Insertion b)

-- | Apply extra <tt>expr Value</tt> arguments to a <a>PersistField</a>
--   constructor
(<&>) :: Esqueleto query expr backend => expr (Insertion (a -> b)) -> expr (Value a) -> expr (Insertion b)

-- | <tt>CASE</tt> statement. For example:
--   
--   <pre>
--   select $
--   return $
--   <a>case_</a>
--      [ <a>when_</a>
--          (<a>exists</a> $
--          <a>from</a> $ \p -&gt; do
--          <a>where_</a> (p <a>^.</a> PersonName <a>==.</a> <a>val</a> "Mike"))
--        <a>then_</a>
--          (<a>sub_select</a> $
--          <a>from</a> $ \v -&gt; do
--          let sub =
--                  <a>from</a> $ \c -&gt; do
--                  <a>where_</a> (c <a>^.</a> PersonName <a>==.</a> <a>val</a> "Mike")
--                  return (c <a>^.</a> PersonFavNum)
--          <a>where_</a> (v <a>^.</a> PersonFavNum &gt;. <a>sub_select</a> sub)
--          return $ <a>count</a> (v <a>^.</a> PersonName) +. <a>val</a> (1 :: Int)) ]
--      (<a>else_</a> $ <a>val</a> (-1))
--   </pre>
--   
--   This query is a bit complicated, but basically it checks if a person
--   named <tt>"Mike"</tt> exists, and if that person does, run the
--   subquery to find out how many people have a ranking (by Fav Num)
--   higher than <tt>"Mike"</tt>.
--   
--   <b>NOTE:</b> There are a few things to be aware about this statement.
--   
--   <ul>
--   <li>This only implements the full CASE statement, it does not
--   implement the "simple" CASE statement.</li>
--   <li>At least one <a>when_</a> and <a>then_</a> is mandatory otherwise
--   it will emit an error.</li>
--   <li>The <a>else_</a> is also mandatory, unlike the SQL statement in
--   which if the <tt>ELSE</tt> is omitted it will return a <tt>NULL</tt>.
--   You can reproduce this via <a>nothing</a>.</li>
--   </ul>
--   
--   <i>Since: 2.1.2</i>
case_ :: (Esqueleto query expr backend, PersistField a) => [(expr (Value Bool), expr (Value a))] -> expr (Value a) -> expr (Value a)

-- | Convert an entity's key into another entity's.
--   
--   This function is to be used when you change an entity's <tt>Id</tt> to
--   be that of another entity. For example:
--   
--   <pre>
--   Bar
--     barNum Int
--   Foo
--     Id BarId
--     fooNum Int
--   </pre>
--   
--   For this example, declare:
--   
--   <pre>
--   instance ToBaseId Foo where
--     type BaseEnt Foo = Bar
--     toBaseIdWitness = FooKey
--   </pre>
--   
--   Now you're able to write queries such as:
--   
--   <pre>
--   <tt>select</tt> $
--   <a>from</a> $ (bar `<a>InnerJoin</a>` foo) -&gt; do
--   <a>on</a> (<a>toBaseId</a> (foo <a>^.</a> FooId) <a>==.</a> bar <a>^.</a> BarId)
--   return (bar, foo)
--   </pre>
--   
--   Note: this function may be unsafe to use in conditions not like the
--   one of the example above.
--   
--   <i>Since: 2.4.3</i>
toBaseId :: (Esqueleto query expr backend, ToBaseId ent) => expr (Value (Key ent)) -> expr (Value (Key (BaseEnt ent)))

-- | <tt>FROM</tt> clause: bring entities into scope.
--   
--   This function internally uses two type classes in order to provide
--   some flexibility of how you may call it. Internally we refer to these
--   type classes as the two different magics.
--   
--   The innermost magic allows you to use <tt>from</tt> with the following
--   types:
--   
--   <ul>
--   <li><tt>expr (Entity val)</tt>, which brings a single entity into
--   scope.</li>
--   <li><tt>expr (Maybe (Entity val))</tt>, which brings a single entity
--   that may be <tt>NULL</tt> into scope. Used for <tt>OUTER
--   JOIN</tt>s.</li>
--   <li>A <tt>JOIN</tt> of any other two types allowed by the innermost
--   magic, where a <tt>JOIN</tt> may be an <a>InnerJoin</a>, a
--   <a>CrossJoin</a>, a <a>LeftOuterJoin</a>, a <a>RightOuterJoin</a>, or
--   a <a>FullOuterJoin</a>. The <tt>JOINs</tt> have left fixity.</li>
--   </ul>
--   
--   The outermost magic allows you to use <tt>from</tt> on any tuples of
--   types supported by innermost magic (and also tuples of tuples, and so
--   on), up to 8-tuples.
--   
--   Note that using <tt>from</tt> for the same entity twice does work and
--   corresponds to a self-join. You don't even need to use two different
--   calls to <tt>from</tt>, you may use a <tt>JOIN</tt> or a tuple.
--   
--   The following are valid examples of uses of <tt>from</tt> (the types
--   of the arguments of the lambda are inside square brackets):
--   
--   <pre>
--   <a>from</a> $ \person -&gt; ...
--   <a>from</a> $ \(person, blogPost) -&gt; ...
--   <a>from</a> $ \(p `<a>LeftOuterJoin</a>` mb) -&gt; ...
--   <a>from</a> $ \(p1 `<a>InnerJoin</a>` f `<a>InnerJoin</a>` p2) -&gt; ...
--   <a>from</a> $ \((p1 `<a>InnerJoin</a>` f) `<a>InnerJoin</a>` p2) -&gt; ...
--   </pre>
--   
--   The types of the arguments to the lambdas above are, respectively:
--   
--   <pre>
--   person
--     :: ( Esqueleto query expr backend
--        , PersistEntity Person
--        , PersistEntityBackend Person ~ backend
--        ) =&gt; expr (Entity Person)
--   (person, blogPost)
--     :: (...) =&gt; (expr (Entity Person), expr (Entity BlogPost))
--   (p `<a>LeftOuterJoin</a>` mb)
--     :: (...) =&gt; InnerJoin (expr (Entity Person)) (expr (Maybe (Entity BlogPost)))
--   (p1 `<a>InnerJoin</a>` f `<a>InnerJoin</a>` p2)
--     :: (...) =&gt; InnerJoin
--                   (InnerJoin (expr (Entity Person))
--                              (expr (Entity Follow)))
--                   (expr (Entity Person))
--   (p1 `<a>InnerJoin</a>` (f `<a>InnerJoin</a>` p2)) ::
--     :: (...) =&gt; InnerJoin
--                   (expr (Entity Person))
--                   (InnerJoin (expr (Entity Follow))
--                              (expr (Entity Person)))
--   </pre>
--   
--   Note that some backends may not support all kinds of <tt>JOIN</tt>s.
from :: From query expr backend a => (a -> query b) -> query b

-- | A single value (as opposed to a whole entity). You may use
--   <tt>(<a>^.</a>)</tt> or <tt>(<a>?.</a>)</tt> to get a <a>Value</a>
--   from an <a>Entity</a>.
data Value a
Value :: a -> Value a

-- | Unwrap a <a>Value</a>.
--   
--   <i>Since: 1.4.1</i>
unValue :: Value a -> a

-- | A list of single values. There's a limited set of functions able to
--   work with this data type (such as <a>subList_select</a>,
--   <a>valList</a>, <a>in_</a> and <a>exists</a>).
data ValueList a
ValueList :: a -> ValueList a

-- | A wrapper type for for any <tt>expr (Value a)</tt> for all a.
data SomeValue expr
SomeValue :: expr (Value a) -> SomeValue expr

-- | A class of things that can be converted into a list of SomeValue. It
--   has instances for tuples and is the reason why <a>groupBy</a> can take
--   tuples, like <tt><a>groupBy</a> (foo <a>^.</a> FooId, foo <a>^.</a>
--   FooName, foo <a>^.</a> FooType)</tt>.
class ToSomeValues expr a
toSomeValues :: ToSomeValues expr a => a -> [SomeValue expr]

-- | Data type that represents an <tt>INNER JOIN</tt> (see
--   <a>LeftOuterJoin</a> for an example).
data InnerJoin a b
InnerJoin :: a -> b -> InnerJoin a b

-- | Data type that represents a <tt>CROSS JOIN</tt> (see
--   <a>LeftOuterJoin</a> for an example).
data CrossJoin a b
CrossJoin :: a -> b -> CrossJoin a b

-- | Data type that represents a <tt>LEFT OUTER JOIN</tt>. For example,
--   
--   <pre>
--   select $
--   <a>from</a> $ \(person `<a>LeftOuterJoin</a>` pet) -&gt;
--     ...
--   </pre>
--   
--   is translated into
--   
--   <pre>
--   SELECT ...
--   FROM Person LEFT OUTER JOIN Pet
--   ...
--   </pre>
--   
--   See also: <a>from</a>.
data LeftOuterJoin a b
LeftOuterJoin :: a -> b -> LeftOuterJoin a b

-- | Data type that represents a <tt>RIGHT OUTER JOIN</tt> (see
--   <a>LeftOuterJoin</a> for an example).
data RightOuterJoin a b
RightOuterJoin :: a -> b -> RightOuterJoin a b

-- | Data type that represents a <tt>FULL OUTER JOIN</tt> (see
--   <a>LeftOuterJoin</a> for an example).
data FullOuterJoin a b
FullOuterJoin :: a -> b -> FullOuterJoin a b

-- | Exception thrown whenever <a>on</a> is used to create an <tt>ON</tt>
--   clause but no matching <tt>JOIN</tt> is found.
data OnClauseWithoutMatchingJoinException
OnClauseWithoutMatchingJoinException :: String -> OnClauseWithoutMatchingJoinException

-- | Phantom type used by <a>orderBy</a>, <a>asc</a> and <a>desc</a>.
data OrderBy

-- | Phantom type used by <a>distinctOn</a> and <a>don</a>.
data DistinctOn

-- | Phantom type for a <tt>SET</tt> operation on an entity of the given
--   type (see <a>set</a> and '(=.)').
data Update typ

-- | Phantom type used by <tt>insertSelect</tt>.
data Insertion a

-- | Different kinds of locking clauses supported by <a>locking</a>.
--   
--   Note that each RDBMS has different locking support. The constructors
--   of this datatype specify only the <i>syntax</i> of the locking
--   mechanism, not its <i>semantics</i>. For example, even though both
--   MySQL and PostgreSQL support <a>ForUpdate</a>, there are no guarantees
--   that they will behave the same.
--   
--   <i>Since: 2.2.7</i>
data LockingKind

-- | <tt>FOR UPDATE</tt> syntax. Supported by MySQL, Oracle and PostgreSQL.
--   
--   <i>Since: 2.2.7</i>
ForUpdate :: LockingKind

-- | <tt>FOR SHARE</tt> syntax. Supported by PostgreSQL.
--   
--   <i>Since: 2.2.7</i>
ForShare :: LockingKind

-- | <tt>LOCK IN SHARE MODE</tt> syntax. Supported by MySQL.
--   
--   <i>Since: 2.2.7</i>
LockInShareMode :: LockingKind

-- | Phantom class of data types that are treated as strings by the RDBMS.
--   It has no methods because it's only used to avoid type errors such as
--   trying to concatenate integers.
--   
--   If you have a custom data type or <tt>newtype</tt>, feel free to make
--   it an instance of this class.
--   
--   <i>Since: 2.4.0</i>
class PersistField a => SqlString a

-- | Class that enables one to use <a>toBaseId</a> to convert an entity's
--   key on a query into another (cf. <a>toBaseId</a>).
class ToBaseId ent where type family BaseEnt ent :: *
toBaseIdWitness :: ToBaseId ent => Key (BaseEnt ent) -> Key ent

-- | (Internal) A kind of <tt>JOIN</tt>.
data JoinKind

-- | <pre>
--   INNER JOIN
--   </pre>
InnerJoinKind :: JoinKind

-- | <pre>
--   CROSS JOIN
--   </pre>
CrossJoinKind :: JoinKind

-- | <pre>
--   LEFT OUTER JOIN
--   </pre>
LeftOuterJoinKind :: JoinKind

-- | <pre>
--   RIGHT OUTER JOIN
--   </pre>
RightOuterJoinKind :: JoinKind

-- | <pre>
--   FULL OUTER JOIN
--   </pre>
FullOuterJoinKind :: JoinKind

-- | (Internal) Functions that operate on types (that should be) of kind
--   <a>JoinKind</a>.
class IsJoinKind join

-- | (Internal) <tt>smartJoin a b</tt> is a <tt>JOIN</tt> of the correct
--   kind.
smartJoin :: IsJoinKind join => a -> b -> join a b

-- | (Internal) Reify a <tt>JoinKind</tt> from a <tt>JOIN</tt>. This
--   function is non-strict.
reifyJoinKind :: IsJoinKind join => join a b -> JoinKind

-- | (Internal) Phantom type used to process <a>from</a> (see
--   <a>fromStart</a>).
data PreprocessedFrom a

-- | (Internal) Class that implements the tuple <a>from</a> magic (see
--   <a>fromStart</a>).
class Esqueleto query expr backend => From query expr backend a

-- | (Internal) Class that implements the <tt>JOIN</tt> <a>from</a> magic
--   (see <a>fromStart</a>).
class Esqueleto query expr backend => FromPreprocess query expr backend a

-- | Syntax sugar for <a>case_</a>.
--   
--   <i>Since: 2.1.2</i>
when_ :: expr (Value Bool) -> () -> expr a -> (expr (Value Bool), expr a)

-- | Syntax sugar for <a>case_</a>.
--   
--   <i>Since: 2.1.2</i>
then_ :: ()

-- | Syntax sugar for <a>case_</a>.
--   
--   <i>Since: 2.1.2</i>
else_ :: expr a -> expr a
instance GHC.Show.Show Database.Esqueleto.Internal.Language.OnClauseWithoutMatchingJoinException
instance GHC.Classes.Ord Database.Esqueleto.Internal.Language.OnClauseWithoutMatchingJoinException
instance GHC.Classes.Eq Database.Esqueleto.Internal.Language.OnClauseWithoutMatchingJoinException
instance GHC.Classes.Eq Database.Esqueleto.Internal.Language.JoinKind
instance GHC.Show.Show a => GHC.Show.Show (Database.Esqueleto.Internal.Language.ValueList a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Database.Esqueleto.Internal.Language.ValueList a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Database.Esqueleto.Internal.Language.ValueList a)
instance GHC.Show.Show a => GHC.Show.Show (Database.Esqueleto.Internal.Language.Value a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Database.Esqueleto.Internal.Language.Value a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Database.Esqueleto.Internal.Language.Value a)
instance GHC.Base.Functor Database.Esqueleto.Internal.Language.Value
instance (Database.Esqueleto.Internal.Language.ToSomeValues expr a, Database.Esqueleto.Internal.Language.ToSomeValues expr b) => Database.Esqueleto.Internal.Language.ToSomeValues expr (a, b)
instance (Database.Esqueleto.Internal.Language.ToSomeValues expr a, Database.Esqueleto.Internal.Language.ToSomeValues expr b, Database.Esqueleto.Internal.Language.ToSomeValues expr c) => Database.Esqueleto.Internal.Language.ToSomeValues expr (a, b, c)
instance (Database.Esqueleto.Internal.Language.ToSomeValues expr a, Database.Esqueleto.Internal.Language.ToSomeValues expr b, Database.Esqueleto.Internal.Language.ToSomeValues expr c, Database.Esqueleto.Internal.Language.ToSomeValues expr d) => Database.Esqueleto.Internal.Language.ToSomeValues expr (a, b, c, d)
instance (Database.Esqueleto.Internal.Language.ToSomeValues expr a, Database.Esqueleto.Internal.Language.ToSomeValues expr b, Database.Esqueleto.Internal.Language.ToSomeValues expr c, Database.Esqueleto.Internal.Language.ToSomeValues expr d, Database.Esqueleto.Internal.Language.ToSomeValues expr e) => Database.Esqueleto.Internal.Language.ToSomeValues expr (a, b, c, d, e)
instance (Database.Esqueleto.Internal.Language.ToSomeValues expr a, Database.Esqueleto.Internal.Language.ToSomeValues expr b, Database.Esqueleto.Internal.Language.ToSomeValues expr c, Database.Esqueleto.Internal.Language.ToSomeValues expr d, Database.Esqueleto.Internal.Language.ToSomeValues expr e, Database.Esqueleto.Internal.Language.ToSomeValues expr f) => Database.Esqueleto.Internal.Language.ToSomeValues expr (a, b, c, d, e, f)
instance (Database.Esqueleto.Internal.Language.ToSomeValues expr a, Database.Esqueleto.Internal.Language.ToSomeValues expr b, Database.Esqueleto.Internal.Language.ToSomeValues expr c, Database.Esqueleto.Internal.Language.ToSomeValues expr d, Database.Esqueleto.Internal.Language.ToSomeValues expr e, Database.Esqueleto.Internal.Language.ToSomeValues expr f, Database.Esqueleto.Internal.Language.ToSomeValues expr g) => Database.Esqueleto.Internal.Language.ToSomeValues expr (a, b, c, d, e, f, g)
instance (Database.Esqueleto.Internal.Language.ToSomeValues expr a, Database.Esqueleto.Internal.Language.ToSomeValues expr b, Database.Esqueleto.Internal.Language.ToSomeValues expr c, Database.Esqueleto.Internal.Language.ToSomeValues expr d, Database.Esqueleto.Internal.Language.ToSomeValues expr e, Database.Esqueleto.Internal.Language.ToSomeValues expr f, Database.Esqueleto.Internal.Language.ToSomeValues expr g, Database.Esqueleto.Internal.Language.ToSomeValues expr h) => Database.Esqueleto.Internal.Language.ToSomeValues expr (a, b, c, d, e, f, g, h)
instance Database.Esqueleto.Internal.Language.IsJoinKind Database.Esqueleto.Internal.Language.InnerJoin
instance Database.Esqueleto.Internal.Language.IsJoinKind Database.Esqueleto.Internal.Language.CrossJoin
instance Database.Esqueleto.Internal.Language.IsJoinKind Database.Esqueleto.Internal.Language.LeftOuterJoin
instance Database.Esqueleto.Internal.Language.IsJoinKind Database.Esqueleto.Internal.Language.RightOuterJoin
instance Database.Esqueleto.Internal.Language.IsJoinKind Database.Esqueleto.Internal.Language.FullOuterJoin
instance GHC.Exception.Exception Database.Esqueleto.Internal.Language.OnClauseWithoutMatchingJoinException
instance (a ~ GHC.Types.Char) => Database.Esqueleto.Internal.Language.SqlString [a]
instance Database.Esqueleto.Internal.Language.SqlString Data.Text.Internal.Text
instance Database.Esqueleto.Internal.Language.SqlString Data.Text.Internal.Lazy.Text
instance Database.Esqueleto.Internal.Language.SqlString Data.ByteString.Internal.ByteString
instance Database.Esqueleto.Internal.Language.SqlString Text.Blaze.Html.Html
instance Database.Esqueleto.Internal.Language.SqlString a => Database.Esqueleto.Internal.Language.SqlString (GHC.Base.Maybe a)
instance (Database.Esqueleto.Internal.Language.Esqueleto query expr backend, Database.Esqueleto.Internal.Language.FromPreprocess query expr backend (expr (Database.Persist.Class.PersistEntity.Entity val))) => Database.Esqueleto.Internal.Language.From query expr backend (expr (Database.Persist.Class.PersistEntity.Entity val))
instance (Database.Esqueleto.Internal.Language.Esqueleto query expr backend, Database.Esqueleto.Internal.Language.FromPreprocess query expr backend (expr (GHC.Base.Maybe (Database.Persist.Class.PersistEntity.Entity val)))) => Database.Esqueleto.Internal.Language.From query expr backend (expr (GHC.Base.Maybe (Database.Persist.Class.PersistEntity.Entity val)))
instance (Database.Esqueleto.Internal.Language.Esqueleto query expr backend, Database.Esqueleto.Internal.Language.FromPreprocess query expr backend (Database.Esqueleto.Internal.Language.InnerJoin a b)) => Database.Esqueleto.Internal.Language.From query expr backend (Database.Esqueleto.Internal.Language.InnerJoin a b)
instance (Database.Esqueleto.Internal.Language.Esqueleto query expr backend, Database.Esqueleto.Internal.Language.FromPreprocess query expr backend (Database.Esqueleto.Internal.Language.CrossJoin a b)) => Database.Esqueleto.Internal.Language.From query expr backend (Database.Esqueleto.Internal.Language.CrossJoin a b)
instance (Database.Esqueleto.Internal.Language.Esqueleto query expr backend, Database.Esqueleto.Internal.Language.FromPreprocess query expr backend (Database.Esqueleto.Internal.Language.LeftOuterJoin a b)) => Database.Esqueleto.Internal.Language.From query expr backend (Database.Esqueleto.Internal.Language.LeftOuterJoin a b)
instance (Database.Esqueleto.Internal.Language.Esqueleto query expr backend, Database.Esqueleto.Internal.Language.FromPreprocess query expr backend (Database.Esqueleto.Internal.Language.RightOuterJoin a b)) => Database.Esqueleto.Internal.Language.From query expr backend (Database.Esqueleto.Internal.Language.RightOuterJoin a b)
instance (Database.Esqueleto.Internal.Language.Esqueleto query expr backend, Database.Esqueleto.Internal.Language.FromPreprocess query expr backend (Database.Esqueleto.Internal.Language.FullOuterJoin a b)) => Database.Esqueleto.Internal.Language.From query expr backend (Database.Esqueleto.Internal.Language.FullOuterJoin a b)
instance (Database.Esqueleto.Internal.Language.From query expr backend a, Database.Esqueleto.Internal.Language.From query expr backend b) => Database.Esqueleto.Internal.Language.From query expr backend (a, b)
instance (Database.Esqueleto.Internal.Language.From query expr backend a, Database.Esqueleto.Internal.Language.From query expr backend b, Database.Esqueleto.Internal.Language.From query expr backend c) => Database.Esqueleto.Internal.Language.From query expr backend (a, b, c)
instance (Database.Esqueleto.Internal.Language.From query expr backend a, Database.Esqueleto.Internal.Language.From query expr backend b, Database.Esqueleto.Internal.Language.From query expr backend c, Database.Esqueleto.Internal.Language.From query expr backend d) => Database.Esqueleto.Internal.Language.From query expr backend (a, b, c, d)
instance (Database.Esqueleto.Internal.Language.From query expr backend a, Database.Esqueleto.Internal.Language.From query expr backend b, Database.Esqueleto.Internal.Language.From query expr backend c, Database.Esqueleto.Internal.Language.From query expr backend d, Database.Esqueleto.Internal.Language.From query expr backend e) => Database.Esqueleto.Internal.Language.From query expr backend (a, b, c, d, e)
instance (Database.Esqueleto.Internal.Language.From query expr backend a, Database.Esqueleto.Internal.Language.From query expr backend b, Database.Esqueleto.Internal.Language.From query expr backend c, Database.Esqueleto.Internal.Language.From query expr backend d, Database.Esqueleto.Internal.Language.From query expr backend e, Database.Esqueleto.Internal.Language.From query expr backend f) => Database.Esqueleto.Internal.Language.From query expr backend (a, b, c, d, e, f)
instance (Database.Esqueleto.Internal.Language.From query expr backend a, Database.Esqueleto.Internal.Language.From query expr backend b, Database.Esqueleto.Internal.Language.From query expr backend c, Database.Esqueleto.Internal.Language.From query expr backend d, Database.Esqueleto.Internal.Language.From query expr backend e, Database.Esqueleto.Internal.Language.From query expr backend f, Database.Esqueleto.Internal.Language.From query expr backend g) => Database.Esqueleto.Internal.Language.From query expr backend (a, b, c, d, e, f, g)
instance (Database.Esqueleto.Internal.Language.From query expr backend a, Database.Esqueleto.Internal.Language.From query expr backend b, Database.Esqueleto.Internal.Language.From query expr backend c, Database.Esqueleto.Internal.Language.From query expr backend d, Database.Esqueleto.Internal.Language.From query expr backend e, Database.Esqueleto.Internal.Language.From query expr backend f, Database.Esqueleto.Internal.Language.From query expr backend g, Database.Esqueleto.Internal.Language.From query expr backend h) => Database.Esqueleto.Internal.Language.From query expr backend (a, b, c, d, e, f, g, h)
instance (Database.Esqueleto.Internal.Language.Esqueleto query expr backend, Database.Persist.Class.PersistEntity.PersistEntity val, Database.Persist.Class.PersistEntity.PersistEntityBackend val ~ backend) => Database.Esqueleto.Internal.Language.FromPreprocess query expr backend (expr (Database.Persist.Class.PersistEntity.Entity val))
instance (Database.Esqueleto.Internal.Language.Esqueleto query expr backend, Database.Persist.Class.PersistEntity.PersistEntity val, Database.Persist.Class.PersistEntity.PersistEntityBackend val ~ backend) => Database.Esqueleto.Internal.Language.FromPreprocess query expr backend (expr (GHC.Base.Maybe (Database.Persist.Class.PersistEntity.Entity val)))
instance (Database.Esqueleto.Internal.Language.Esqueleto query expr backend, Database.Esqueleto.Internal.Language.FromPreprocess query expr backend a, Database.Esqueleto.Internal.Language.FromPreprocess query expr backend b, Database.Esqueleto.Internal.Language.IsJoinKind join) => Database.Esqueleto.Internal.Language.FromPreprocess query expr backend (join a b)


-- | This is an internal module, anything exported by this module may
--   change without a major version bump. Please use only
--   <a>Database.Esqueleto</a> if possible.
module Database.Esqueleto.Internal.Sql

-- | SQL backend for <tt>esqueleto</tt> using <a>SqlPersistT</a>.
data SqlQuery a

-- | An expression on the SQL backend.
--   
--   There are many comments describing the constructors of this data type.
--   However, Haddock doesn't like GADTs, so you'll have to read them by
--   hitting "Source".
data SqlExpr a

-- | Constraint synonym for <tt>persistent</tt> entities whose backend is
--   <a>SqlPersistT</a>.
type SqlEntity ent = (PersistEntity ent, PersistEntityBackend ent ~ SqlBackend)

-- | Execute an <tt>esqueleto</tt> <tt>SELECT</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad and return a list of
--   rows.
--   
--   We've seen that <a>from</a> has some magic about which kinds of things
--   you may bring into scope. This <a>select</a> function also has some
--   magic for which kinds of things you may bring back to Haskell-land by
--   using <tt>SqlQuery</tt>'s <tt>return</tt>:
--   
--   <ul>
--   <li>You may return a <tt>SqlExpr (<a>Entity</a> v)</tt> for an entity
--   <tt>v</tt> (i.e., like the <tt>*</tt> in SQL), which is then returned
--   to Haskell-land as just <tt>Entity v</tt>.</li>
--   <li>You may return a <tt>SqlExpr (Maybe (Entity v))</tt> for an entity
--   <tt>v</tt> that may be <tt>NULL</tt>, which is then returned to
--   Haskell-land as <tt>Maybe (Entity v)</tt>. Used for <tt>OUTER
--   JOIN</tt>s.</li>
--   <li>You may return a <tt>SqlExpr (<a>Value</a> t)</tt> for a value
--   <tt>t</tt> (i.e., a single column), where <tt>t</tt> is any instance
--   of <a>PersistField</a>, which is then returned to Haskell-land as
--   <tt>Value t</tt>. You may use <tt>Value</tt> to return projections of
--   an <tt>Entity</tt> (see <tt>(<a>^.</a>)</tt> and <tt>(<a>?.</a>)</tt>)
--   or to return any other value calculated on the query (e.g.,
--   <a>countRows</a> or <a>sub_select</a>).</li>
--   </ul>
--   
--   The <tt>SqlSelect a r</tt> class has functional dependencies that
--   allow type information to flow both from <tt>a</tt> to <tt>r</tt> and
--   vice-versa. This means that you'll almost never have to give any type
--   signatures for <tt>esqueleto</tt> queries. For example, the query
--   <tt><a>select</a> $ from $ \p -&gt; return p</tt> alone is ambiguous,
--   but in the context of
--   
--   <pre>
--   do ps &lt;- <a>select</a> $
--            <a>from</a> $ \p -&gt;
--            return p
--      liftIO $ mapM_ (putStrLn . personName . entityVal) ps
--   </pre>
--   
--   we are able to infer from that single <tt>personName . entityVal</tt>
--   function composition that the <tt>p</tt> inside the query is of type
--   <tt>SqlExpr (Entity Person)</tt>.
select :: (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlPersistT m [r]

-- | Execute an <tt>esqueleto</tt> <tt>SELECT</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad and return a
--   <a>Source</a> of rows.
selectSource :: (SqlSelect a r, MonadResource m) => SqlQuery a -> Source (SqlPersistT m) r

-- | Execute an <tt>esqueleto</tt> <tt>SELECT DISTINCT</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad and return a list of
--   rows.

-- | <i>Deprecated: Since 2.2.4: use <a>select</a> and <a>distinct</a>.</i>
selectDistinct :: (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlPersistT m [r]

-- | Execute an <tt>esqueleto</tt> <tt>SELECT DISTINCT</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad and return a
--   <a>Source</a> of rows.

-- | <i>Deprecated: Since 2.2.4: use <a>selectSource</a> and
--   <a>distinct</a>.</i>
selectDistinctSource :: (SqlSelect a r, MonadResource m) => SqlQuery a -> Source (SqlPersistT m) r

-- | Execute an <tt>esqueleto</tt> <tt>DELETE</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad. Note that currently
--   there are no type checks for statements that should not appear on a
--   <tt>DELETE</tt> query.
--   
--   Example of usage:
--   
--   <pre>
--   <a>delete</a> $
--   <a>from</a> $ \appointment -&gt;
--   <a>where_</a> (appointment <a>^.</a> AppointmentDate <a>&lt;.</a> <a>val</a> now)
--   </pre>
--   
--   Unlike <a>select</a>, there is a useful way of using <a>delete</a>
--   that will lead to type ambiguities. If you want to delete all rows
--   (i.e., no <a>where_</a> clause), you'll have to use a type signature:
--   
--   <pre>
--   <a>delete</a> $
--   <a>from</a> $ \(appointment :: <a>SqlExpr</a> (<a>Entity</a> Appointment)) -&gt;
--   return ()
--   </pre>
delete :: (MonadIO m) => SqlQuery () -> SqlPersistT m ()

-- | Same as <a>delete</a>, but returns the number of rows affected.
deleteCount :: (MonadIO m) => SqlQuery () -> SqlPersistT m Int64

-- | Execute an <tt>esqueleto</tt> <tt>UPDATE</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad. Note that currently
--   there are no type checks for statements that should not appear on a
--   <tt>UPDATE</tt> query.
--   
--   Example of usage:
--   
--   <pre>
--   <a>update</a> $ p -&gt; do
--   <a>set</a> p [ PersonAge <a>=.</a> <a>just</a> (<a>val</a> thisYear) -. p <a>^.</a> PersonBorn ]
--   <a>where_</a> $ isNothing (p <a>^.</a> PersonAge)
--   </pre>
update :: (MonadIO m, SqlEntity val) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlPersistT m ()

-- | Same as <a>update</a>, but returns the number of rows affected.
updateCount :: (MonadIO m, SqlEntity val) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlPersistT m Int64

-- | Insert a <a>PersistField</a> for every unique selected value.

-- | <i>Deprecated: Since 2.2.4: use <a>insertSelect</a> and
--   <a>distinct</a>.</i>
insertSelectDistinct :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlPersistT m ()

-- | Insert a <a>PersistField</a> for every selected value.
--   
--   <i>Since: 2.4.2</i>
insertSelect :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlPersistT m ()

-- | Insert a <a>PersistField</a> for every selected value, return the
--   count afterward
insertSelectCount :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlPersistT m Int64

-- | (Internal) Create a case statement.
--   
--   Since: 2.1.1
unsafeSqlCase :: PersistField a => [(SqlExpr (Value Bool), SqlExpr (Value a))] -> SqlExpr (Value a) -> SqlExpr (Value a)

-- | (Internal) Create a custom binary operator. You <i>should</i>
--   <i>not</i> use this function directly since its type is very general,
--   you should always use it with an explicit type signature. For example:
--   
--   <pre>
--   (==.) :: SqlExpr (Value a) -&gt; SqlExpr (Value a) -&gt; SqlExpr (Value Bool)
--   (==.) = unsafeSqlBinOp " = "
--   </pre>
--   
--   In the example above, we constraint the arguments to be of the same
--   type and constraint the result to be a boolean value.
unsafeSqlBinOp :: Builder -> SqlExpr (Value a) -> SqlExpr (Value b) -> SqlExpr (Value c)

-- | Similar to <a>unsafeSqlBinOp</a>, but may also be applied to composite
--   keys. Uses the operator given as the second argument whenever applied
--   to composite keys.
--   
--   Usage example:
--   
--   <pre>
--   (==.) :: SqlExpr (Value a) -&gt; SqlExpr (Value a) -&gt; SqlExpr (Value Bool)
--   (==.) = unsafeSqlBinOpComposite " = " " AND "
--   </pre>
--   
--   Persistent has a hack for implementing composite keys (see
--   <a>ECompositeKey</a> doc for more details), so we're forced to use a
--   hack here as well. We deconstruct <a>ERaw</a> values based on two
--   rules:
--   
--   <ul>
--   <li>If it is a single placeholder, then it's assumed to be coming from
--   a <a>PersistList</a> and thus its components are separated so that
--   they may be applied to a composite key.</li>
--   <li>If it is not a single placeholder, then it's assumed to be a
--   foreign (composite or not) key, so we enforce that it has no
--   placeholders and split it on the commas.</li>
--   </ul>
unsafeSqlBinOpComposite :: Builder -> Builder -> SqlExpr (Value a) -> SqlExpr (Value b) -> SqlExpr (Value c)

-- | (Internal) A raw SQL value. The same warning from
--   <a>unsafeSqlBinOp</a> applies to this function as well.
unsafeSqlValue :: Builder -> SqlExpr (Value a)

-- | (Internal) A raw SQL function. Once again, the same warning from
--   <a>unsafeSqlBinOp</a> applies to this function as well.
unsafeSqlFunction :: UnsafeSqlFunctionArgument a => Builder -> a -> SqlExpr (Value b)

-- | (Internal) An unsafe SQL function to extract a subfield from a
--   compound field, e.g. datetime. See <a>unsafeSqlBinOp</a> for warnings.
--   
--   Since: 1.3.6.
unsafeSqlExtractSubField :: UnsafeSqlFunctionArgument a => Builder -> a -> SqlExpr (Value b)
class UnsafeSqlFunctionArgument a

-- | (Internal) Execute an <tt>esqueleto</tt> <tt>SELECT</tt>
--   <a>SqlQuery</a> inside <tt>persistent</tt>'s <a>SqlPersistT</a> monad.
rawSelectSource :: (SqlSelect a r, MonadIO m1, MonadIO m2) => Mode -> SqlQuery a -> SqlPersistT m1 (Acquire (Source m2 r))

-- | (Internal) Run a <a>Source</a> of rows.
runSource :: Monad m => Source (SqlPersistT m) r -> SqlPersistT m [r]

-- | (Internal) Execute an <tt>esqueleto</tt> statement inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad.
rawEsqueleto :: (MonadIO m, SqlSelect a r) => Mode -> SqlQuery a -> SqlPersistT m Int64

-- | (Internal) Pretty prints a <a>SqlQuery</a> into a SQL query.
--   
--   Note: if you're curious about the SQL query being generated by
--   <tt>esqueleto</tt>, instead of manually using this function (which is
--   possible but tedious), you may just turn on query logging of
--   <tt>persistent</tt>.
toRawSql :: SqlSelect a r => Mode -> IdentInfo -> SqlQuery a -> (Builder, [PersistValue])

-- | (Internal) Mode of query being converted by <a>toRawSql</a>.
data Mode
SELECT :: Mode
DELETE :: Mode
UPDATE :: Mode
INSERT_INTO :: Mode

-- | List of identifiers already in use and supply of temporary
--   identifiers.
data IdentState
initialIdentState :: IdentState

-- | Information needed to escape and use identifiers.
type IdentInfo = (SqlBackend, IdentState)

-- | (Internal) Class for mapping results coming from <a>SqlQuery</a> into
--   actual results.
--   
--   This looks very similar to <tt>RawSql</tt>, and it is! However, there
--   are some crucial differences and ultimately they're different classes.
class SqlSelect a r | a -> r, r -> a where sqlInsertInto = error "Type does not support sqlInsertInto."

-- | Creates the variable part of the <tt>SELECT</tt> query and returns the
--   list of <a>PersistValue</a>s that will be given to <a>rawQuery</a>.
sqlSelectCols :: SqlSelect a r => IdentInfo -> a -> (Builder, [PersistValue])

-- | Number of columns that will be consumed.
sqlSelectColCount :: SqlSelect a r => Proxy a -> Int

-- | Transform a row of the result into the data type.
sqlSelectProcessRow :: SqlSelect a r => [PersistValue] -> Either Text r

-- | Create <tt>INSERT INTO</tt> clause instead.
sqlInsertInto :: SqlSelect a r => IdentInfo -> a -> (Builder, [PersistValue])

-- | (Internal) Coerce a value's type from 'SqlExpr (Value a)' to 'SqlExpr
--   (Value b)'. You should <i>not</i> use this function unless you know
--   what you're doing!
veryUnsafeCoerceSqlExprValue :: SqlExpr (Value a) -> SqlExpr (Value b)

-- | (Internal) Coerce a value's type from 'SqlExpr (ValueList a)' to
--   'SqlExpr (Value a)'. Does not work with empty lists.
veryUnsafeCoerceSqlExprValueList :: SqlExpr (ValueList a) -> SqlExpr (Value a)
instance GHC.Base.Functor Database.Esqueleto.Internal.Sql.SqlQuery
instance GHC.Base.Monad Database.Esqueleto.Internal.Sql.SqlQuery
instance GHC.Base.Applicative Database.Esqueleto.Internal.Sql.SqlQuery
instance GHC.Base.Monoid Database.Esqueleto.Internal.Sql.SideData
instance GHC.Base.Monoid Database.Esqueleto.Internal.Sql.DistinctClause
instance GHC.Base.Monoid Database.Esqueleto.Internal.Sql.WhereClause
instance GHC.Base.Monoid Database.Esqueleto.Internal.Sql.GroupByClause
instance GHC.Base.Monoid Database.Esqueleto.Internal.Sql.LimitClause
instance Database.Esqueleto.Internal.Language.Esqueleto Database.Esqueleto.Internal.Sql.SqlQuery Database.Esqueleto.Internal.Sql.SqlExpr Database.Persist.Sql.Types.SqlBackend
instance Database.Esqueleto.Internal.Language.ToSomeValues Database.Esqueleto.Internal.Sql.SqlExpr (Database.Esqueleto.Internal.Sql.SqlExpr (Database.Esqueleto.Internal.Language.Value a))
instance (a ~ Database.Esqueleto.Internal.Language.Value b) => Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument (Database.Esqueleto.Internal.Sql.SqlExpr a)
instance Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument a => Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument [a]
instance (Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument a, Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument b) => Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument (a, b)
instance (Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument a, Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument b, Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument c) => Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument (a, b, c)
instance (Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument a, Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument b, Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument c, Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument d) => Database.Esqueleto.Internal.Sql.UnsafeSqlFunctionArgument (a, b, c, d)
instance Database.Esqueleto.Internal.Sql.SqlSelect (Database.Esqueleto.Internal.Sql.SqlExpr Database.Esqueleto.Internal.Sql.InsertFinal) Database.Esqueleto.Internal.Sql.InsertFinal
instance Database.Esqueleto.Internal.Sql.SqlSelect () ()
instance Database.Persist.Class.PersistEntity.PersistEntity a => Database.Esqueleto.Internal.Sql.SqlSelect (Database.Esqueleto.Internal.Sql.SqlExpr (Database.Persist.Class.PersistEntity.Entity a)) (Database.Persist.Class.PersistEntity.Entity a)
instance Database.Persist.Class.PersistEntity.PersistEntity a => Database.Esqueleto.Internal.Sql.SqlSelect (Database.Esqueleto.Internal.Sql.SqlExpr (GHC.Base.Maybe (Database.Persist.Class.PersistEntity.Entity a))) (GHC.Base.Maybe (Database.Persist.Class.PersistEntity.Entity a))
instance Database.Persist.Class.PersistField.PersistField a => Database.Esqueleto.Internal.Sql.SqlSelect (Database.Esqueleto.Internal.Sql.SqlExpr (Database.Esqueleto.Internal.Language.Value a)) (Database.Esqueleto.Internal.Language.Value a)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b) (ra, rb)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c) (ra, rb, rc)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d) (ra, rb, rc, rd)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e) (ra, rb, rc, rd, re)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f) (ra, rb, rc, rd, re, rf)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf, Database.Esqueleto.Internal.Sql.SqlSelect g rg) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f, g) (ra, rb, rc, rd, re, rf, rg)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf, Database.Esqueleto.Internal.Sql.SqlSelect g rg, Database.Esqueleto.Internal.Sql.SqlSelect h rh) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f, g, h) (ra, rb, rc, rd, re, rf, rg, rh)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf, Database.Esqueleto.Internal.Sql.SqlSelect g rg, Database.Esqueleto.Internal.Sql.SqlSelect h rh, Database.Esqueleto.Internal.Sql.SqlSelect i ri) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f, g, h, i) (ra, rb, rc, rd, re, rf, rg, rh, ri)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf, Database.Esqueleto.Internal.Sql.SqlSelect g rg, Database.Esqueleto.Internal.Sql.SqlSelect h rh, Database.Esqueleto.Internal.Sql.SqlSelect i ri, Database.Esqueleto.Internal.Sql.SqlSelect j rj) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f, g, h, i, j) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf, Database.Esqueleto.Internal.Sql.SqlSelect g rg, Database.Esqueleto.Internal.Sql.SqlSelect h rh, Database.Esqueleto.Internal.Sql.SqlSelect i ri, Database.Esqueleto.Internal.Sql.SqlSelect j rj, Database.Esqueleto.Internal.Sql.SqlSelect k rk) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f, g, h, i, j, k) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf, Database.Esqueleto.Internal.Sql.SqlSelect g rg, Database.Esqueleto.Internal.Sql.SqlSelect h rh, Database.Esqueleto.Internal.Sql.SqlSelect i ri, Database.Esqueleto.Internal.Sql.SqlSelect j rj, Database.Esqueleto.Internal.Sql.SqlSelect k rk, Database.Esqueleto.Internal.Sql.SqlSelect l rl) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f, g, h, i, j, k, l) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf, Database.Esqueleto.Internal.Sql.SqlSelect g rg, Database.Esqueleto.Internal.Sql.SqlSelect h rh, Database.Esqueleto.Internal.Sql.SqlSelect i ri, Database.Esqueleto.Internal.Sql.SqlSelect j rj, Database.Esqueleto.Internal.Sql.SqlSelect k rk, Database.Esqueleto.Internal.Sql.SqlSelect l rl, Database.Esqueleto.Internal.Sql.SqlSelect m rm) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f, g, h, i, j, k, l, m) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf, Database.Esqueleto.Internal.Sql.SqlSelect g rg, Database.Esqueleto.Internal.Sql.SqlSelect h rh, Database.Esqueleto.Internal.Sql.SqlSelect i ri, Database.Esqueleto.Internal.Sql.SqlSelect j rj, Database.Esqueleto.Internal.Sql.SqlSelect k rk, Database.Esqueleto.Internal.Sql.SqlSelect l rl, Database.Esqueleto.Internal.Sql.SqlSelect m rm, Database.Esqueleto.Internal.Sql.SqlSelect n rn) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f, g, h, i, j, k, l, m, n) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm, rn)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf, Database.Esqueleto.Internal.Sql.SqlSelect g rg, Database.Esqueleto.Internal.Sql.SqlSelect h rh, Database.Esqueleto.Internal.Sql.SqlSelect i ri, Database.Esqueleto.Internal.Sql.SqlSelect j rj, Database.Esqueleto.Internal.Sql.SqlSelect k rk, Database.Esqueleto.Internal.Sql.SqlSelect l rl, Database.Esqueleto.Internal.Sql.SqlSelect m rm, Database.Esqueleto.Internal.Sql.SqlSelect n rn, Database.Esqueleto.Internal.Sql.SqlSelect o ro) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm, rn, ro)
instance (Database.Esqueleto.Internal.Sql.SqlSelect a ra, Database.Esqueleto.Internal.Sql.SqlSelect b rb, Database.Esqueleto.Internal.Sql.SqlSelect c rc, Database.Esqueleto.Internal.Sql.SqlSelect d rd, Database.Esqueleto.Internal.Sql.SqlSelect e re, Database.Esqueleto.Internal.Sql.SqlSelect f rf, Database.Esqueleto.Internal.Sql.SqlSelect g rg, Database.Esqueleto.Internal.Sql.SqlSelect h rh, Database.Esqueleto.Internal.Sql.SqlSelect i ri, Database.Esqueleto.Internal.Sql.SqlSelect j rj, Database.Esqueleto.Internal.Sql.SqlSelect k rk, Database.Esqueleto.Internal.Sql.SqlSelect l rl, Database.Esqueleto.Internal.Sql.SqlSelect m rm, Database.Esqueleto.Internal.Sql.SqlSelect n rn, Database.Esqueleto.Internal.Sql.SqlSelect o ro, Database.Esqueleto.Internal.Sql.SqlSelect p rp) => Database.Esqueleto.Internal.Sql.SqlSelect (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm, rn, ro, rp)


-- | This module contain PostgreSQL-specific functions.
--   
--   <i>Since: 2.2.8</i>
module Database.Esqueleto.PostgreSQL

-- | (<tt>array_agg</tt>) Concatenate input values, including
--   <tt>NULL</tt>s, into an array.
--   
--   <i>Since: 2.2.8</i>
arrayAgg :: SqlExpr (Value a) -> SqlExpr (Value [a])

-- | (<tt>string_agg</tt>) Concatenate input values separated by a
--   delimiter.
--   
--   <i>Since: 2.2.8</i>
stringAgg :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value s)

-- | (<tt>chr</tt>) Translate the given integer to a character. (Note the
--   result will depend on the character set of your database.)
--   
--   <i>Since: 2.2.11</i>
chr :: SqlString s => SqlExpr (Value Int) -> SqlExpr (Value s)


-- | The <tt>esqueleto</tt> EDSL (embedded domain specific language). This
--   module replaces <tt>Database.Persist</tt>, so instead of importing
--   that module you should just import this one:
--   
--   <pre>
--   -- For a module using just esqueleto.
--   import Database.Esqueleto
--   </pre>
--   
--   If you need to use <tt>persistent</tt>'s default support for queries
--   as well, either import it qualified:
--   
--   <pre>
--   -- For a module that mostly uses esqueleto.
--   import Database.Esqueleto
--   import qualified Database.Persistent as P
--   </pre>
--   
--   or import <tt>esqueleto</tt> itself qualified:
--   
--   <pre>
--   -- For a module that uses esqueleto just on some queries.
--   import Database.Persistent
--   import qualified Database.Esqueleto as E
--   </pre>
--   
--   Other than identifier name clashes, <tt>esqueleto</tt> does not
--   conflict with <tt>persistent</tt> in any way.
module Database.Esqueleto

-- | Finally tagless representation of <tt>esqueleto</tt>'s EDSL.
class (Functor query, Applicative query, Monad query) => Esqueleto query expr backend | query -> expr backend, expr -> query backend

-- | <tt>WHERE</tt> clause: restrict the query's result.
where_ :: Esqueleto query expr backend => expr (Value Bool) -> query ()

-- | <tt>ON</tt> clause: restrict the a <tt>JOIN</tt>'s result. The
--   <tt>ON</tt> clause will be applied to the <i>last</i> <tt>JOIN</tt>
--   that does not have an <tt>ON</tt> clause yet. If there are no
--   <tt>JOIN</tt>s without <tt>ON</tt> clauses (either because you didn't
--   do any <tt>JOIN</tt>, or because all <tt>JOIN</tt>s already have their
--   own <tt>ON</tt> clauses), a runtime exception
--   <a>OnClauseWithoutMatchingJoinException</a> is thrown. <tt>ON</tt>
--   clauses are optional when doing <tt>JOIN</tt>s.
--   
--   On the simple case of doing just one <tt>JOIN</tt>, for example
--   
--   <pre>
--   select $
--   <a>from</a> $ \(foo `<a>InnerJoin</a>` bar) -&gt; do
--     <a>on</a> (foo <a>^.</a> FooId <a>==.</a> bar <a>^.</a> BarFooId)
--     ...
--   </pre>
--   
--   there's no ambiguity and the rules above just mean that you're allowed
--   to call <a>on</a> only once (as in SQL). If you have many joins, then
--   the <a>on</a>s are applied on the <i>reverse</i> order that the
--   <tt>JOIN</tt>s appear. For example:
--   
--   <pre>
--   select $
--   <a>from</a> $ \(foo `<a>InnerJoin</a>` bar `<a>InnerJoin</a>` baz) -&gt; do
--     <a>on</a> (baz <a>^.</a> BazId <a>==.</a> bar <a>^.</a> BarBazId)
--     <a>on</a> (foo <a>^.</a> FooId <a>==.</a> bar <a>^.</a> BarFooId)
--     ...
--   </pre>
--   
--   The order is <i>reversed</i> in order to improve composability. For
--   example, consider <tt>query1</tt> and <tt>query2</tt> below:
--   
--   <pre>
--   let query1 =
--         <a>from</a> $ \(foo `<a>InnerJoin</a>` bar) -&gt; do
--           <a>on</a> (foo <a>^.</a> FooId <a>==.</a> bar <a>^.</a> BarFooId)
--       query2 =
--         <a>from</a> $ \(mbaz `<a>LeftOuterJoin</a>` quux) -&gt; do
--           return (mbaz <a>?.</a> BazName, quux)
--       test1 =      (,) &lt;$&gt; query1 &lt;*&gt; query2
--       test2 = flip (,) &lt;$&gt; query2 &lt;*&gt; query1
--   </pre>
--   
--   If the order was <i>not</i> reversed, then <tt>test2</tt> would be
--   broken: <tt>query1</tt>'s <a>on</a> would refer to <tt>query2</tt>'s
--   <a>LeftOuterJoin</a>.
on :: Esqueleto query expr backend => expr (Value Bool) -> query ()

-- | <tt>GROUP BY</tt> clause. You can enclose multiple columns in a tuple.
--   
--   <pre>
--   select $ <a>from</a> \(foo `<a>InnerJoin</a>` bar) -&gt; do
--     <a>on</a> (foo <a>^.</a> FooBarId <a>==.</a> bar <a>^.</a> BarId)
--     <a>groupBy</a> (bar <a>^.</a> BarId, bar <a>^.</a> BarName)
--     return (bar <a>^.</a> BarId, bar <a>^.</a> BarName, countRows)
--   </pre>
--   
--   With groupBy you can sort by aggregate functions, like so (we used
--   <tt>let</tt> to restrict the more general <a>countRows</a> to
--   <tt>SqlExpr (Value Int)</tt> to avoid ambiguity---the second use of
--   <a>countRows</a> has its type restricted by the <tt>:: Int</tt>
--   below):
--   
--   <pre>
--   r &lt;- select $ <a>from</a> \(foo `<a>InnerJoin</a>` bar) -&gt; do
--     <a>on</a> (foo <a>^.</a> FooBarId <a>==.</a> bar <a>^.</a> BarId)
--     <a>groupBy</a> $ bar <a>^.</a> BarName
--     let countRows' = <a>countRows</a>
--     <a>orderBy</a> [<a>asc</a> countRows']
--     return (bar <a>^.</a> BarName, countRows')
--   forM_ r $ \(<a>Value</a> name, <a>Value</a> count) -&gt; do
--     print name
--     print (count :: Int)
--   </pre>
groupBy :: (Esqueleto query expr backend, ToSomeValues expr a) => a -> query ()

-- | <tt>ORDER BY</tt> clause. See also <a>asc</a> and <a>desc</a>.
--   
--   Multiple calls to <a>orderBy</a> get concatenated on the final query,
--   including <a>distinctOnOrderBy</a>.
orderBy :: Esqueleto query expr backend => [expr OrderBy] -> query ()

-- | Ascending order of this field or expression.
asc :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr OrderBy

-- | Descending order of this field or expression.
desc :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr OrderBy

-- | <tt>LIMIT</tt>. Limit the number of returned rows.
limit :: Esqueleto query expr backend => Int64 -> query ()

-- | <tt>OFFSET</tt>. Usually used with <a>limit</a>.
offset :: Esqueleto query expr backend => Int64 -> query ()

-- | <tt>DISTINCT</tt>. Change the current <tt>SELECT</tt> into <tt>SELECT
--   DISTINCT</tt>. For example:
--   
--   <pre>
--   select $ distinct $
--     <a>from</a> \foo -&gt; do
--     ...
--   </pre>
--   
--   Note that this also has the same effect:
--   
--   <pre>
--   select $
--     <a>from</a> \foo -&gt; do
--     distinct (return ())
--     ...
--   </pre>
--   
--   <i>Since: 2.2.4</i>
distinct :: Esqueleto query expr backend => query a -> query a

-- | <tt>DISTINCT ON</tt>. Change the current <tt>SELECT</tt> into
--   <tt>SELECT DISTINCT ON (expressions)</tt>. For example:
--   
--   <pre>
--   select $
--     <a>from</a> \foo -&gt;
--     <a>distinctOn</a> [<a>don</a> (foo ^. FooName), <a>don</a> (foo ^. FooState)] $ do
--     ...
--   </pre>
--   
--   You can also chain different calls to <a>distinctOn</a>. The above is
--   equivalent to:
--   
--   <pre>
--   select $
--     <a>from</a> \foo -&gt;
--     <a>distinctOn</a> [<a>don</a> (foo ^. FooName)] $
--     <a>distinctOn</a> [<a>don</a> (foo ^. FooState)] $ do
--     ...
--   </pre>
--   
--   Each call to <a>distinctOn</a> adds more expressions. Calls to
--   <a>distinctOn</a> override any calls to <a>distinct</a>.
--   
--   Note that PostgreSQL requires the expressions on <tt>DISTINCT ON</tt>
--   to be the first ones to appear on a <tt>ORDER BY</tt>. This is not
--   managed automatically by esqueleto, keeping its spirit of trying to be
--   close to raw SQL.
--   
--   Supported by PostgreSQL only.
--   
--   <i>Since: 2.2.4</i>
distinctOn :: Esqueleto query expr backend => [expr DistinctOn] -> query a -> query a

-- | Erase an expression's type so that it's suitable to be used by
--   <a>distinctOn</a>.
--   
--   <i>Since: 2.2.4</i>
don :: Esqueleto query expr backend => expr (Value a) -> expr DistinctOn

-- | A convenience function that calls both <a>distinctOn</a> and
--   <a>orderBy</a>. In other words,
--   
--   <pre>
--   <a>distinctOnOrderBy</a> [asc foo, desc bar, desc quux] $ do
--     ...
--   </pre>
--   
--   is the same as:
--   
--   <pre>
--   <a>distinctOn</a> [don foo, don  bar, don  quux] $ do
--     <a>orderBy</a>  [asc foo, desc bar, desc quux]
--     ...
--   </pre>
--   
--   <i>Since: 2.2.4</i>
distinctOnOrderBy :: Esqueleto query expr backend => [expr OrderBy] -> query a -> query a

-- | <tt>ORDER BY random()</tt> clause.
--   
--   <i>Since: 1.3.10</i>
rand :: Esqueleto query expr backend => expr OrderBy

-- | <tt>HAVING</tt>.
--   
--   <i>Since: 1.2.2</i>
having :: Esqueleto query expr backend => expr (Value Bool) -> query ()

-- | Add a locking clause to the query. Please read <a>LockingKind</a>
--   documentation and your RDBMS manual.
--   
--   If multiple calls to <a>locking</a> are made on the same query, the
--   last one is used.
--   
--   <i>Since: 2.2.7</i>
locking :: Esqueleto query expr backend => LockingKind -> query ()

-- | Execute a subquery <tt>SELECT</tt> in an expression. Returns a simple
--   value so should be used only when the <tt>SELECT</tt> query is
--   guaranteed to return just one row.
sub_select :: (Esqueleto query expr backend, PersistField a) => query (expr (Value a)) -> expr (Value a)

-- | Same as <a>sub_select</a> but using <tt>SELECT DISTINCT</tt>.

-- | <i>Deprecated: Since 2.2.4: use <a>sub_select</a> and
--   <a>distinct</a>.</i>
sub_selectDistinct :: (Esqueleto query expr backend, PersistField a) => query (expr (Value a)) -> expr (Value a)

-- | Project a field of an entity.
(^.) :: (Esqueleto query expr backend, PersistEntity val, PersistField typ) => expr (Entity val) -> EntityField val typ -> expr (Value typ)

-- | Project a field of an entity that may be null.
(?.) :: (Esqueleto query expr backend, PersistEntity val, PersistField typ) => expr (Maybe (Entity val)) -> EntityField val typ -> expr (Value (Maybe typ))

-- | Lift a constant value from Haskell-land to the query.
val :: (Esqueleto query expr backend, PersistField typ) => typ -> expr (Value typ)

-- | <tt>IS NULL</tt> comparison.
isNothing :: (Esqueleto query expr backend, PersistField typ) => expr (Value (Maybe typ)) -> expr (Value Bool)

-- | Analogous to <a>Just</a>, promotes a value of type <tt>typ</tt> into
--   one of type <tt>Maybe typ</tt>. It should hold that <tt><a>val</a> .
--   Just === just . <a>val</a></tt>.
just :: Esqueleto query expr backend => expr (Value typ) -> expr (Value (Maybe typ))

-- | <tt>NULL</tt> value.
nothing :: Esqueleto query expr backend => expr (Value (Maybe typ))

-- | Join nested <a>Maybe</a>s in a <a>Value</a> into one. This is useful
--   when calling aggregate functions on nullable fields.
joinV :: Esqueleto query expr backend => expr (Value (Maybe (Maybe typ))) -> expr (Value (Maybe typ))

-- | <tt>COUNT(*)</tt> value.
countRows :: (Esqueleto query expr backend, Num a) => expr (Value a)

-- | <tt>COUNT</tt>.
count :: (Esqueleto query expr backend, Num a) => expr (Value typ) -> expr (Value a)

-- | <tt>COUNT(DISTINCT x)</tt>.
--   
--   <i>Since: 2.4.1</i>
countDistinct :: (Esqueleto query expr backend, Num a) => expr (Value typ) -> expr (Value a)
not_ :: Esqueleto query expr backend => expr (Value Bool) -> expr (Value Bool)
(==.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(>=.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(>.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(<=.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(<.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(!=.) :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (Value typ) -> expr (Value Bool)
(&&.) :: Esqueleto query expr backend => expr (Value Bool) -> expr (Value Bool) -> expr (Value Bool)
(||.) :: Esqueleto query expr backend => expr (Value Bool) -> expr (Value Bool) -> expr (Value Bool)
(+.) :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value a) -> expr (Value a)
(-.) :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value a) -> expr (Value a)
(/.) :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value a) -> expr (Value a)
(*.) :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value a) -> expr (Value a)
random_ :: (Esqueleto query expr backend, PersistField a, Num a) => expr (Value a)
round_ :: (Esqueleto query expr backend, PersistField a, Num a, PersistField b, Num b) => expr (Value a) -> expr (Value b)
ceiling_ :: (Esqueleto query expr backend, PersistField a, Num a, PersistField b, Num b) => expr (Value a) -> expr (Value b)
floor_ :: (Esqueleto query expr backend, PersistField a, Num a, PersistField b, Num b) => expr (Value a) -> expr (Value b)
sum_ :: (Esqueleto query expr backend, PersistField a, PersistField b) => expr (Value a) -> expr (Value (Maybe b))
min_ :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value (Maybe a))
max_ :: (Esqueleto query expr backend, PersistField a) => expr (Value a) -> expr (Value (Maybe a))
avg_ :: (Esqueleto query expr backend, PersistField a, PersistField b) => expr (Value a) -> expr (Value (Maybe b))

-- | Allow a number of one type to be used as one of another type via an
--   implicit cast. An explicit cast is not made, this function changes
--   only the types on the Haskell side.
--   
--   <i>Caveat</i>: Trying to use <tt>castNum</tt> from <tt>Double</tt> to
--   <tt>Int</tt> will not result in an integer, the original fractional
--   number will still be used! Use <a>round_</a>, <a>ceiling_</a> or
--   <a>floor_</a> instead.
--   
--   <i>Safety</i>: This operation is mostly safe due to the <a>Num</a>
--   constraint between the types and the fact that RDBMSs usually allow
--   numbers of different types to be used interchangeably. However, there
--   may still be issues with the query not being accepted by the RDBMS or
--   <tt>persistent</tt> not being able to parse it.
--   
--   <i>Since: 2.2.9</i>
castNum :: (Esqueleto query expr backend, Num a, Num b) => expr (Value a) -> expr (Value b)

-- | Same as <a>castNum</a>, but for nullable values.
--   
--   <i>Since: 2.2.9</i>
castNumM :: (Esqueleto query expr backend, Num a, Num b) => expr (Value (Maybe a)) -> expr (Value (Maybe b))

-- | <tt>COALESCE</tt> function. Evaluates the arguments in order and
--   returns the value of the first non-NULL expression, or NULL (Nothing)
--   otherwise. Some RDBMSs (such as SQLite) require at least two
--   arguments; please refer to the appropriate documentation.
--   
--   <i>Since: 1.4.3</i>
coalesce :: (Esqueleto query expr backend, PersistField a) => [expr (Value (Maybe a))] -> expr (Value (Maybe a))

-- | Like <tt>coalesce</tt>, but takes a non-nullable expression placed at
--   the end of the expression list, which guarantees a non-NULL result.
--   
--   <i>Since: 1.4.3</i>
coalesceDefault :: (Esqueleto query expr backend, PersistField a) => [expr (Value (Maybe a))] -> expr (Value a) -> expr (Value a)

-- | <tt>LOWER</tt> function.
lower_ :: (Esqueleto query expr backend, SqlString s) => expr (Value s) -> expr (Value s)

-- | <tt>LIKE</tt> operator.
like :: (Esqueleto query expr backend, SqlString s) => expr (Value s) -> expr (Value s) -> expr (Value Bool)

-- | <tt>ILIKE</tt> operator (case-insensitive <tt>LIKE</tt>).
--   
--   Supported by PostgreSQL only.
--   
--   <i>Since: 2.2.3</i>
ilike :: (Esqueleto query expr backend, SqlString s) => expr (Value s) -> expr (Value s) -> expr (Value Bool)

-- | The string <tt><a>%</a></tt>. May be useful while using <a>like</a>
--   and concatenation (<a>concat_</a> or <a>++.</a>, depending on your
--   database). Note that you always have to type the parenthesis, for
--   example:
--   
--   <pre>
--   name `<a>like</a>` (%) ++. <a>val</a> "John" ++. (%)
--   </pre>
(%) :: (Esqueleto query expr backend, SqlString s) => expr (Value s)

-- | The <tt>CONCAT</tt> function with a variable number of parameters.
--   Supported by MySQL and PostgreSQL.
concat_ :: (Esqueleto query expr backend, SqlString s) => [expr (Value s)] -> expr (Value s)

-- | The <tt>||</tt> string concatenation operator (named after Haskell's
--   <a>++</a> in order to avoid naming clash with <a>||.</a>). Supported
--   by SQLite and PostgreSQL.
(++.) :: (Esqueleto query expr backend, SqlString s) => expr (Value s) -> expr (Value s) -> expr (Value s)

-- | Cast a string type into <tt>Text</tt>. This function is very useful if
--   you want to use <tt>newtype</tt>s, or if you want to apply functions
--   such as <a>like</a> to strings of different types.
--   
--   <i>Safety:</i> This is a slightly unsafe function, especially if you
--   have defined your own instances of <a>SqlString</a>. Also, since
--   <a>Maybe</a> is an instance of <a>SqlString</a>, it's possible to turn
--   a nullable value into a non-nullable one. Avoid using this function if
--   possible.
castString :: (Esqueleto query expr backend, SqlString s, SqlString r) => expr (Value s) -> expr (Value r)

-- | Execute a subquery <tt>SELECT</tt> in an expression. Returns a list of
--   values.
subList_select :: (Esqueleto query expr backend, PersistField a) => query (expr (Value a)) -> expr (ValueList a)

-- | Same as <tt>sublist_select</tt> but using <tt>SELECT DISTINCT</tt>.

-- | <i>Deprecated: Since 2.2.4: use <a>subList_select</a> and
--   <a>distinct</a>.</i>
subList_selectDistinct :: (Esqueleto query expr backend, PersistField a) => query (expr (Value a)) -> expr (ValueList a)

-- | Lift a list of constant value from Haskell-land to the query.
valList :: (Esqueleto query expr backend, PersistField typ) => [typ] -> expr (ValueList typ)

-- | Same as <a>just</a> but for <a>ValueList</a>. Most of the time you
--   won't need it, though, because you can use <a>just</a> from inside
--   <a>subList_select</a> or <a>Just</a> from inside <a>valList</a>.
--   
--   <i>Since: 2.2.12</i>
justList :: Esqueleto query expr backend => expr (ValueList typ) -> expr (ValueList (Maybe typ))

-- | <tt>IN</tt> operator. For example if you want to select all
--   <tt>Person</tt>s by a list of IDs:
--   
--   <pre>
--   SELECT *
--   FROM Person
--   WHERE Person.id IN (?)
--   </pre>
--   
--   In <tt>esqueleto</tt>, we may write the same query above as:
--   
--   <pre>
--   select $
--   <a>from</a> $ \person -&gt; do
--   <a>where_</a> $ person <a>^.</a> PersonId <a>in_</a> <a>valList</a> personIds
--   return person
--   </pre>
--   
--   Where <tt>personIds</tt> is of type <tt>[Key Person]</tt>.
in_ :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (ValueList typ) -> expr (Value Bool)

-- | <tt>NOT IN</tt> operator.
notIn :: (Esqueleto query expr backend, PersistField typ) => expr (Value typ) -> expr (ValueList typ) -> expr (Value Bool)

-- | <tt>EXISTS</tt> operator. For example:
--   
--   <pre>
--   select $
--   <a>from</a> $ \person -&gt; do
--   <a>where_</a> $ <a>exists</a> $
--            <a>from</a> $ \post -&gt; do
--            <a>where_</a> (post <a>^.</a> BlogPostAuthorId <a>==.</a> person <a>^.</a> PersonId)
--   return person
--   </pre>
exists :: Esqueleto query expr backend => query () -> expr (Value Bool)

-- | <tt>NOT EXISTS</tt> operator.
notExists :: Esqueleto query expr backend => query () -> expr (Value Bool)

-- | <tt>SET</tt> clause used on <tt>UPDATE</tt>s. Note that while it's not
--   a type error to use this function on a <tt>SELECT</tt>, it will most
--   certainly result in a runtime error.
set :: (Esqueleto query expr backend, PersistEntity val) => expr (Entity val) -> [expr (Update val)] -> query ()
(=.) :: (Esqueleto query expr backend, PersistEntity val, PersistField typ) => EntityField val typ -> expr (Value typ) -> expr (Update val)
(+=.) :: (Esqueleto query expr backend, PersistEntity val, PersistField a) => EntityField val a -> expr (Value a) -> expr (Update val)
(-=.) :: (Esqueleto query expr backend, PersistEntity val, PersistField a) => EntityField val a -> expr (Value a) -> expr (Update val)
(*=.) :: (Esqueleto query expr backend, PersistEntity val, PersistField a) => EntityField val a -> expr (Value a) -> expr (Update val)
(/=.) :: (Esqueleto query expr backend, PersistEntity val, PersistField a) => EntityField val a -> expr (Value a) -> expr (Update val)

-- | Apply a <a>PersistField</a> constructor to <tt>expr Value</tt>
--   arguments.
(<#) :: Esqueleto query expr backend => (a -> b) -> expr (Value a) -> expr (Insertion b)

-- | Apply extra <tt>expr Value</tt> arguments to a <a>PersistField</a>
--   constructor
(<&>) :: Esqueleto query expr backend => expr (Insertion (a -> b)) -> expr (Value a) -> expr (Insertion b)

-- | <tt>CASE</tt> statement. For example:
--   
--   <pre>
--   select $
--   return $
--   <a>case_</a>
--      [ <a>when_</a>
--          (<a>exists</a> $
--          <a>from</a> $ \p -&gt; do
--          <a>where_</a> (p <a>^.</a> PersonName <a>==.</a> <a>val</a> "Mike"))
--        <a>then_</a>
--          (<a>sub_select</a> $
--          <a>from</a> $ \v -&gt; do
--          let sub =
--                  <a>from</a> $ \c -&gt; do
--                  <a>where_</a> (c <a>^.</a> PersonName <a>==.</a> <a>val</a> "Mike")
--                  return (c <a>^.</a> PersonFavNum)
--          <a>where_</a> (v <a>^.</a> PersonFavNum &gt;. <a>sub_select</a> sub)
--          return $ <a>count</a> (v <a>^.</a> PersonName) +. <a>val</a> (1 :: Int)) ]
--      (<a>else_</a> $ <a>val</a> (-1))
--   </pre>
--   
--   This query is a bit complicated, but basically it checks if a person
--   named <tt>"Mike"</tt> exists, and if that person does, run the
--   subquery to find out how many people have a ranking (by Fav Num)
--   higher than <tt>"Mike"</tt>.
--   
--   <b>NOTE:</b> There are a few things to be aware about this statement.
--   
--   <ul>
--   <li>This only implements the full CASE statement, it does not
--   implement the "simple" CASE statement.</li>
--   <li>At least one <a>when_</a> and <a>then_</a> is mandatory otherwise
--   it will emit an error.</li>
--   <li>The <a>else_</a> is also mandatory, unlike the SQL statement in
--   which if the <tt>ELSE</tt> is omitted it will return a <tt>NULL</tt>.
--   You can reproduce this via <a>nothing</a>.</li>
--   </ul>
--   
--   <i>Since: 2.1.2</i>
case_ :: (Esqueleto query expr backend, PersistField a) => [(expr (Value Bool), expr (Value a))] -> expr (Value a) -> expr (Value a)

-- | Convert an entity's key into another entity's.
--   
--   This function is to be used when you change an entity's <tt>Id</tt> to
--   be that of another entity. For example:
--   
--   <pre>
--   Bar
--     barNum Int
--   Foo
--     Id BarId
--     fooNum Int
--   </pre>
--   
--   For this example, declare:
--   
--   <pre>
--   instance ToBaseId Foo where
--     type BaseEnt Foo = Bar
--     toBaseIdWitness = FooKey
--   </pre>
--   
--   Now you're able to write queries such as:
--   
--   <pre>
--   <tt>select</tt> $
--   <a>from</a> $ (bar `<a>InnerJoin</a>` foo) -&gt; do
--   <a>on</a> (<a>toBaseId</a> (foo <a>^.</a> FooId) <a>==.</a> bar <a>^.</a> BarId)
--   return (bar, foo)
--   </pre>
--   
--   Note: this function may be unsafe to use in conditions not like the
--   one of the example above.
--   
--   <i>Since: 2.4.3</i>
toBaseId :: (Esqueleto query expr backend, ToBaseId ent) => expr (Value (Key ent)) -> expr (Value (Key (BaseEnt ent)))

-- | Class that enables one to use <a>toBaseId</a> to convert an entity's
--   key on a query into another (cf. <a>toBaseId</a>).
class ToBaseId ent where type family BaseEnt ent :: *
toBaseIdWitness :: ToBaseId ent => Key (BaseEnt ent) -> Key ent

-- | Syntax sugar for <a>case_</a>.
--   
--   <i>Since: 2.1.2</i>
when_ :: expr (Value Bool) -> () -> expr a -> (expr (Value Bool), expr a)

-- | Syntax sugar for <a>case_</a>.
--   
--   <i>Since: 2.1.2</i>
then_ :: ()

-- | Syntax sugar for <a>case_</a>.
--   
--   <i>Since: 2.1.2</i>
else_ :: expr a -> expr a

-- | <tt>FROM</tt> clause: bring entities into scope.
--   
--   This function internally uses two type classes in order to provide
--   some flexibility of how you may call it. Internally we refer to these
--   type classes as the two different magics.
--   
--   The innermost magic allows you to use <tt>from</tt> with the following
--   types:
--   
--   <ul>
--   <li><tt>expr (Entity val)</tt>, which brings a single entity into
--   scope.</li>
--   <li><tt>expr (Maybe (Entity val))</tt>, which brings a single entity
--   that may be <tt>NULL</tt> into scope. Used for <tt>OUTER
--   JOIN</tt>s.</li>
--   <li>A <tt>JOIN</tt> of any other two types allowed by the innermost
--   magic, where a <tt>JOIN</tt> may be an <a>InnerJoin</a>, a
--   <a>CrossJoin</a>, a <a>LeftOuterJoin</a>, a <a>RightOuterJoin</a>, or
--   a <a>FullOuterJoin</a>. The <tt>JOINs</tt> have left fixity.</li>
--   </ul>
--   
--   The outermost magic allows you to use <tt>from</tt> on any tuples of
--   types supported by innermost magic (and also tuples of tuples, and so
--   on), up to 8-tuples.
--   
--   Note that using <tt>from</tt> for the same entity twice does work and
--   corresponds to a self-join. You don't even need to use two different
--   calls to <tt>from</tt>, you may use a <tt>JOIN</tt> or a tuple.
--   
--   The following are valid examples of uses of <tt>from</tt> (the types
--   of the arguments of the lambda are inside square brackets):
--   
--   <pre>
--   <a>from</a> $ \person -&gt; ...
--   <a>from</a> $ \(person, blogPost) -&gt; ...
--   <a>from</a> $ \(p `<a>LeftOuterJoin</a>` mb) -&gt; ...
--   <a>from</a> $ \(p1 `<a>InnerJoin</a>` f `<a>InnerJoin</a>` p2) -&gt; ...
--   <a>from</a> $ \((p1 `<a>InnerJoin</a>` f) `<a>InnerJoin</a>` p2) -&gt; ...
--   </pre>
--   
--   The types of the arguments to the lambdas above are, respectively:
--   
--   <pre>
--   person
--     :: ( Esqueleto query expr backend
--        , PersistEntity Person
--        , PersistEntityBackend Person ~ backend
--        ) =&gt; expr (Entity Person)
--   (person, blogPost)
--     :: (...) =&gt; (expr (Entity Person), expr (Entity BlogPost))
--   (p `<a>LeftOuterJoin</a>` mb)
--     :: (...) =&gt; InnerJoin (expr (Entity Person)) (expr (Maybe (Entity BlogPost)))
--   (p1 `<a>InnerJoin</a>` f `<a>InnerJoin</a>` p2)
--     :: (...) =&gt; InnerJoin
--                   (InnerJoin (expr (Entity Person))
--                              (expr (Entity Follow)))
--                   (expr (Entity Person))
--   (p1 `<a>InnerJoin</a>` (f `<a>InnerJoin</a>` p2)) ::
--     :: (...) =&gt; InnerJoin
--                   (expr (Entity Person))
--                   (InnerJoin (expr (Entity Follow))
--                              (expr (Entity Person)))
--   </pre>
--   
--   Note that some backends may not support all kinds of <tt>JOIN</tt>s.
from :: From query expr backend a => (a -> query b) -> query b

-- | A single value (as opposed to a whole entity). You may use
--   <tt>(<a>^.</a>)</tt> or <tt>(<a>?.</a>)</tt> to get a <a>Value</a>
--   from an <a>Entity</a>.
data Value a
Value :: a -> Value a

-- | Unwrap a <a>Value</a>.
--   
--   <i>Since: 1.4.1</i>
unValue :: Value a -> a

-- | A list of single values. There's a limited set of functions able to
--   work with this data type (such as <a>subList_select</a>,
--   <a>valList</a>, <a>in_</a> and <a>exists</a>).
data ValueList a
ValueList :: a -> ValueList a

-- | Phantom type used by <a>orderBy</a>, <a>asc</a> and <a>desc</a>.
data OrderBy

-- | Phantom type used by <a>distinctOn</a> and <a>don</a>.
data DistinctOn

-- | Different kinds of locking clauses supported by <a>locking</a>.
--   
--   Note that each RDBMS has different locking support. The constructors
--   of this datatype specify only the <i>syntax</i> of the locking
--   mechanism, not its <i>semantics</i>. For example, even though both
--   MySQL and PostgreSQL support <a>ForUpdate</a>, there are no guarantees
--   that they will behave the same.
--   
--   <i>Since: 2.2.7</i>
data LockingKind

-- | <tt>FOR UPDATE</tt> syntax. Supported by MySQL, Oracle and PostgreSQL.
--   
--   <i>Since: 2.2.7</i>
ForUpdate :: LockingKind

-- | <tt>FOR SHARE</tt> syntax. Supported by PostgreSQL.
--   
--   <i>Since: 2.2.7</i>
ForShare :: LockingKind

-- | <tt>LOCK IN SHARE MODE</tt> syntax. Supported by MySQL.
--   
--   <i>Since: 2.2.7</i>
LockInShareMode :: LockingKind

-- | Phantom class of data types that are treated as strings by the RDBMS.
--   It has no methods because it's only used to avoid type errors such as
--   trying to concatenate integers.
--   
--   If you have a custom data type or <tt>newtype</tt>, feel free to make
--   it an instance of this class.
--   
--   <i>Since: 2.4.0</i>
class PersistField a => SqlString a

-- | Data type that represents an <tt>INNER JOIN</tt> (see
--   <a>LeftOuterJoin</a> for an example).
data InnerJoin a b
InnerJoin :: a -> b -> InnerJoin a b

-- | Data type that represents a <tt>CROSS JOIN</tt> (see
--   <a>LeftOuterJoin</a> for an example).
data CrossJoin a b
CrossJoin :: a -> b -> CrossJoin a b

-- | Data type that represents a <tt>LEFT OUTER JOIN</tt>. For example,
--   
--   <pre>
--   select $
--   <a>from</a> $ \(person `<a>LeftOuterJoin</a>` pet) -&gt;
--     ...
--   </pre>
--   
--   is translated into
--   
--   <pre>
--   SELECT ...
--   FROM Person LEFT OUTER JOIN Pet
--   ...
--   </pre>
--   
--   See also: <a>from</a>.
data LeftOuterJoin a b
LeftOuterJoin :: a -> b -> LeftOuterJoin a b

-- | Data type that represents a <tt>RIGHT OUTER JOIN</tt> (see
--   <a>LeftOuterJoin</a> for an example).
data RightOuterJoin a b
RightOuterJoin :: a -> b -> RightOuterJoin a b

-- | Data type that represents a <tt>FULL OUTER JOIN</tt> (see
--   <a>LeftOuterJoin</a> for an example).
data FullOuterJoin a b
FullOuterJoin :: a -> b -> FullOuterJoin a b

-- | Exception thrown whenever <a>on</a> is used to create an <tt>ON</tt>
--   clause but no matching <tt>JOIN</tt> is found.
data OnClauseWithoutMatchingJoinException
OnClauseWithoutMatchingJoinException :: String -> OnClauseWithoutMatchingJoinException

-- | SQL backend for <tt>esqueleto</tt> using <a>SqlPersistT</a>.
data SqlQuery a

-- | An expression on the SQL backend.
--   
--   There are many comments describing the constructors of this data type.
--   However, Haddock doesn't like GADTs, so you'll have to read them by
--   hitting "Source".
data SqlExpr a

-- | Constraint synonym for <tt>persistent</tt> entities whose backend is
--   <a>SqlPersistT</a>.
type SqlEntity ent = (PersistEntity ent, PersistEntityBackend ent ~ SqlBackend)

-- | Execute an <tt>esqueleto</tt> <tt>SELECT</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad and return a list of
--   rows.
--   
--   We've seen that <a>from</a> has some magic about which kinds of things
--   you may bring into scope. This <a>select</a> function also has some
--   magic for which kinds of things you may bring back to Haskell-land by
--   using <tt>SqlQuery</tt>'s <tt>return</tt>:
--   
--   <ul>
--   <li>You may return a <tt>SqlExpr (<a>Entity</a> v)</tt> for an entity
--   <tt>v</tt> (i.e., like the <tt>*</tt> in SQL), which is then returned
--   to Haskell-land as just <tt>Entity v</tt>.</li>
--   <li>You may return a <tt>SqlExpr (Maybe (Entity v))</tt> for an entity
--   <tt>v</tt> that may be <tt>NULL</tt>, which is then returned to
--   Haskell-land as <tt>Maybe (Entity v)</tt>. Used for <tt>OUTER
--   JOIN</tt>s.</li>
--   <li>You may return a <tt>SqlExpr (<a>Value</a> t)</tt> for a value
--   <tt>t</tt> (i.e., a single column), where <tt>t</tt> is any instance
--   of <a>PersistField</a>, which is then returned to Haskell-land as
--   <tt>Value t</tt>. You may use <tt>Value</tt> to return projections of
--   an <tt>Entity</tt> (see <tt>(<a>^.</a>)</tt> and <tt>(<a>?.</a>)</tt>)
--   or to return any other value calculated on the query (e.g.,
--   <a>countRows</a> or <a>sub_select</a>).</li>
--   </ul>
--   
--   The <tt>SqlSelect a r</tt> class has functional dependencies that
--   allow type information to flow both from <tt>a</tt> to <tt>r</tt> and
--   vice-versa. This means that you'll almost never have to give any type
--   signatures for <tt>esqueleto</tt> queries. For example, the query
--   <tt><a>select</a> $ from $ \p -&gt; return p</tt> alone is ambiguous,
--   but in the context of
--   
--   <pre>
--   do ps &lt;- <a>select</a> $
--            <a>from</a> $ \p -&gt;
--            return p
--      liftIO $ mapM_ (putStrLn . personName . entityVal) ps
--   </pre>
--   
--   we are able to infer from that single <tt>personName . entityVal</tt>
--   function composition that the <tt>p</tt> inside the query is of type
--   <tt>SqlExpr (Entity Person)</tt>.
select :: (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlPersistT m [r]

-- | Execute an <tt>esqueleto</tt> <tt>SELECT DISTINCT</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad and return a list of
--   rows.

-- | <i>Deprecated: Since 2.2.4: use <a>select</a> and <a>distinct</a>.</i>
selectDistinct :: (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlPersistT m [r]

-- | Execute an <tt>esqueleto</tt> <tt>SELECT</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad and return a
--   <a>Source</a> of rows.
selectSource :: (SqlSelect a r, MonadResource m) => SqlQuery a -> Source (SqlPersistT m) r

-- | Execute an <tt>esqueleto</tt> <tt>SELECT DISTINCT</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad and return a
--   <a>Source</a> of rows.

-- | <i>Deprecated: Since 2.2.4: use <a>selectSource</a> and
--   <a>distinct</a>.</i>
selectDistinctSource :: (SqlSelect a r, MonadResource m) => SqlQuery a -> Source (SqlPersistT m) r

-- | Execute an <tt>esqueleto</tt> <tt>DELETE</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad. Note that currently
--   there are no type checks for statements that should not appear on a
--   <tt>DELETE</tt> query.
--   
--   Example of usage:
--   
--   <pre>
--   <a>delete</a> $
--   <a>from</a> $ \appointment -&gt;
--   <a>where_</a> (appointment <a>^.</a> AppointmentDate <a>&lt;.</a> <a>val</a> now)
--   </pre>
--   
--   Unlike <a>select</a>, there is a useful way of using <a>delete</a>
--   that will lead to type ambiguities. If you want to delete all rows
--   (i.e., no <a>where_</a> clause), you'll have to use a type signature:
--   
--   <pre>
--   <a>delete</a> $
--   <a>from</a> $ \(appointment :: <a>SqlExpr</a> (<a>Entity</a> Appointment)) -&gt;
--   return ()
--   </pre>
delete :: (MonadIO m) => SqlQuery () -> SqlPersistT m ()

-- | Same as <a>delete</a>, but returns the number of rows affected.
deleteCount :: (MonadIO m) => SqlQuery () -> SqlPersistT m Int64

-- | Execute an <tt>esqueleto</tt> <tt>UPDATE</tt> query inside
--   <tt>persistent</tt>'s <a>SqlPersistT</a> monad. Note that currently
--   there are no type checks for statements that should not appear on a
--   <tt>UPDATE</tt> query.
--   
--   Example of usage:
--   
--   <pre>
--   <a>update</a> $ p -&gt; do
--   <a>set</a> p [ PersonAge <a>=.</a> <a>just</a> (<a>val</a> thisYear) -. p <a>^.</a> PersonBorn ]
--   <a>where_</a> $ isNothing (p <a>^.</a> PersonAge)
--   </pre>
update :: (MonadIO m, SqlEntity val) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlPersistT m ()

-- | Same as <a>update</a>, but returns the number of rows affected.
updateCount :: (MonadIO m, SqlEntity val) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlPersistT m Int64

-- | Insert a <a>PersistField</a> for every selected value.
--   
--   <i>Since: 2.4.2</i>
insertSelect :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlPersistT m ()

-- | Insert a <a>PersistField</a> for every selected value, return the
--   count afterward
insertSelectCount :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlPersistT m Int64

-- | Insert a <a>PersistField</a> for every unique selected value.

-- | <i>Deprecated: Since 2.2.4: use <a>insertSelect</a> and
--   <a>distinct</a>.</i>
insertSelectDistinct :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlPersistT m ()

-- | <tt>valkey i = <a>val</a> . <a>toSqlKey</a></tt>
--   (<a>https://github.com/prowdsponsor/esqueleto/issues/9</a>).
valkey :: (Esqueleto query expr backend, ToBackendKey SqlBackend entity, PersistField (Key entity)) => Int64 -> expr (Value (Key entity))

-- | <tt>valJ</tt> is like <tt>val</tt> but for something that is already a
--   <tt>Value</tt>. The use case it was written for was, given a
--   <tt>Value</tt> lift the <tt>Key</tt> for that <tt>Value</tt> into the
--   query expression in a type safe way. However, the implementation is
--   more generic than that so we call it <tt>valJ</tt>.
--   
--   Its important to note that the input entity and the output entity are
--   constrained to be the same by the type signature on the function
--   (<a>https://github.com/prowdsponsor/esqueleto/pull/69</a>).
--   
--   <i>Since: 1.4.2</i>
valJ :: (Esqueleto query expr backend, PersistField (Key entity)) => Value (Key entity) -> expr (Value (Key entity))

-- | Synonym for <a>delete</a> that does not clash with
--   <tt>esqueleto</tt>'s <a>delete</a>.
deleteKey :: (PersistStore (PersistEntityBackend val), MonadIO m, PersistEntity val) => Key val -> ReaderT (PersistEntityBackend val) m ()
