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


-- | An SQL-generating DSL targeting PostgreSQL
--   
--   An SQL-generating DSL targeting PostgreSQL. Allows Postgres queries to
--   be written within Haskell in a typesafe and composable fashion.
@package opaleye
@version 0.6.7003.1

module Opaleye.Internal.HaskellDB.Sql
data SqlTable
SqlTable :: Maybe String -> String -> SqlTable
[sqlTableSchemaName] :: SqlTable -> Maybe String
[sqlTableName] :: SqlTable -> String
newtype SqlColumn
SqlColumn :: String -> SqlColumn

-- | A valid SQL name for a parameter.
type SqlName = String
data SqlOrderNulls
SqlNullsFirst :: SqlOrderNulls
SqlNullsLast :: SqlOrderNulls
data SqlOrderDirection
SqlAsc :: SqlOrderDirection
SqlDesc :: SqlOrderDirection
data SqlOrder
SqlOrder :: SqlOrderDirection -> SqlOrderNulls -> SqlOrder
[sqlOrderDirection] :: SqlOrder -> SqlOrderDirection
[sqlOrderNulls] :: SqlOrder -> SqlOrderNulls
data SqlRangeBound
Inclusive :: SqlExpr -> SqlRangeBound
Exclusive :: SqlExpr -> SqlRangeBound
PosInfinity :: SqlRangeBound
NegInfinity :: SqlRangeBound
data SqlDistinct
SqlDistinct :: SqlDistinct
SqlNotDistinct :: SqlDistinct

-- | Expressions in SQL statements.
data SqlExpr
ColumnSqlExpr :: SqlColumn -> SqlExpr
CompositeSqlExpr :: SqlExpr -> String -> SqlExpr
BinSqlExpr :: String -> SqlExpr -> SqlExpr -> SqlExpr
SubscriptSqlExpr :: SqlExpr -> SqlExpr -> SqlExpr
PrefixSqlExpr :: String -> SqlExpr -> SqlExpr
PostfixSqlExpr :: String -> SqlExpr -> SqlExpr
FunSqlExpr :: String -> [SqlExpr] -> SqlExpr

-- | Aggregate functions separate from normal functions.
AggrFunSqlExpr :: String -> [SqlExpr] -> [(SqlExpr, SqlOrder)] -> SqlDistinct -> SqlExpr
ConstSqlExpr :: String -> SqlExpr
CaseSqlExpr :: NonEmpty (SqlExpr, SqlExpr) -> SqlExpr -> SqlExpr
ListSqlExpr :: NonEmpty SqlExpr -> SqlExpr
ParamSqlExpr :: Maybe SqlName -> SqlExpr -> SqlExpr
PlaceHolderSqlExpr :: SqlExpr
ParensSqlExpr :: SqlExpr -> SqlExpr
CastSqlExpr :: String -> SqlExpr -> SqlExpr
DefaultSqlExpr :: SqlExpr
ArraySqlExpr :: [SqlExpr] -> SqlExpr
RangeSqlExpr :: String -> SqlRangeBound -> SqlRangeBound -> SqlExpr

-- | Data type for SQL UPDATE statements.
data SqlUpdate
SqlUpdate :: SqlTable -> [(SqlColumn, SqlExpr)] -> [SqlExpr] -> SqlUpdate

-- | Data type for SQL DELETE statements.
data SqlDelete
SqlDelete :: SqlTable -> [SqlExpr] -> SqlDelete
data OnConflict

-- | <pre>
--   ON CONFLICT DO NOTHING
--   </pre>
DoNothing :: OnConflict
data SqlInsert
SqlInsert :: SqlTable -> [SqlColumn] -> NonEmpty [SqlExpr] -> Maybe OnConflict -> SqlInsert
instance GHC.Show.Show Opaleye.Internal.HaskellDB.Sql.SqlRangeBound
instance GHC.Show.Show Opaleye.Internal.HaskellDB.Sql.SqlExpr
instance GHC.Show.Show Opaleye.Internal.HaskellDB.Sql.SqlDistinct
instance GHC.Show.Show Opaleye.Internal.HaskellDB.Sql.SqlOrder
instance GHC.Show.Show Opaleye.Internal.HaskellDB.Sql.SqlOrderDirection
instance GHC.Show.Show Opaleye.Internal.HaskellDB.Sql.SqlOrderNulls
instance GHC.Show.Show Opaleye.Internal.HaskellDB.Sql.SqlColumn
instance GHC.Show.Show Opaleye.Internal.HaskellDB.Sql.SqlTable

module Opaleye.Internal.HaskellDB.Sql.Print
deliteral :: SqlExpr -> SqlExpr
ppUpdate :: SqlUpdate -> Doc
ppDelete :: SqlDelete -> Doc
ppInsert :: SqlInsert -> Doc
ppSqlExpr :: SqlExpr -> Doc
ppWhere :: [SqlExpr] -> Doc
ppGroupBy :: [SqlExpr] -> Doc
ppOrderBy :: [(SqlExpr, SqlOrder)] -> Doc
ppTable :: SqlTable -> Doc
ppAs :: Maybe String -> Doc -> Doc
commaV :: (a -> Doc) -> [a] -> Doc
commaH :: (a -> Doc) -> [a] -> Doc

module Opaleye.Internal.Helpers
(.:) :: (r -> z) -> (a -> b -> r) -> a -> b -> z
infixr 8 .:
(.:.) :: (r -> z) -> (a -> b -> c -> r) -> a -> b -> c -> z
infixr 8 .:.
(.::) :: (r -> z) -> (a -> b -> c -> d -> r) -> a -> b -> c -> d -> z
infixr 8 .::
(.::.) :: (r -> z) -> (a -> b -> c -> d -> e -> r) -> a -> b -> c -> d -> e -> z
infixr 8 .::.

module Opaleye.Internal.Tag

-- | Tag is for use as a source of unique IDs in QueryArr
newtype Tag
UnsafeTag :: Int -> Tag
start :: Tag
next :: Tag -> Tag
unsafeUnTag :: Tag -> Int
tagWith :: Tag -> String -> String
instance GHC.Show.Show Opaleye.Internal.Tag.Tag
instance GHC.Read.Read Opaleye.Internal.Tag.Tag

module Opaleye.Internal.HaskellDB.PrimQuery
type TableName = String
type Attribute = String
type Name = String
type Scheme = [Attribute]
type Assoc = [(Attribute, PrimExpr)]
data Symbol
Symbol :: String -> Tag -> Symbol
data PrimExpr
AttrExpr :: Symbol -> PrimExpr
BaseTableAttrExpr :: Attribute -> PrimExpr

-- | Composite Type Query
CompositeExpr :: PrimExpr -> Attribute -> PrimExpr
BinExpr :: BinOp -> PrimExpr -> PrimExpr -> PrimExpr
UnExpr :: UnOp -> PrimExpr -> PrimExpr
AggrExpr :: AggrDistinct -> AggrOp -> PrimExpr -> [OrderExpr] -> PrimExpr
ConstExpr :: Literal -> PrimExpr
CaseExpr :: [(PrimExpr, PrimExpr)] -> PrimExpr -> PrimExpr
ListExpr :: NonEmpty PrimExpr -> PrimExpr
ParamExpr :: Maybe Name -> PrimExpr -> PrimExpr
FunExpr :: Name -> [PrimExpr] -> PrimExpr

-- | Cast an expression to a given type.
CastExpr :: Name -> PrimExpr -> PrimExpr
DefaultInsertExpr :: PrimExpr

-- | ARRAY[..]
ArrayExpr :: [PrimExpr] -> PrimExpr
RangeExpr :: String -> BoundExpr -> BoundExpr -> PrimExpr
ArrayIndex :: PrimExpr -> PrimExpr -> PrimExpr
data Literal
NullLit :: Literal

-- | represents a default value
DefaultLit :: Literal
BoolLit :: Bool -> Literal
StringLit :: String -> Literal
ByteStringLit :: ByteString -> Literal
IntegerLit :: Integer -> Literal
DoubleLit :: Double -> Literal
NumericLit :: Scientific -> Literal

-- | used for hacking in custom SQL
OtherLit :: String -> Literal
data BinOp
(:==) :: BinOp
(:<) :: BinOp
(:<=) :: BinOp
(:>) :: BinOp
(:>=) :: BinOp
(:<>) :: BinOp
OpAnd :: BinOp
OpOr :: BinOp
OpLike :: BinOp
OpILike :: BinOp
OpIn :: BinOp
OpOther :: String -> BinOp
(:||) :: BinOp
(:+) :: BinOp
(:-) :: BinOp
(:*) :: BinOp
(:/) :: BinOp
OpMod :: BinOp
(:~) :: BinOp
(:&) :: BinOp
(:|) :: BinOp
(:^) :: BinOp
(:=) :: BinOp
OpAtTimeZone :: BinOp
(:->) :: BinOp
(:->>) :: BinOp
(:#>) :: BinOp
(:#>>) :: BinOp
(:@>) :: BinOp
(:<@) :: BinOp
(:?) :: BinOp
(:?|) :: BinOp
(:?&) :: BinOp
(:&&) :: BinOp
(:<<) :: BinOp
(:>>) :: BinOp
(:&<) :: BinOp
(:&>) :: BinOp
(:-|-) :: BinOp
data UnOp
OpNot :: UnOp
OpIsNull :: UnOp
OpIsNotNull :: UnOp
OpLength :: UnOp
OpAbs :: UnOp
OpNegate :: UnOp
OpLower :: UnOp
OpUpper :: UnOp
UnOpOther :: String -> UnOp
data AggrOp
AggrCount :: AggrOp
AggrSum :: AggrOp
AggrAvg :: AggrOp
AggrMin :: AggrOp
AggrMax :: AggrOp
AggrStdDev :: AggrOp
AggrStdDevP :: AggrOp
AggrVar :: AggrOp
AggrVarP :: AggrOp
AggrBoolOr :: AggrOp
AggrBoolAnd :: AggrOp
AggrArr :: AggrOp
AggrStringAggr :: PrimExpr -> AggrOp
AggrOther :: String -> AggrOp
data AggrDistinct
AggrDistinct :: AggrDistinct
AggrAll :: AggrDistinct
data OrderExpr
OrderExpr :: OrderOp -> PrimExpr -> OrderExpr
data OrderNulls
NullsFirst :: OrderNulls
NullsLast :: OrderNulls
data OrderDirection
OpAsc :: OrderDirection
OpDesc :: OrderDirection
data OrderOp
OrderOp :: OrderDirection -> OrderNulls -> OrderOp
[orderDirection] :: OrderOp -> OrderDirection
[orderNulls] :: OrderOp -> OrderNulls
data BoundExpr
Inclusive :: PrimExpr -> BoundExpr
Exclusive :: PrimExpr -> BoundExpr
PosInfinity :: BoundExpr
NegInfinity :: BoundExpr
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.AggrOp
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.AggrOp
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.OrderExpr
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.OrderExpr
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.PrimExpr
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.PrimExpr
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.BoundExpr
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.BoundExpr
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.OrderOp
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.OrderOp
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.OrderDirection
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.OrderDirection
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.OrderNulls
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.OrderNulls
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.AggrDistinct
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.AggrDistinct
instance GHC.Classes.Eq Opaleye.Internal.HaskellDB.PrimQuery.AggrDistinct
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.UnOp
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.UnOp
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.BinOp
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.BinOp
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.Literal
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.Literal
instance GHC.Show.Show Opaleye.Internal.HaskellDB.PrimQuery.Symbol
instance GHC.Read.Read Opaleye.Internal.HaskellDB.PrimQuery.Symbol

module Opaleye.Internal.PrimQuery
data LimitOp
LimitOp :: Int -> LimitOp
OffsetOp :: Int -> LimitOp
LimitOffsetOp :: Int -> Int -> LimitOp
data BinOp
Except :: BinOp
ExceptAll :: BinOp
Union :: BinOp
UnionAll :: BinOp
Intersect :: BinOp
IntersectAll :: BinOp
data JoinType
LeftJoin :: JoinType
RightJoin :: JoinType
FullJoin :: JoinType
data TableIdentifier
TableIdentifier :: Maybe String -> String -> TableIdentifier
[tiSchemaName] :: TableIdentifier -> Maybe String
[tiTableName] :: TableIdentifier -> String
tiToSqlTable :: TableIdentifier -> SqlTable
type Bindings a = [(Symbol, a)]
data PrimQuery' a
Unit :: PrimQuery' a
Empty :: a -> PrimQuery' a
BaseTable :: TableIdentifier -> Bindings PrimExpr -> PrimQuery' a
Product :: NonEmpty (PrimQuery' a) -> [PrimExpr] -> PrimQuery' a
Aggregate :: Bindings (Maybe (AggrOp, [OrderExpr], AggrDistinct), PrimExpr) -> PrimQuery' a -> PrimQuery' a

-- | Represents both <tt>DISTINCT ON</tt> and <tt>ORDER BY</tt> clauses. In
--   order to represent valid SQL only, <tt>DISTINCT ON</tt> expressions
--   are always interpreted as the first <tt>ORDER BY</tt>s when present,
--   preceding any in the provided list. See <a>distinctOnOrderBy</a>.
DistinctOnOrderBy :: Maybe (NonEmpty PrimExpr) -> [OrderExpr] -> PrimQuery' a -> PrimQuery' a
Limit :: LimitOp -> PrimQuery' a -> PrimQuery' a
Join :: JoinType -> PrimExpr -> Bindings PrimExpr -> Bindings PrimExpr -> PrimQuery' a -> PrimQuery' a -> PrimQuery' a
Exists :: Bool -> PrimQuery' a -> PrimQuery' a -> PrimQuery' a
Values :: [Symbol] -> NonEmpty [PrimExpr] -> PrimQuery' a
Binary :: BinOp -> Bindings (PrimExpr, PrimExpr) -> (PrimQuery' a, PrimQuery' a) -> PrimQuery' a
Label :: String -> PrimQuery' a -> PrimQuery' a
RelExpr :: PrimExpr -> Bindings PrimExpr -> PrimQuery' a
type PrimQuery = PrimQuery' ()
type PrimQueryFold = PrimQueryFold' ()
data PrimQueryFold' a p
PrimQueryFold :: p -> (a -> p) -> (TableIdentifier -> Bindings PrimExpr -> p) -> (NonEmpty p -> [PrimExpr] -> p) -> (Bindings (Maybe (AggrOp, [OrderExpr], AggrDistinct), PrimExpr) -> p -> p) -> (Maybe (NonEmpty PrimExpr) -> [OrderExpr] -> p -> p) -> (LimitOp -> p -> p) -> (JoinType -> PrimExpr -> Bindings PrimExpr -> Bindings PrimExpr -> p -> p -> p) -> (Bool -> p -> p -> p) -> ([Symbol] -> NonEmpty [PrimExpr] -> p) -> (BinOp -> Bindings (PrimExpr, PrimExpr) -> (p, p) -> p) -> (String -> p -> p) -> (PrimExpr -> Bindings PrimExpr -> p) -> PrimQueryFold' a p
[unit] :: PrimQueryFold' a p -> p
[empty] :: PrimQueryFold' a p -> a -> p
[baseTable] :: PrimQueryFold' a p -> TableIdentifier -> Bindings PrimExpr -> p
[product] :: PrimQueryFold' a p -> NonEmpty p -> [PrimExpr] -> p
[aggregate] :: PrimQueryFold' a p -> Bindings (Maybe (AggrOp, [OrderExpr], AggrDistinct), PrimExpr) -> p -> p
[distinctOnOrderBy] :: PrimQueryFold' a p -> Maybe (NonEmpty PrimExpr) -> [OrderExpr] -> p -> p
[limit] :: PrimQueryFold' a p -> LimitOp -> p -> p
[join] :: PrimQueryFold' a p -> JoinType -> PrimExpr -> Bindings PrimExpr -> Bindings PrimExpr -> p -> p -> p
[existsf] :: PrimQueryFold' a p -> Bool -> p -> p -> p
[values] :: PrimQueryFold' a p -> [Symbol] -> NonEmpty [PrimExpr] -> p
[binary] :: PrimQueryFold' a p -> BinOp -> Bindings (PrimExpr, PrimExpr) -> (p, p) -> p
[label] :: PrimQueryFold' a p -> String -> p -> p

-- | A relation-valued expression
[relExpr] :: PrimQueryFold' a p -> PrimExpr -> Bindings PrimExpr -> p
primQueryFoldDefault :: PrimQueryFold' a (PrimQuery' a)
foldPrimQuery :: PrimQueryFold' a p -> PrimQuery' a -> p
times :: PrimQuery -> PrimQuery -> PrimQuery
restrict :: PrimExpr -> PrimQuery -> PrimQuery
exists :: PrimQuery -> PrimQuery -> PrimQuery
notExists :: PrimQuery -> PrimQuery -> PrimQuery
isUnit :: PrimQuery' a -> Bool
instance GHC.Show.Show a => GHC.Show.Show (Opaleye.Internal.PrimQuery.PrimQuery' a)
instance GHC.Show.Show Opaleye.Internal.PrimQuery.TableIdentifier
instance GHC.Show.Show Opaleye.Internal.PrimQuery.JoinType
instance GHC.Show.Show Opaleye.Internal.PrimQuery.BinOp
instance GHC.Show.Show Opaleye.Internal.PrimQuery.LimitOp

module Opaleye.Internal.Optimize
optimize :: PrimQuery' a -> PrimQuery' a
removeUnit :: PrimQuery' a -> PrimQuery' a
mergeProduct :: PrimQuery' a -> PrimQuery' a
removeEmpty :: PrimQuery' a -> Maybe (PrimQuery' b)

module Opaleye.Internal.Label
label' :: String -> (a, PrimQuery, Tag) -> (a, PrimQuery, Tag)

module Opaleye.Internal.PackMap

-- | A <a>PackMap</a> <tt>a</tt> <tt>b</tt> <tt>s</tt> <tt>t</tt> encodes
--   how an <tt>s</tt> contains an updatable sequence of <tt>a</tt> inside
--   it. Each <tt>a</tt> in the sequence can be updated to a <tt>b</tt>
--   (and the <tt>s</tt> changes to a <tt>t</tt> to reflect this change of
--   type).
--   
--   <a>PackMap</a> is just like a <tt>Traversal</tt> from the lens
--   package. <a>PackMap</a> has a different order of arguments to
--   <tt>Traversal</tt> because it typically needs to be made a
--   <a>Profunctor</a> (and indeed <a>ProductProfunctor</a>) in <tt>s</tt>
--   and <tt>t</tt>. It is unclear at this point whether we want the same
--   <tt>Traversal</tt> laws to hold or not. Our use cases may be much more
--   general.
newtype PackMap a b s t
PackMap :: (forall f. Applicative f => (a -> f b) -> s -> f t) -> PackMap a b s t

-- | Replaces the targeted occurences of <tt>a</tt> in <tt>s</tt> with
--   <tt>b</tt> (changing the <tt>s</tt> to a <tt>t</tt> in the process).
--   This can be done via an <a>Applicative</a> action.
--   
--   <a>traversePM</a> is just like <tt>traverse</tt> from the
--   <tt>lens</tt> package. <a>traversePM</a> used to be called
--   <tt>packmap</tt>.
traversePM :: Applicative f => PackMap a b s t -> (a -> f b) -> s -> f t

-- | Modify the targeted occurrences of <tt>a</tt> in <tt>s</tt> with
--   <tt>b</tt> (changing the <tt>s</tt> to a <tt>t</tt> in the process).
--   
--   <a>overPM</a> is just like <tt>over</tt> from the <tt>lens</tt>
--   pacakge.
overPM :: PackMap a b s t -> (a -> b) -> s -> t

-- | A helpful monad for writing columns in the AST
type PM a = State (a, Int)
new :: PM a String
write :: a -> PM [a] ()
run :: PM [a] r -> (r, [a])

-- | Make a fresh name for an input value (the variable <tt>primExpr</tt>
--   type is typically actually a <a>PrimExpr</a>) based on the supplied
--   function and the unique <a>Tag</a> that is used as part of our
--   <tt>QueryArr</tt>.
--   
--   Add the fresh name and the input value it refers to to the list in the
--   state parameter.
extractAttrPE :: (primExpr -> String -> String) -> Tag -> primExpr -> PM [(Symbol, primExpr)] PrimExpr

-- | As <a>extractAttrPE</a> but ignores the <tt>primExpr</tt> when making
--   the fresh column name and just uses the supplied <a>String</a> and
--   <a>Tag</a>.
extractAttr :: String -> Tag -> primExpr -> PM [(Symbol, primExpr)] PrimExpr
eitherFunction :: (SumProfunctor p, Functor f) => p a (f b) -> p a' (f b') -> p (Either a a') (f (Either b b'))

-- | Like <a>iso</a>. In practice it won't actually be used as an
--   isomorphism, but it seems to be appropriate anyway.
iso :: (s -> a) -> (b -> t) -> PackMap a b s t
instance GHC.Base.Functor (Opaleye.Internal.PackMap.PackMap a b s)
instance GHC.Base.Applicative (Opaleye.Internal.PackMap.PackMap a b s)
instance Data.Profunctor.Unsafe.Profunctor (Opaleye.Internal.PackMap.PackMap a b)
instance Data.Profunctor.Product.Class.ProductProfunctor (Opaleye.Internal.PackMap.PackMap a b)
instance Data.Profunctor.Product.Class.SumProfunctor (Opaleye.Internal.PackMap.PackMap a b)

module Opaleye.Internal.HaskellDB.Sql.Generate
data SqlGenerator
SqlGenerator :: (SqlTable -> [PrimExpr] -> Assoc -> SqlUpdate) -> (SqlTable -> [PrimExpr] -> SqlDelete) -> (SqlTable -> [Attribute] -> NonEmpty [PrimExpr] -> Maybe OnConflict -> SqlInsert) -> (PrimExpr -> SqlExpr) -> (Literal -> String) -> (String -> String) -> SqlGenerator
[sqlUpdate] :: SqlGenerator -> SqlTable -> [PrimExpr] -> Assoc -> SqlUpdate
[sqlDelete] :: SqlGenerator -> SqlTable -> [PrimExpr] -> SqlDelete
[sqlInsert] :: SqlGenerator -> SqlTable -> [Attribute] -> NonEmpty [PrimExpr] -> Maybe OnConflict -> SqlInsert
[sqlExpr] :: SqlGenerator -> PrimExpr -> SqlExpr
[sqlLiteral] :: SqlGenerator -> Literal -> String

-- | Turn a string into a quoted string. Quote characters and any escaping
--   are handled by this function.
[sqlQuote] :: SqlGenerator -> String -> String

module Opaleye.Internal.HaskellDB.Sql.Default
mkSqlGenerator :: SqlGenerator -> SqlGenerator
defaultSqlGenerator :: SqlGenerator
toSqlOrder :: SqlGenerator -> OrderExpr -> (SqlExpr, SqlOrder)
toSqlColumn :: Attribute -> SqlColumn
toSqlAssoc :: SqlGenerator -> Assoc -> [(SqlColumn, SqlExpr)]
defaultSqlUpdate :: SqlGenerator -> SqlTable -> [PrimExpr] -> Assoc -> SqlUpdate
defaultSqlInsert :: SqlGenerator -> SqlTable -> [Attribute] -> NonEmpty [PrimExpr] -> Maybe OnConflict -> SqlInsert
defaultSqlDelete :: SqlGenerator -> SqlTable -> [PrimExpr] -> SqlDelete
defaultSqlExpr :: SqlGenerator -> PrimExpr -> SqlExpr
showBinOp :: BinOp -> String
data UnOpType
UnOpFun :: UnOpType
UnOpPrefix :: UnOpType
UnOpPostfix :: UnOpType
sqlUnOp :: UnOp -> (String, UnOpType)
showAggrOp :: AggrOp -> String
defaultSqlLiteral :: SqlGenerator -> Literal -> String
defaultSqlQuote :: SqlGenerator -> String -> String

-- | Quote a string and escape characters that need escaping We use
--   Postgres "escape strings", i.e. strings prefixed with E, to ensure
--   that escaping with backslash is valid.
quote :: String -> String

-- | Escape characters that need escaping
escape :: Char -> String

-- | Quote binary literals using Postgresql's hex format.
binQuote :: ByteString -> String

module Opaleye.Internal.Sql
data Select
SelectFrom :: From -> Select
Table :: SqlTable -> Select

-- | A relation-valued expression
RelExpr :: SqlExpr -> Select
SelectJoin :: Join -> Select
SelectValues :: Values -> Select
SelectBinary :: Binary -> Select
SelectLabel :: Label -> Select
SelectExists :: Exists -> Select
data SelectAttrs
Star :: SelectAttrs
SelectAttrs :: NonEmpty (SqlExpr, Maybe SqlColumn) -> SelectAttrs
SelectAttrsStar :: NonEmpty (SqlExpr, Maybe SqlColumn) -> SelectAttrs
data From
From :: SelectAttrs -> [Select] -> [SqlExpr] -> Maybe (NonEmpty SqlExpr) -> [(SqlExpr, SqlOrder)] -> Maybe (NonEmpty SqlExpr) -> Maybe Int -> Maybe Int -> From
[attrs] :: From -> SelectAttrs
[tables] :: From -> [Select]
[criteria] :: From -> [SqlExpr]
[groupBy] :: From -> Maybe (NonEmpty SqlExpr)
[orderBy] :: From -> [(SqlExpr, SqlOrder)]
[distinctOn] :: From -> Maybe (NonEmpty SqlExpr)
[limit] :: From -> Maybe Int
[offset] :: From -> Maybe Int
data Join
Join :: JoinType -> (Select, Select) -> SqlExpr -> Join
[jJoinType] :: Join -> JoinType
[jTables] :: Join -> (Select, Select)
[jCond] :: Join -> SqlExpr
data Values
Values :: SelectAttrs -> [[SqlExpr]] -> Values
[vAttrs] :: Values -> SelectAttrs
[vValues] :: Values -> [[SqlExpr]]
data Binary
Binary :: BinOp -> Select -> Select -> Binary
[bOp] :: Binary -> BinOp
[bSelect1] :: Binary -> Select
[bSelect2] :: Binary -> Select
data JoinType
LeftJoin :: JoinType
RightJoin :: JoinType
FullJoin :: JoinType
data BinOp
Except :: BinOp
ExceptAll :: BinOp
Union :: BinOp
UnionAll :: BinOp
Intersect :: BinOp
IntersectAll :: BinOp
data Label
Label :: String -> Select -> Label
[lLabel] :: Label -> String
[lSelect] :: Label -> Select
data Returning a
Returning :: a -> NonEmpty SqlExpr -> Returning a
data Exists
Exists :: Bool -> Select -> Select -> Exists
[existsBool] :: Exists -> Bool
[existsTable] :: Exists -> Select
[existsCriteria] :: Exists -> Select
sqlQueryGenerator :: PrimQueryFold' Void Select
exists :: Bool -> Select -> Select -> Select
sql :: ([PrimExpr], PrimQuery' Void, Tag) -> Select
unit :: Select
empty :: Void -> select
baseTable :: TableIdentifier -> [(Symbol, PrimExpr)] -> Select
product :: NonEmpty Select -> [PrimExpr] -> Select
aggregate :: [(Symbol, (Maybe (AggrOp, [OrderExpr], AggrDistinct), PrimExpr))] -> Select -> Select
aggrExpr :: Maybe (AggrOp, [OrderExpr], AggrDistinct) -> PrimExpr -> PrimExpr
distinctOnOrderBy :: Maybe (NonEmpty PrimExpr) -> [OrderExpr] -> Select -> Select
limit_ :: LimitOp -> Select -> Select
join :: JoinType -> PrimExpr -> Bindings PrimExpr -> Bindings PrimExpr -> Select -> Select -> Select
values :: [Symbol] -> NonEmpty [PrimExpr] -> Select
binary :: BinOp -> [(Symbol, (PrimExpr, PrimExpr))] -> (Select, Select) -> Select
joinType :: JoinType -> JoinType
binOp :: BinOp -> BinOp
newSelect :: From
sqlExpr :: PrimExpr -> SqlExpr
sqlBinding :: (Symbol, PrimExpr) -> (SqlExpr, Maybe SqlColumn)
ensureColumns :: [(SqlExpr, Maybe a)] -> NonEmpty (SqlExpr, Maybe a)

-- | For ensuring that we have at least one column in a SELECT or RETURNING
ensureColumnsGen :: (SqlExpr -> a) -> [a] -> NonEmpty a
label :: String -> Select -> Select
relExpr :: PrimExpr -> [(Symbol, PrimExpr)] -> Select
instance GHC.Show.Show Opaleye.Internal.Sql.From
instance GHC.Show.Show Opaleye.Internal.Sql.Join
instance GHC.Show.Show Opaleye.Internal.Sql.Binary
instance GHC.Show.Show Opaleye.Internal.Sql.Label
instance GHC.Show.Show Opaleye.Internal.Sql.Select
instance GHC.Show.Show Opaleye.Internal.Sql.Exists
instance GHC.Show.Show Opaleye.Internal.Sql.BinOp
instance GHC.Show.Show Opaleye.Internal.Sql.JoinType
instance GHC.Show.Show Opaleye.Internal.Sql.Values
instance GHC.Show.Show Opaleye.Internal.Sql.SelectAttrs

module Opaleye.Internal.Print
type TableAlias = String
ppSql :: Select -> Doc
ppDistinctOn :: Maybe (NonEmpty SqlExpr) -> Doc
ppSelectFrom :: From -> Doc
ppSelectJoin :: Join -> Doc
ppSelectValues :: Values -> Doc
ppSelectBinary :: Binary -> Doc
ppSelectLabel :: Label -> Doc
ppSelectExists :: Exists -> Doc
ppJoinType :: JoinType -> Doc
ppAttrs :: SelectAttrs -> Doc
nameAs :: (SqlExpr, Maybe SqlColumn) -> Doc
ppTables :: [Select] -> Doc
tableAlias :: Int -> Select -> (TableAlias, Select)
ppTable :: (TableAlias, Select) -> Doc
ppGroupBy :: Maybe (NonEmpty SqlExpr) -> Doc
ppLimit :: Maybe Int -> Doc
ppOffset :: Maybe Int -> Doc
ppValues :: [[SqlExpr]] -> Doc
ppValuesRow :: [SqlExpr] -> Doc
ppBinOp :: BinOp -> Doc
ppInsertReturning :: Returning SqlInsert -> Doc
ppUpdateReturning :: Returning SqlUpdate -> Doc

module Opaleye.Internal.Column

-- | A column of a <tt>Query</tt>, of type <tt>pgType</tt>. For example
--   <a>Column</a> <tt>PGInt4</tt> is an <tt>int4</tt> column and a
--   <a>Column</a> <tt>PGText</tt> is a <tt>text</tt> column.
--   
--   Do not use the <a>Show</a> instance of <a>Column</a>. It is considered
--   deprecated and will be removed in version 0.7.
newtype Column pgType
Column :: PrimExpr -> Column pgType

-- | Only used within a <a>Column</a>, to indicate that it can be
--   <tt>NULL</tt>. For example, a <a>Column</a> (<a>Nullable</a>
--   <tt>PGText</tt>) can be <tt>NULL</tt> but a <a>Column</a>
--   <tt>PGText</tt> cannot.
data Nullable a
Nullable :: Nullable a
unColumn :: Column a -> PrimExpr

-- | Treat a <a>Column</a> as though it were of a different type. If such a
--   treatment is not valid then Postgres may fail with an error at SQL run
--   time.
unsafeCoerceColumn :: Column a -> Column b

-- | Cast a column to any other type. Implements Postgres's <tt>::</tt> or
--   <tt>CAST( ... AS ... )</tt> operations. This is safe for some
--   conversions, such as uuid to text.
unsafeCast :: String -> Column a -> Column b
unsafeCompositeField :: Column a -> String -> Column b
binOp :: BinOp -> Column a -> Column b -> Column c
unOp :: UnOp -> Column a -> Column b
unsafeCase_ :: [(Column pgBool, Column a)] -> Column a -> Column a
unsafeIfThenElse :: Column pgBool -> Column a -> Column a -> Column a
unsafeGt :: Column a -> Column a -> Column pgBool
unsafeEq :: Column a -> Column a -> Column pgBool
class PGNum a
pgFromInteger :: PGNum a => Integer -> Column a
sqlFromInteger :: PGNum a => Integer -> Column a
type SqlNum = PGNum
class PGFractional a
pgFromRational :: PGFractional a => Rational -> Column a
sqlFromRational :: PGFractional a => Rational -> Column a
type SqlFractional = PGFractional

-- | A dummy typeclass whose instances support integral operations.
class PGIntegral a
type SqlIntegral = PGIntegral
class PGString a
pgFromString :: PGString a => String -> Column a
sqlFromString :: PGString a => String -> Column a
type SqlString = PGString
instance GHC.Show.Show (Opaleye.Internal.Column.Column pgType)
instance Opaleye.Internal.Column.SqlString a => Data.String.IsString (Opaleye.Internal.Column.Column a)
instance (Opaleye.Internal.Column.SqlNum a, Opaleye.Internal.Column.SqlFractional a) => GHC.Real.Fractional (Opaleye.Internal.Column.Column a)
instance Opaleye.Internal.Column.SqlNum a => GHC.Num.Num (Opaleye.Internal.Column.Column a)

module Opaleye.Internal.PGTypes
unsafePgFormatTime :: FormatTime t => Name -> String -> t -> Column c
literalColumn :: Literal -> Column a
castToType :: Name -> String -> Column c
strictDecodeUtf8 :: ByteString -> String
lazyDecodeUtf8 :: ByteString -> String

module Opaleye.Map
type family Map f x


-- | Postgres types and functions to create <a>Column</a>s of those types.
--   You may find it more convenient to use <a>Opaleye.Constant</a>
--   instead.
module Opaleye.PGTypes
data PGRange a
data PGJsonb
data PGJson
data PGBytea
data PGArray a
data PGCitext
data PGUuid
data PGTimestamptz
data PGTimestamp
data PGTime
data PGText
data PGNumeric
data PGInt2
data PGInt4
data PGInt8
data PGFloat8
data PGFloat4
data PGDate
data PGBool
class IsSqlType pgType => IsRangeType pgType
showRangeType :: IsRangeType pgType => proxy pgType -> String
class IsSqlType sqlType

-- | <i>Deprecated: Use <a>showSqlType</a> instead. <a>showPGType</a> will
--   be removed in version 0.7.</i>
showPGType :: IsSqlType sqlType => proxy sqlType -> String
showSqlType :: IsSqlType sqlType => proxy sqlType -> String
pgString :: String -> Column PGText
pgLazyByteString :: ByteString -> Column PGBytea
pgStrictByteString :: ByteString -> Column PGBytea
pgStrictText :: Text -> Column PGText
pgLazyText :: Text -> Column PGText
pgNumeric :: Scientific -> Column PGNumeric
pgInt4 :: Int -> Column PGInt4
pgInt8 :: Int64 -> Column PGInt8
pgDouble :: Double -> Column PGFloat8
pgBool :: Bool -> Column PGBool
pgUUID :: UUID -> Column PGUuid
pgDay :: Day -> Column PGDate
pgUTCTime :: UTCTime -> Column PGTimestamptz
pgLocalTime :: LocalTime -> Column PGTimestamp
pgZonedTime :: ZonedTime -> Column PGTimestamptz
pgTimeOfDay :: TimeOfDay -> Column PGTime
pgCiStrictText :: CI Text -> Column PGCitext
pgCiLazyText :: CI Text -> Column PGCitext
pgJSON :: String -> Column PGJson
pgStrictJSON :: ByteString -> Column PGJson
pgLazyJSON :: ByteString -> Column PGJson
pgValueJSON :: ToJSON a => a -> Column PGJson
pgJSONB :: String -> Column PGJsonb
pgStrictJSONB :: ByteString -> Column PGJsonb
pgLazyJSONB :: ByteString -> Column PGJsonb
pgValueJSONB :: ToJSON a => a -> Column PGJsonb
pgArray :: forall a b. IsSqlType b => (a -> Column b) -> [a] -> Column (PGArray b)
pgRange :: forall a b. IsRangeType b => (a -> Column b) -> RangeBound a -> RangeBound a -> Column (PGRange b)

-- | <i>Deprecated: <a>literalColumn</a> has been moved to
--   Opaleye.Internal.PGTypes and will be removed in version 0.7.</i>
literalColumn :: Literal -> Column a

-- | <i>Deprecated: <a>unsafePgFormatTime</a> has been moved to
--   Opaleye.Internal.PGTypes and will be removed in version 0.7.</i>
unsafePgFormatTime :: FormatTime t => Name -> String -> t -> Column c
instance Opaleye.PGTypes.IsRangeType a => Opaleye.PGTypes.IsSqlType (Opaleye.PGTypes.PGRange a)
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGJsonb
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGJson
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGBytea
instance Opaleye.PGTypes.IsSqlType a => Opaleye.PGTypes.IsSqlType (Opaleye.PGTypes.PGArray a)
instance Opaleye.Internal.Column.PGString Opaleye.PGTypes.PGCitext
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGCitext
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGUuid
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGTimestamptz
instance Opaleye.PGTypes.IsRangeType Opaleye.PGTypes.PGTimestamptz
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGTimestamp
instance Opaleye.PGTypes.IsRangeType Opaleye.PGTypes.PGTimestamp
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGTime
instance Opaleye.Internal.Column.PGString Opaleye.PGTypes.PGText
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGText
instance Opaleye.Internal.Column.PGIntegral Opaleye.PGTypes.PGNumeric
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGNumeric
instance Opaleye.PGTypes.IsRangeType Opaleye.PGTypes.PGNumeric
instance Opaleye.Internal.Column.PGIntegral Opaleye.PGTypes.PGInt2
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGInt2
instance Opaleye.Internal.Column.PGNum Opaleye.PGTypes.PGInt4
instance Opaleye.Internal.Column.PGIntegral Opaleye.PGTypes.PGInt4
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGInt4
instance Opaleye.PGTypes.IsRangeType Opaleye.PGTypes.PGInt4
instance Opaleye.Internal.Column.PGNum Opaleye.PGTypes.PGInt8
instance Opaleye.Internal.Column.PGIntegral Opaleye.PGTypes.PGInt8
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGInt8
instance Opaleye.PGTypes.IsRangeType Opaleye.PGTypes.PGInt8
instance Opaleye.Internal.Column.PGNum Opaleye.PGTypes.PGFloat8
instance Opaleye.Internal.Column.PGFractional Opaleye.PGTypes.PGFloat8
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGFloat8
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGFloat4
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGDate
instance Opaleye.PGTypes.IsRangeType Opaleye.PGTypes.PGDate
instance Opaleye.PGTypes.IsSqlType Opaleye.PGTypes.PGBool
instance Opaleye.PGTypes.IsSqlType a => Opaleye.PGTypes.IsSqlType (Opaleye.Internal.Column.Nullable a)


-- | Functions for working directly with <a>Column</a>s.
--   
--   Please note that numeric <a>Column</a> types are instances of
--   <a>Num</a>, so you can use <a>*</a>, <a>/</a>, <a>+</a>, <a>-</a> on
--   them.
module Opaleye.Column

-- | A column of a <tt>Query</tt>, of type <tt>pgType</tt>. For example
--   <a>Column</a> <tt>PGInt4</tt> is an <tt>int4</tt> column and a
--   <a>Column</a> <tt>PGText</tt> is a <tt>text</tt> column.
--   
--   Do not use the <a>Show</a> instance of <a>Column</a>. It is considered
--   deprecated and will be removed in version 0.7.
data Column pgType

-- | Only used within a <a>Column</a>, to indicate that it can be
--   <tt>NULL</tt>. For example, a <a>Column</a> (<a>Nullable</a>
--   <tt>PGText</tt>) can be <tt>NULL</tt> but a <a>Column</a>
--   <tt>PGText</tt> cannot.
data Nullable a

-- | A NULL of any type
null :: Column (Nullable a)

-- | <tt>TRUE</tt> if the value of the column is <tt>NULL</tt>,
--   <tt>FALSE</tt> otherwise.
isNull :: Column (Nullable a) -> Column PGBool

-- | If the <tt>Column (Nullable a)</tt> is NULL then return the <tt>Column
--   b</tt> otherwise map the underlying <tt>Column a</tt> using the
--   provided function.
--   
--   The Opaleye equivalent of <a>maybe</a>.
matchNullable :: Column b -> (Column a -> Column b) -> Column (Nullable a) -> Column b

-- | If the <tt>Column (Nullable a)</tt> is NULL then return the provided
--   <tt>Column a</tt> otherwise return the underlying <tt>Column a</tt>.
--   
--   The Opaleye equivalent of <a>fromMaybe</a> and very similar to
--   PostgreSQL's <tt>COALESCE</tt>.
fromNullable :: Column a -> Column (Nullable a) -> Column a

-- | Treat a column as though it were nullable. This is always safe.
--   
--   The Opaleye equivalent of <a>Just</a>.
toNullable :: Column a -> Column (Nullable a)

-- | If the argument is <a>Nothing</a> return NULL otherwise return the
--   provided value coerced to a nullable type.
maybeToNullable :: Maybe (Column a) -> Column (Nullable a)

-- | Cast a column to any other type. Implements Postgres's <tt>::</tt> or
--   <tt>CAST( ... AS ... )</tt> operations. This is safe for some
--   conversions, such as uuid to text.
unsafeCast :: String -> Column a -> Column b

-- | Treat a <a>Column</a> as though it were of a different type. If such a
--   treatment is not valid then Postgres may fail with an error at SQL run
--   time.
unsafeCoerceColumn :: Column a -> Column b
unsafeCompositeField :: Column a -> String -> Column b

-- | A NULL of any type
null :: Column (Nullable a)

-- | <tt>TRUE</tt> if the value of the column is <tt>NULL</tt>,
--   <tt>FALSE</tt> otherwise.
isNull :: Column (Nullable a) -> Column PGBool

-- | If the <tt>Column (Nullable a)</tt> is NULL then return the <tt>Column
--   b</tt> otherwise map the underlying <tt>Column a</tt> using the
--   provided function.
--   
--   The Opaleye equivalent of <a>maybe</a>.
matchNullable :: Column b -> (Column a -> Column b) -> Column (Nullable a) -> Column b

-- | If the <tt>Column (Nullable a)</tt> is NULL then return the provided
--   <tt>Column a</tt> otherwise return the underlying <tt>Column a</tt>.
--   
--   The Opaleye equivalent of <a>fromMaybe</a> and very similar to
--   PostgreSQL's <tt>COALESCE</tt>.
fromNullable :: Column a -> Column (Nullable a) -> Column a

-- | Treat a column as though it were nullable. This is always safe.
--   
--   The Opaleye equivalent of <a>Just</a>.
toNullable :: Column a -> Column (Nullable a)

-- | If the argument is <a>Nothing</a> return NULL otherwise return the
--   provided value coerced to a nullable type.
maybeToNullable :: Maybe (Column a) -> Column (Nullable a)
joinNullable :: Column (Nullable (Nullable a)) -> Column (Nullable a)

module Opaleye.Internal.Unpackspec
newtype Unpackspec columns columns'

-- | An <a>Unpackspec</a> <tt>columns</tt> <tt>columns'</tt> allows you to
--   extract and modify a sequence of <a>PrimExpr</a>s inside a value of
--   type <tt>columns</tt>.
--   
--   For example, the <tt>Default</tt> instance of type <a>Unpackspec</a>
--   <tt>(Column a, Column b)</tt> <tt>(Column a, Column b)</tt> allows you
--   to manipulate or extract the two <a>PrimExpr</a>s inside a <tt>(Column
--   a, Column b)</tt>. The <tt>Default</tt> instance of type <tt>Foo
--   (Column a) (Column b) (Column c)</tt> will allow you to manipulate or
--   extract the three <a>PrimExpr</a>s contained therein (for a
--   user-defined product type <tt>Foo</tt>, assuming the
--   <tt>makeAdaptorAndInstance</tt> splice from
--   <tt>Data.Profunctor.Product.TH</tt> has been run).
--   
--   Users should almost never need to create or manipulate
--   <a>Unpackspec</a>s. Typically they will be created automatically by
--   the <a>Default</a> instance. If you really need to you can create
--   <a>Unpackspec</a>s by hand using <a>unpackspecColumn</a> and the
--   <a>Profunctor</a>, <a>ProductProfunctor</a> and <tt>SumProfunctor</tt>
--   operations.
Unpackspec :: PackMap PrimExpr PrimExpr columns columns' -> Unpackspec columns columns'

-- | Target the single <a>PrimExpr</a> inside a <a>Column</a>
unpackspecColumn :: Unpackspec (Column a) (Column a)

-- | Modify all the targeted <a>PrimExpr</a>s
runUnpackspec :: Applicative f => Unpackspec columns b -> (PrimExpr -> f PrimExpr) -> columns -> f b

-- | Extract all the targeted <a>PrimExpr</a>s
collectPEs :: Unpackspec s t -> s -> [PrimExpr]
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Unpackspec.Unpackspec (Opaleye.Internal.Column.Column a) (Opaleye.Internal.Column.Column a)
instance GHC.Base.Functor (Opaleye.Internal.Unpackspec.Unpackspec a)
instance GHC.Base.Applicative (Opaleye.Internal.Unpackspec.Unpackspec a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Unpackspec.Unpackspec
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Unpackspec.Unpackspec
instance Data.Profunctor.Product.Class.SumProfunctor Opaleye.Internal.Unpackspec.Unpackspec

module Opaleye.Internal.Values
valuesU :: Unpackspec columns columns' -> Valuesspec columns columns' -> [columns] -> ((), Tag) -> (columns', PrimQuery, Tag)
extractValuesEntry :: PrimExpr -> PM [PrimExpr] PrimExpr
extractValuesField :: Tag -> primExpr -> PM [(Symbol, primExpr)] PrimExpr
newtype Valuesspec columns columns'
Valuesspec :: PackMap () PrimExpr () columns' -> Valuesspec columns columns'
runValuesspec :: Applicative f => Valuesspec columns columns' -> (() -> f PrimExpr) -> f columns'
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Values.Valuesspec (Opaleye.Internal.Column.Column a) (Opaleye.Internal.Column.Column a)
instance GHC.Base.Functor (Opaleye.Internal.Values.Valuesspec a)
instance GHC.Base.Applicative (Opaleye.Internal.Values.Valuesspec a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Values.Valuesspec
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Values.Valuesspec

module Opaleye.Internal.Table
data Table writerColumns viewColumns

-- | For unqualified table names. Do not use the constructor. It is
--   internal and will be deprecated in version 0.7.
Table :: String -> TableFields writerColumns viewColumns -> Table writerColumns viewColumns

-- | Schema name, table name, table properties. Do not use the constructor.
--   It is internal and will be deprecated in version 0.7.
TableWithSchema :: String -> String -> TableFields writerColumns viewColumns -> Table writerColumns viewColumns
tableIdentifier :: Table writeColumns viewColumns -> TableIdentifier
tableColumns :: Table writeColumns viewColumns -> TableFields writeColumns viewColumns

-- | Use <a>tableColumns</a> instead. Will be deprecated soon.
tableProperties :: Table writeColumns viewColumns -> TableFields writeColumns viewColumns

-- | Use <a>TableFields</a> instead. <a>TableProperties</a> will be
--   deprecated in version 0.7.
data TableProperties writeColumns viewColumns
TableProperties :: Writer writeColumns viewColumns -> View viewColumns -> TableProperties writeColumns viewColumns
[tablePropertiesWriter] :: TableProperties writeColumns viewColumns -> Writer writeColumns viewColumns
[tablePropertiesView] :: TableProperties writeColumns viewColumns -> View viewColumns

-- | Use <a>TableFields</a> instead. <a>TableColumns</a> will be deprecated
--   in version 0.7.
type TableColumns = TableProperties

-- | The new name for <a>TableColumns</a> and <a>TableProperties</a> which
--   will replace them in version 0.7.
type TableFields = TableProperties
tableColumnsWriter :: TableFields writeColumns viewColumns -> Writer writeColumns viewColumns
tableColumnsView :: TableFields writeColumns viewColumns -> View viewColumns

-- | Internal only. Do not use. <a>View</a> will be deprecated in version
--   0.7.
data View columns
View :: columns -> View columns

-- | Internal only. Do not use. <a>Writer</a> will be deprecated in version
--   0.7.
newtype Writer columns dummy
Writer :: (forall f. Functor f => PackMap (f PrimExpr, String) () (f columns) ()) -> Writer columns dummy

-- | <a>required</a> is for columns which are not <a>optional</a>. You must
--   provide them on writes.
required :: String -> TableFields (Column a) (Column a)

-- | <a>optional</a> is for columns that you can omit on writes, such as
--   columns which have defaults or which are SERIAL.
optional :: String -> TableFields (Maybe (Column a)) (Column a)
class TableColumn writeType sqlType | writeType -> sqlType

-- | Infer either a <a>required</a> or <a>optional</a> column depending on
--   the write type. It's generally more convenient to use this than
--   <a>required</a> or <a>optional</a> but you do have to provide a type
--   signature instead.
tableColumn :: TableColumn writeType sqlType => String -> TableFields writeType (Column sqlType)
tableField :: TableColumn writeType sqlType => String -> TableFields writeType (Column sqlType)
queryTable :: Unpackspec viewColumns columns -> Table writeColumns viewColumns -> Tag -> (columns, PrimQuery)
runColumnMaker :: Unpackspec tablecolumns columns -> Tag -> tablecolumns -> (columns, [(Symbol, PrimExpr)])
runWriter :: Writer columns columns' -> columns -> [(PrimExpr, String)]
runWriter' :: Writer columns columns' -> NonEmpty columns -> (NonEmpty [PrimExpr], [String])
newtype Zip a
Zip :: NonEmpty [a] -> Zip a
[unZip] :: Zip a -> NonEmpty [a]
requiredW :: String -> Writer (Column a) (Column a)
optionalW :: String -> Writer (Maybe (Column a)) (Column a)
instance GHC.Base.Semigroup (Opaleye.Internal.Table.Zip a)
instance GHC.Base.Monoid (Opaleye.Internal.Table.Zip a)
instance Opaleye.Internal.Table.TableColumn (Opaleye.Internal.Column.Column a) a
instance Opaleye.Internal.Table.TableColumn (GHC.Maybe.Maybe (Opaleye.Internal.Column.Column a)) a
instance GHC.Base.Functor (Opaleye.Internal.Table.Table a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Table.Table
instance GHC.Base.Functor (Opaleye.Internal.Table.TableProperties a)
instance GHC.Base.Applicative (Opaleye.Internal.Table.TableProperties a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Table.TableProperties
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Table.TableProperties
instance GHC.Base.Functor (Opaleye.Internal.Table.Writer a)
instance GHC.Base.Applicative (Opaleye.Internal.Table.Writer a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Table.Writer
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Table.Writer

module Opaleye.Internal.QueryArr
newtype QueryArr a b
QueryArr :: ((a, PrimQuery, Tag) -> (b, PrimQuery, Tag)) -> QueryArr a b
type Query = QueryArr ()
simpleQueryArr :: ((a, Tag) -> (b, PrimQuery, Tag)) -> QueryArr a b
runQueryArr :: QueryArr a b -> (a, PrimQuery, Tag) -> (b, PrimQuery, Tag)
runSimpleQueryArr :: QueryArr a b -> (a, Tag) -> (b, PrimQuery, Tag)
runSimpleQueryArrStart :: QueryArr a b -> a -> (b, PrimQuery, Tag)
runQueryArrUnpack :: Unpackspec a b -> Query a -> ([PrimExpr], PrimQuery, Tag)
first3 :: (a1 -> b) -> (a1, a2, a3) -> (b, a2, a3)
instance Control.Category.Category Opaleye.Internal.QueryArr.QueryArr
instance Control.Arrow.Arrow Opaleye.Internal.QueryArr.QueryArr
instance Control.Arrow.ArrowChoice Opaleye.Internal.QueryArr.QueryArr
instance GHC.Base.Functor (Opaleye.Internal.QueryArr.QueryArr a)
instance GHC.Base.Applicative (Opaleye.Internal.QueryArr.QueryArr a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.QueryArr.QueryArr
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.QueryArr.QueryArr

module Opaleye.Internal.Binary
extractBinaryFields :: Tag -> (PrimExpr, PrimExpr) -> PM [(Symbol, (PrimExpr, PrimExpr))] PrimExpr
newtype Binaryspec columns columns'
Binaryspec :: PackMap (PrimExpr, PrimExpr) PrimExpr (columns, columns) columns' -> Binaryspec columns columns'
runBinaryspec :: Applicative f => Binaryspec columns columns' -> ((PrimExpr, PrimExpr) -> f PrimExpr) -> (columns, columns) -> f columns'
binaryspecColumn :: Binaryspec (Column a) (Column a)
sameTypeBinOpHelper :: BinOp -> Binaryspec columns columns' -> Query columns -> Query columns -> Query columns'
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Binary.Binaryspec (Opaleye.Internal.Column.Column a) (Opaleye.Internal.Column.Column a)
instance GHC.Base.Functor (Opaleye.Internal.Binary.Binaryspec a)
instance GHC.Base.Applicative (Opaleye.Internal.Binary.Binaryspec a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Binary.Binaryspec
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Binary.Binaryspec

module Opaleye.Internal.TableMaker
newtype ViewColumnMaker strings columns
ViewColumnMaker :: PackMap () () strings columns -> ViewColumnMaker strings columns
runViewColumnMaker :: ViewColumnMaker strings tablecolumns -> strings -> tablecolumns

-- | <i>Deprecated: Use Unpackspec instead</i>
type ColumnMaker = Unpackspec

-- | <i>Deprecated: Use runUnpackspec instead</i>
runColumnMaker :: Applicative f => ColumnMaker tablecolumns columns -> (PrimExpr -> f PrimExpr) -> tablecolumns -> f columns
tableColumn :: ViewColumnMaker String (Column a)

-- | <i>Deprecated: Use unpackspecColumn instead</i>
column :: ColumnMaker (Column a) (Column a)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.TableMaker.ViewColumnMaker GHC.Base.String (Opaleye.Internal.Column.Column a)
instance GHC.Base.Functor (Opaleye.Internal.TableMaker.ViewColumnMaker a)
instance GHC.Base.Applicative (Opaleye.Internal.TableMaker.ViewColumnMaker a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.TableMaker.ViewColumnMaker
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.TableMaker.ViewColumnMaker

module Opaleye.Internal.Operators
(.==) :: forall columns. Default EqPP columns columns => columns -> columns -> Column PGBool
infix 4 .==

-- | Boolean and
(.&&) :: Column PGBool -> Column PGBool -> Column PGBool
infixr 3 .&&
newtype EqPP a b
EqPP :: (a -> a -> Column PGBool) -> EqPP a b
eqExplicit :: EqPP columns a -> columns -> columns -> Column PGBool
newtype IfPP a b
IfPP :: (Column PGBool -> a -> a -> b) -> IfPP a b
ifExplict :: IfPP columns columns' -> Column PGBool -> columns -> columns -> columns'
data RelExprMaker a b
RelExprMaker :: ViewColumnMaker a c -> Unpackspec c b -> RelExprMaker a b
[relExprVCM] :: RelExprMaker a b -> ViewColumnMaker a c
[relExprCM] :: RelExprMaker a b -> Unpackspec c b
relExprColumn :: RelExprMaker String (Column a)
runRelExprMaker :: RelExprMaker strings columns -> Tag -> strings -> (columns, [(Symbol, PrimExpr)])
relationValuedExprExplicit :: RelExprMaker strings columns -> strings -> (a -> PrimExpr) -> QueryArr a columns
relationValuedExpr :: Default RelExprMaker strings columns => strings -> (a -> PrimExpr) -> QueryArr a columns
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Operators.RelExprMaker GHC.Base.String (Opaleye.Internal.Column.Column a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Operators.RelExprMaker
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Operators.RelExprMaker
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Operators.IfPP (Opaleye.Internal.Column.Column a) (Opaleye.Internal.Column.Column a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Operators.IfPP
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Operators.IfPP
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Operators.EqPP (Opaleye.Internal.Column.Column a) (Opaleye.Internal.Column.Column a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Operators.EqPP
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Operators.EqPP

module Opaleye.Internal.RunQuery

-- | A <a>QueryRunnerColumn</a> <tt>pgType</tt> <tt>haskellType</tt>
--   encodes how to turn a value of Postgres type <tt>pgType</tt> into a
--   value of Haskell type <tt>haskellType</tt>. For example a value of
--   type <a>QueryRunnerColumn</a> <a>PGText</a> <a>String</a> encodes how
--   to turn a <a>PGText</a> result from the database into a Haskell
--   <a>String</a>.
--   
--   "<a>QueryRunnerColumn</a> <tt>pgType</tt> <tt>haskellType</tt>"
--   corresponds to postgresql-simple's "<a>FieldParser</a>
--   <tt>haskellType</tt>".
data QueryRunnerColumn pgType haskellType
QueryRunnerColumn :: Unpackspec (Column pgType) () -> FieldParser haskellType -> QueryRunnerColumn pgType haskellType
type FromField = QueryRunnerColumn

-- | A <a>QueryRunner</a> specifies how to convert Postgres values
--   (<tt>columns</tt>) into Haskell values (<tt>haskells</tt>). Most
--   likely you will never need to create on of these or handle one
--   directly. It will be provided for you by the <a>Default</a>
--   <a>QueryRunner</a> instance.
--   
--   "<a>QueryRunner</a> <tt>columns</tt> <tt>haskells</tt>" corresponds to
--   postgresql-simple's "<a>RowParser</a> <tt>haskells</tt>".
--   "<tt>Default</tt> <a>QueryRunner</a> <tt>columns</tt>
--   <tt>haskells</tt>" corresponds to postgresql-simple's
--   "<tt>FromRow</tt> <tt>haskells</tt>".
data QueryRunner columns haskells
QueryRunner :: Unpackspec columns () -> (columns -> RowParser haskells) -> (columns -> Bool) -> QueryRunner columns haskells
type FromFields = QueryRunner
fieldQueryRunnerColumn :: FromField haskell => FromField pgType haskell
fieldParserQueryRunnerColumn :: FieldParser haskell -> FromField pgType haskell
queryRunner :: FromField a b -> FromFields (Column a) b
queryRunnerColumnNullable :: FromField a b -> FromField (Nullable a) (Maybe b)

-- | A <a>QueryRunnerColumnDefault</a> <tt>pgType</tt> <tt>haskellType</tt>
--   represents the default way to turn a <tt>pgType</tt> result from the
--   database into a Haskell value of type <tt>haskellType</tt>.
--   
--   "<a>QueryRunnerColumnDefault</a> <tt>pgType</tt> <tt>haskellType</tt>"
--   corresponds to postgresql-simple's "<a>FromField</a>
--   <tt>haskellType</tt>".
--   
--   Creating an instance of <a>QueryRunnerColumnDefault</a> for your own
--   types is necessary for retrieving those types from the database.
--   
--   You should use one of the three methods below for writing a
--   <a>QueryRunnerColumnDefault</a> instance.
--   
--   <ol>
--   <li>If you already have a <a>FromField</a> instance for your
--   <tt>haskellType</tt>, use <a>fieldQueryRunnerColumn</a>. (This is how
--   most of the built-in instances are defined.)</li>
--   <li>If you don't have a <a>FromField</a> instance, use
--   <a>queryRunnerColumn</a> if possible. See the documentation for
--   <a>queryRunnerColumn</a> for an example.</li>
--   <li>If you have a more complicated case, but not a <a>FromField</a>
--   instance, write a <a>FieldParser</a> for your type and use
--   <a>fieldParserQueryRunnerColumn</a>. You can also add a
--   <a>FromField</a> instance using this.</li>
--   </ol>
class QueryRunnerColumnDefault pgType haskellType
queryRunnerColumnDefault :: QueryRunnerColumnDefault pgType haskellType => QueryRunnerColumn pgType haskellType
arrayColumn :: Column (PGArray a) -> Column a
jsonFieldParser :: FieldParser String
jsonbFieldParser :: FieldParser String
jsonFieldTypeParser :: ByteString -> FieldParser String
prepareRowParser :: FromFields columns haskells -> columns -> RowParser haskells

-- | Cursor within a transaction.
data Cursor haskells
EmptyCursor :: Cursor haskells
Cursor :: RowParser haskells -> Cursor -> Cursor haskells
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault a b => Opaleye.Internal.RunQuery.QueryRunnerColumnDefault (Opaleye.Internal.Column.Nullable a) (GHC.Maybe.Maybe b)
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault a b => Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.RunQuery.QueryRunner (Opaleye.Internal.Column.Column a) b
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault sqlType haskellType => Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.RunQuery.FromField sqlType haskellType
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGNumeric Data.Scientific.Scientific
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGInt4 GHC.Types.Int
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGInt4 GHC.Int.Int32
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGInt8 GHC.Int.Int64
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGText GHC.Base.String
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGFloat8 GHC.Types.Double
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGBool GHC.Types.Bool
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGUuid Data.UUID.Types.Internal.UUID
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGBytea Data.ByteString.Internal.ByteString
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGBytea Data.ByteString.Lazy.Internal.ByteString
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGText Data.Text.Internal.Text
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGText Data.Text.Internal.Lazy.Text
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGDate Data.Time.Calendar.Days.Day
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGTimestamptz Data.Time.Clock.Internal.UTCTime.UTCTime
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGTimestamp Data.Time.LocalTime.Internal.LocalTime.LocalTime
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGTimestamptz Data.Time.LocalTime.Internal.ZonedTime.ZonedTime
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGTime Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGCitext (Data.CaseInsensitive.Internal.CI Data.Text.Internal.Text)
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGCitext (Data.CaseInsensitive.Internal.CI Data.Text.Internal.Lazy.Text)
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGJson GHC.Base.String
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGJson Data.Aeson.Types.Internal.Value
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGJsonb GHC.Base.String
instance Opaleye.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.PGTypes.PGJsonb Data.Aeson.Types.Internal.Value
instance (Data.Typeable.Internal.Typeable b, Opaleye.Internal.RunQuery.QueryRunnerColumnDefault a b) => Opaleye.Internal.RunQuery.QueryRunnerColumnDefault (Opaleye.PGTypes.PGArray a) [b]
instance (Data.Typeable.Internal.Typeable b, Database.PostgreSQL.Simple.FromField.FromField b, Opaleye.Internal.RunQuery.QueryRunnerColumnDefault a b) => Opaleye.Internal.RunQuery.QueryRunnerColumnDefault (Opaleye.PGTypes.PGRange a) (Database.PostgreSQL.Simple.Range.PGRange b)
instance GHC.Base.Functor (Opaleye.Internal.RunQuery.FromFields c)
instance GHC.Base.Applicative (Opaleye.Internal.RunQuery.FromFields c)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.RunQuery.FromFields
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.RunQuery.FromFields
instance Data.Profunctor.Product.Class.SumProfunctor Opaleye.Internal.RunQuery.FromFields
instance GHC.Base.Functor (Opaleye.Internal.RunQuery.FromField u)

module Opaleye.Internal.Order

-- | An <a>Order</a> <tt>a</tt> represents a sort order and direction for
--   the elements of the type <tt>a</tt>. Multiple <a>Order</a>s can be
--   composed with <a>mappend</a> or <tt>(&lt;&gt;)</tt> from
--   <a>Data.Monoid</a>. If two rows are equal according to the first
--   <a>Order</a> in the <tt>mappend</tt>, the second is used, and so on.
newtype Order a
Order :: (a -> [(OrderOp, PrimExpr)]) -> Order a
order :: OrderOp -> (a -> Column b) -> Order a
orderByU :: Order a -> (a, PrimQuery, Tag) -> (a, PrimQuery, Tag)
orderExprs :: a -> Order a -> [OrderExpr]
limit' :: Int -> (a, PrimQuery, Tag) -> (a, PrimQuery, Tag)
offset' :: Int -> (a, PrimQuery, Tag) -> (a, PrimQuery, Tag)
distinctOn :: Unpackspec b b -> (a -> b) -> (a, PrimQuery, Tag) -> (a, PrimQuery, Tag)
distinctOnBy :: Unpackspec b b -> (a -> b) -> Order a -> (a, PrimQuery, Tag) -> (a, PrimQuery, Tag)

-- | Order the results of a given query exactly, as determined by the given
--   list of input columns. Note that this list does not have to contain an
--   entry for every result in your query: you may exactly order only a
--   subset of results, if you wish. Rows that are not ordered according to
--   the input list are returned <i>after</i> the ordered results, in the
--   usual order the database would return them (e.g. sorted by primary
--   key). Exactly-ordered results always come first in a result set.
--   Entries in the input list that are <i>not</i> present in result of a
--   query are ignored.
exact :: [Column b] -> (a -> Column b) -> Order a
instance Data.Functor.Contravariant.Contravariant Opaleye.Internal.Order.Order
instance GHC.Base.Semigroup (Opaleye.Internal.Order.Order a)
instance GHC.Base.Monoid (Opaleye.Internal.Order.Order a)
instance Data.Functor.Contravariant.Divisible.Divisible Opaleye.Internal.Order.Order
instance Data.Functor.Contravariant.Divisible.Decidable Opaleye.Internal.Order.Order

module Opaleye.Internal.Aggregate

-- | An <a>Aggregator</a> takes a collection of rows of type <tt>a</tt>,
--   groups them, and transforms each group into a single row of type
--   <tt>b</tt>. This corresponds to aggregators using <tt>GROUP BY</tt> in
--   SQL.
--   
--   You should combine basic <a>Aggregator</a>s into <a>Aggregator</a>s on
--   compound types by using the operations in
--   <a>Data.Profunctor.Product</a>.
--   
--   An <a>Aggregator</a> corresponds closely to a <a>Fold</a> from the
--   <tt>foldl</tt> package. Whereas an <a>Aggregator</a> <tt>a</tt>
--   <tt>b</tt> takes each group of type <tt>a</tt> to a single row of type
--   <tt>b</tt>, a <a>Fold</a> <tt>a</tt> <tt>b</tt> takes a list of
--   <tt>a</tt> and returns a single value of type <tt>b</tt>.
newtype Aggregator a b
Aggregator :: PackMap (Maybe (AggrOp, [OrderExpr], AggrDistinct), PrimExpr) PrimExpr a b -> Aggregator a b
makeAggr' :: Maybe AggrOp -> Aggregator (Column a) (Column b)
makeAggr :: AggrOp -> Aggregator (Column a) (Column b)

-- | Order the values within each aggregation in <a>Aggregator</a> using
--   the given ordering. This is only relevant for aggregations that depend
--   on the order they get their elements, like <a>arrayAgg</a> and
--   <a>stringAgg</a>.
--   
--   You can either apply it to an aggregation of multiple columns, in
--   which case it will apply to all aggregation functions in there, or you
--   can apply it to a single column, and then compose the aggregations
--   afterwards. Examples:
--   
--   <pre>
--   x :: Aggregator (Column a, Column b) (Column (PGArray a), Column (PGArray a))
--   x = (,) &lt;$&gt; orderAggregate (asc snd) (lmap fst arrayAggGrouped)
--           &lt;*&gt; orderAggregate (desc snd) (lmap fst arrayAggGrouped)
--   </pre>
--   
--   This will generate:
--   
--   <pre>
--   SELECT array_agg(a ORDER BY b ASC), array_agg(a ORDER BY b DESC)
--   FROM (SELECT a, b FROM ...)
--   </pre>
--   
--   Or:
--   
--   <pre>
--   x :: Aggregator (Column a, Column b) (Column (PGArray a), Column (PGArray b))
--   x = orderAggregate (asc snd) $ p2 (arrayAggGrouped, arrayAggGrouped)
--   </pre>
--   
--   This will generate:
--   
--   <pre>
--   SELECT array_agg(a ORDER BY b ASC), array_agg(b ORDER BY b ASC)
--   FROM (SELECT a, b FROM ...)
--   </pre>
orderAggregate :: Order a -> Aggregator a b -> Aggregator a b
runAggregator :: Applicative f => Aggregator a b -> ((Maybe (AggrOp, [OrderExpr], AggrDistinct), PrimExpr) -> f PrimExpr) -> a -> f b
aggregateU :: Aggregator a b -> (a, PrimQuery, Tag) -> (b, PrimQuery, Tag)
extractAggregateFields :: Tag -> (Maybe (AggrOp, [OrderExpr], AggrDistinct), PrimExpr) -> PM [(Symbol, (Maybe (AggrOp, [OrderExpr], AggrDistinct), PrimExpr))] PrimExpr
instance GHC.Base.Functor (Opaleye.Internal.Aggregate.Aggregator a)
instance GHC.Base.Applicative (Opaleye.Internal.Aggregate.Aggregator a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Aggregate.Aggregator
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Aggregate.Aggregator
instance Data.Profunctor.Product.Class.SumProfunctor Opaleye.Internal.Aggregate.Aggregator

module Opaleye.Field
type family Field_ (a :: Nullability) b
data Nullability
NonNullable :: Nullability
Nullable :: Nullability
type FieldNullable a = Field_  'Nullable a
type Field a = Field_  'NonNullable a

-- | A NULL of any type
null :: FieldNullable a

-- | <tt>TRUE</tt> if the value of the column is <tt>NULL</tt>,
--   <tt>FALSE</tt> otherwise.
isNull :: FieldNullable a -> Field PGBool

-- | If the <tt>Field 'Nullable a</tt> is NULL then return the <tt>Field
--   'NonNullable b</tt> otherwise map the underlying <tt>Field 'Nullable
--   a</tt> using the provided function.
--   
--   The Opaleye equivalent of <a>maybe</a>.
--   
--   Will be generalized to <tt>Field_ n b</tt> in a later version.
matchNullable :: Field_  'NonNullable b -> (Field_  'NonNullable a -> Field_  'NonNullable b) -> Field_  'Nullable a -> Field_  'NonNullable b

-- | If the <tt>Field 'Nullable a</tt> is NULL then return the provided
--   <tt>Field 'NonNullable a</tt> otherwise return the underlying
--   <tt>Field 'NonNullable a</tt>.
--   
--   The Opaleye equivalent of <a>fromMaybe</a> and very similar to
--   PostgreSQL's <tt>COALESCE</tt>.
--   
--   Will be generalized to <tt>Field_ n a</tt> in a later version.
fromNullable :: Field_  'NonNullable a -> Field_  'Nullable a -> Field_  'NonNullable a

-- | Treat a field as though it were nullable. This is always safe.
--   
--   The Opaleye equivalent of <a>Just</a>.
--   
--   Will be generalized to <tt>Field_ n a</tt> in a later version.
toNullable :: Field_  'NonNullable a -> Field_  'Nullable a

-- | If the argument is <a>Nothing</a> return NULL otherwise return the
--   provided value coerced to a nullable type.
--   
--   Will be generalized to <tt>Maybe (Field_ n a)</tt> in a later version.
maybeToNullable :: Maybe (Field_  'NonNullable a) -> Field_  'Nullable a

module Opaleye.Internal.TypeFamilies
type family IMap f a
data HT
data OT
data NullsT
data WT
type NN =  'NonNullable
type N =  'Nullable
data Optionality
OReq :: Optionality
OOpt :: Optionality
type Req =  'OReq
type Opt =  'OOpt
type family A (a :: Arr h k1 k2) (b :: k1) :: k2
data Arr h k1 k2
[K] :: k1 -> Arr h k2 k1
[S] :: Arr h k1 (k2 -> k3) -> Arr h k1 k2 -> Arr h k1 k3
[I] :: Arr h k1 k1
[H] :: h -> Arr h k2 k3
type (:<*>) =  'S
type Pure =  'K
type (:<$>) f = (:<*>) (Pure f)
type Id =  'I
type (:<|) f x = A f x
data C a
C :: (a, a, Nullability) -> C a
data TC a
TC :: ((a, a, Nullability), Optionality) -> TC a
type RecordField f a b c = A f ( 'C '(a, b, c))
type TableField f a b c d = A f ( 'TC '('(a, b, c), d))
type H =  'H HT
type O =  'H OT
type Nulls =  'H NullsT
type W =  'H WT
type F =  'H

module Opaleye.Internal.Join
newtype NullMaker a b
NullMaker :: (a -> b) -> NullMaker a b
toNullable :: NullMaker a b -> a -> b
joinExplicit :: Unpackspec columnsA columnsA -> Unpackspec columnsB columnsB -> (columnsA -> returnedColumnsA) -> (columnsB -> returnedColumnsB) -> JoinType -> Query columnsA -> Query columnsB -> ((columnsA, columnsB) -> Column PGBool) -> Query (returnedColumnsA, returnedColumnsB)
leftJoinAExplicit :: Unpackspec a a -> NullMaker a nullableA -> Query a -> QueryArr (a -> Column PGBool) nullableA
extractLeftJoinFields :: Int -> Tag -> PrimExpr -> PM [(Symbol, PrimExpr)] PrimExpr
data Nulled
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Join.NullMaker (Opaleye.Internal.Column.Column a) (Opaleye.Internal.Column.Column (Opaleye.Internal.Column.Nullable a))
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Join.NullMaker (Opaleye.Internal.Column.Column (Opaleye.Internal.Column.Nullable a)) (Opaleye.Internal.Column.Column (Opaleye.Internal.Column.Nullable a))
instance GHC.Base.Functor (Opaleye.Internal.Join.NullMaker a)
instance GHC.Base.Applicative (Opaleye.Internal.Join.NullMaker a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Join.NullMaker
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Join.NullMaker


-- | Use <a>Opaleye.Select</a> instead. This module will be deprecated in
--   0.7.
module Opaleye.QueryArr
type Query = QueryArr ()
data QueryArr a b


-- | <a>Select</a> and <a>SelectArr</a> are the composable units of
--   database querying that are used in Opaleye.
module Opaleye.Select

-- | A Postgres <tt>SELECT</tt>, i.e. some functionality that can run via
--   SQL and produce a collection of rows.
--   
--   <tt>Select a</tt> is analogous to a Haskell value <tt>[a]</tt>.
type Select = SelectArr ()

-- | <tt>SelectArr a b</tt> is analogous to a Haskell function <tt>a -&gt;
--   [b]</tt>.
type SelectArr = QueryArr

module Opaleye.Label

-- | Add a commented label to the generated SQL.
label :: String -> Select a -> Select a


-- | Binary relational operations on <a>Select</a>s, that is, operations
--   which take two <a>Select</a>s as arguments and return a single
--   <a>Select</a>.
--   
--   All the binary relational operations have the same type
--   specializations. For example:
--   
--   <pre>
--   unionAll :: S.Select (Column a, Column b)
--            -&gt; S.Select (Column a, Column b)
--            -&gt; S.Select (Column a, Column b)
--   </pre>
--   
--   Assuming the <tt>makeAdaptorAndInstance</tt> splice has been run for
--   the product type <tt>Foo</tt>:
--   
--   <pre>
--   unionAll :: S.Select (Foo (Column a) (Column b) (Column c))
--            -&gt; S.Select (Foo (Column a) (Column b) (Column c))
--            -&gt; S.Select (Foo (Column a) (Column b) (Column c))
--   </pre>
--   
--   Please note that by design there are no binary relational functions of
--   type <tt>S.SelectArr a b -&gt; S.SelectArr a b -&gt; S.SelectArr a
--   b</tt>. Such functions would allow violation of SQL's scoping rules
--   and lead to invalid queries.
--   
--   <a>unionAll</a> is very close to being the <tt>&lt;|&gt;</tt> operator
--   of a <tt>Control.Applicative.Alternative</tt> instance but it fails to
--   work only because of the typeclass constraint it has.
module Opaleye.Binary
unionAll :: Default Binaryspec fields fields => Select fields -> Select fields -> Select fields

-- | The same as unionAll, except that it additionally removes any
--   duplicate rows.
union :: Default Binaryspec fields fields => Select fields -> Select fields -> Select fields
intersectAll :: Default Binaryspec fields fields => Select fields -> Select fields -> Select fields

-- | The same as intersectAll, except that it additionally removes any
--   duplicate rows.
intersect :: Default Binaryspec fields fields => Select fields -> Select fields -> Select fields
exceptAll :: Default Binaryspec fields fields => Select fields -> Select fields -> Select fields

-- | The same as exceptAll, except that it additionally removes any
--   duplicate rows.
except :: Default Binaryspec fields fields => Select fields -> Select fields -> Select fields
unionAllExplicit :: Binaryspec fields fields' -> Select fields -> Select fields -> Select fields'
unionExplicit :: Binaryspec fields fields' -> Select fields -> Select fields -> Select fields'
intersectAllExplicit :: Binaryspec fields fields' -> Select fields -> Select fields -> Select fields'
intersectExplicit :: Binaryspec fields fields' -> Select fields -> Select fields -> Select fields'
exceptAllExplicit :: Binaryspec fields fields' -> Select fields -> Select fields -> Select fields'
exceptExplicit :: Binaryspec fields fields' -> Select fields -> Select fields -> Select fields'

module Opaleye.Sql

-- | Show the SQL query string generated from the query.
--   
--   When <a>Nothing</a> is returned it means that the <tt>Query</tt>
--   returns zero rows.
--   
--   Example type specialization:
--   
--   <pre>
--   showSql :: Select (Column a, Column b) -&gt; Maybe String
--   </pre>
--   
--   Assuming the <tt>makeAdaptorAndInstance</tt> splice has been run for
--   the product type <tt>Foo</tt>:
--   
--   <pre>
--   showSql :: Select (Foo (Column a) (Column b) (Column c)) -&gt; Maybe String
--   </pre>
showSql :: forall fields. Default Unpackspec fields fields => Select fields -> Maybe String

-- | Show the unoptimized SQL query string generated from the query.
showSqlUnopt :: forall fields. Default Unpackspec fields fields => Select fields -> Maybe String
showSqlExplicit :: Unpackspec fields b -> Select fields -> Maybe String
showSqlUnoptExplicit :: Unpackspec fields b -> Select fields -> Maybe String

-- | Will be deprecated in version 0.7. Use <a>showSql</a> instead.
showSqlForPostgres :: forall columns. Default Unpackspec columns columns => Select columns -> Maybe String

-- | Will be deprecated in version 0.7. Use <a>showSqlUnopt</a> instead.
showSqlForPostgresUnopt :: forall columns. Default Unpackspec columns columns => Select columns -> Maybe String

-- | Will be deprecated in version 0.7. Use <a>showSqlExplicit</a> instead.
showSqlForPostgresExplicit :: Unpackspec columns b -> Select columns -> Maybe String

-- | Will be deprecated in version 0.7. Use <a>showSqlUnoptExplicit</a>
--   instead.
showSqlForPostgresUnoptExplicit :: Unpackspec columns b -> Select columns -> Maybe String

-- | <i>Deprecated: You probably want <a>showSqlExplicit</a> or
--   <a>showSqlUnoptExplicit</a> instead. Will be removed in version
--   0.7.</i>
formatAndShowSQL :: ([PrimExpr], PrimQuery' a, Tag) -> Maybe String


-- | This module will be deprecated in 0.7. Use <a>Opaleye.RunSelect</a>
--   instead.
module Opaleye.RunQuery

-- | <tt>runQuery</tt>'s use of the <a>Default</a> typeclass means that the
--   compiler will have trouble inferring types. It is strongly recommended
--   that you provide full type signatures when using <tt>runQuery</tt>.
--   
--   Example type specialization:
--   
--   <pre>
--   runQuery :: <a>Select</a> (Column <a>SqlInt4</a>, Column <a>SqlText</a>) -&gt; IO [(Int, String)]
--   </pre>
--   
--   Assuming the <tt>makeAdaptorAndInstance</tt> splice has been run for
--   the product type <tt>Foo</tt>:
--   
--   <pre>
--   runQuery :: <a>Select</a> (Foo (Column <a>SqlInt4</a>) (Column <a>SqlText</a>) (Column <a>SqlBool</a>)
--            -&gt; IO [Foo Int String Bool]
--   </pre>
--   
--   Opaleye types are converted to Haskell types based on instances of the
--   <a>QueryRunnerColumnDefault</a> typeclass.
runQuery :: Default FromFields fields haskells => Connection -> Select fields -> IO [haskells]

-- | <tt>runQueryFold</tt> streams the results of a query incrementally and
--   consumes the results with a left fold.
--   
--   This fold is <i>not</i> strict. The stream consumer is responsible for
--   forcing the evaluation of its result to avoid space leaks.
runQueryFold :: Default FromFields fields haskells => Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b

-- | Use <a>queryRunnerColumn</a> to make an instance to allow you to run
--   queries on your own datatypes. For example:
--   
--   <pre>
--   newtype Foo = Foo Int
--   
--   instance QueryRunnerColumnDefault Foo Foo where
--      queryRunnerColumnDefault =
--          queryRunnerColumn (<a>unsafeCoerceColumn</a>
--                                 :: Column Foo -&gt; Column SqlInt4)
--                            Foo
--                            queryRunnerColumnDefault
--   </pre>
queryRunnerColumn :: (Column a' -> Column a) -> (b -> b') -> QueryRunnerColumn a b -> QueryRunnerColumn a' b'
runQueryExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO [haskells]
runQueryFoldExplicit :: FromFields fields haskells -> Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b

-- | Declare a temporary cursor. The cursor is given a unique name for the
--   given connection.
--   
--   Returns <a>Nothing</a> when the query returns zero rows.
declareCursor :: Default FromFields fields haskells => Connection -> Select fields -> IO (Cursor haskells)

-- | Like <a>declareCursor</a> but takes a <a>FromFields</a> explicitly.
declareCursorExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO (Cursor haskells)

-- | Close the given cursor.
closeCursor :: Cursor fields -> IO ()

-- | Fold over a chunk of rows, calling the supplied fold-like function on
--   each row as it is received. In case the cursor is exhausted, a
--   <a>Left</a> value is returned, otherwise a <a>Right</a> value is
--   returned.
foldForward :: Cursor haskells -> Int -> (a -> haskells -> IO a) -> a -> IO (Either a a)

-- | <i>Deprecated: Will be removed in version 0.7</i>
prepareQuery :: FromFields fields haskells -> Select fields -> (Maybe Query, RowParser haskells)

-- | Cursor within a transaction.
data Cursor haskells
type FromFields = QueryRunner
type FromField = QueryRunnerColumn

-- | A <a>QueryRunner</a> specifies how to convert Postgres values
--   (<tt>columns</tt>) into Haskell values (<tt>haskells</tt>). Most
--   likely you will never need to create on of these or handle one
--   directly. It will be provided for you by the <a>Default</a>
--   <a>QueryRunner</a> instance.
--   
--   "<a>QueryRunner</a> <tt>columns</tt> <tt>haskells</tt>" corresponds to
--   postgresql-simple's "<a>RowParser</a> <tt>haskells</tt>".
--   "<tt>Default</tt> <a>QueryRunner</a> <tt>columns</tt>
--   <tt>haskells</tt>" corresponds to postgresql-simple's
--   "<tt>FromRow</tt> <tt>haskells</tt>".
data QueryRunner columns haskells

-- | A <a>QueryRunnerColumn</a> <tt>pgType</tt> <tt>haskellType</tt>
--   encodes how to turn a value of Postgres type <tt>pgType</tt> into a
--   value of Haskell type <tt>haskellType</tt>. For example a value of
--   type <a>QueryRunnerColumn</a> <a>PGText</a> <a>String</a> encodes how
--   to turn a <a>PGText</a> result from the database into a Haskell
--   <a>String</a>.
--   
--   "<a>QueryRunnerColumn</a> <tt>pgType</tt> <tt>haskellType</tt>"
--   corresponds to postgresql-simple's "<a>FieldParser</a>
--   <tt>haskellType</tt>".
data QueryRunnerColumn pgType haskellType

-- | A <a>QueryRunnerColumnDefault</a> <tt>pgType</tt> <tt>haskellType</tt>
--   represents the default way to turn a <tt>pgType</tt> result from the
--   database into a Haskell value of type <tt>haskellType</tt>.
--   
--   "<a>QueryRunnerColumnDefault</a> <tt>pgType</tt> <tt>haskellType</tt>"
--   corresponds to postgresql-simple's "<a>FromField</a>
--   <tt>haskellType</tt>".
--   
--   Creating an instance of <a>QueryRunnerColumnDefault</a> for your own
--   types is necessary for retrieving those types from the database.
--   
--   You should use one of the three methods below for writing a
--   <a>QueryRunnerColumnDefault</a> instance.
--   
--   <ol>
--   <li>If you already have a <a>FromField</a> instance for your
--   <tt>haskellType</tt>, use <a>fieldQueryRunnerColumn</a>. (This is how
--   most of the built-in instances are defined.)</li>
--   <li>If you don't have a <a>FromField</a> instance, use
--   <a>queryRunnerColumn</a> if possible. See the documentation for
--   <a>queryRunnerColumn</a> for an example.</li>
--   <li>If you have a more complicated case, but not a <a>FromField</a>
--   instance, write a <a>FieldParser</a> for your type and use
--   <a>fieldParserQueryRunnerColumn</a>. You can also add a
--   <a>FromField</a> instance using this.</li>
--   </ol>
class QueryRunnerColumnDefault pgType haskellType
queryRunnerColumnDefault :: QueryRunnerColumnDefault pgType haskellType => QueryRunnerColumn pgType haskellType
fieldQueryRunnerColumn :: FromField haskell => FromField pgType haskell
fieldParserQueryRunnerColumn :: FieldParser haskell -> FromField pgType haskell

module Opaleye.SqlTypes
type SqlRange = PGRange
type SqlJsonb = PGJsonb
type SqlJson = PGJson
type SqlBytea = PGBytea
type SqlArray = PGArray
type SqlCitext = PGCitext
type SqlUuid = PGUuid
type SqlTimestamptz = PGTimestamptz
type SqlTimestamp = PGTimestamp
type SqlTime = PGTime
type SqlText = PGText
type SqlNumeric = PGNumeric
type SqlInt2 = PGInt2
type SqlInt4 = PGInt4
type SqlInt8 = PGInt8
type SqlFloat8 = PGFloat8
type SqlFloat4 = PGFloat4
type SqlDate = PGDate
type SqlBool = PGBool
sqlString :: String -> Field SqlText
sqlLazyByteString :: ByteString -> Field SqlBytea
sqlStrictByteString :: ByteString -> Field SqlBytea
sqlStrictText :: Text -> Field SqlText
sqlLazyText :: Text -> Field SqlText
sqlNumeric :: Scientific -> Field SqlNumeric
sqlInt4 :: Int -> Field SqlInt4
sqlInt8 :: Int64 -> Field SqlInt8
sqlDouble :: Double -> Field SqlFloat8
sqlBool :: Bool -> Field SqlBool
sqlUUID :: UUID -> Field SqlUuid
sqlDay :: Day -> Field SqlDate
sqlUTCTime :: UTCTime -> Field SqlTimestamptz
sqlLocalTime :: LocalTime -> Field SqlTimestamp
sqlZonedTime :: ZonedTime -> Field SqlTimestamptz
sqlTimeOfDay :: TimeOfDay -> Field SqlTime
sqlCiStrictText :: CI Text -> Field SqlCitext
sqlCiLazyText :: CI Text -> Field SqlCitext
sqlJSON :: String -> Field SqlJson
sqlStrictJSON :: ByteString -> Field SqlJson
sqlLazyJSON :: ByteString -> Field SqlJson
sqlValueJSON :: ToJSON a => a -> Field SqlJson
sqlJSONB :: String -> Field SqlJsonb
sqlStrictJSONB :: ByteString -> Field SqlJsonb
sqlLazyJSONB :: ByteString -> Field SqlJsonb
sqlValueJSONB :: ToJSON a => a -> Field SqlJsonb
sqlArray :: IsSqlType b => (a -> Field b) -> [a] -> Field (SqlArray b)
sqlRange :: IsRangeType b => (a -> Field b) -> RangeBound a -> RangeBound a -> Field (SqlRange b)
class IsSqlType sqlType
class IsSqlType pgType => IsRangeType pgType


-- | Ordering, <tt>LIMIT</tt>, <tt>OFFSET</tt> and <tt>DISTINCT ON</tt>
module Opaleye.Order

-- | Order the rows of a <a>Select</a> according to the <a>Order</a>.
--   
--   <pre>
--   import Data.Monoid ((&lt;&gt;))
--   
--   -- Order by the first column ascending.  When first columns are equal
--   -- order by second column descending.
--   example :: <a>Select</a> (<a>Column</a> <a>SqlInt4</a>, <a>Column</a> <a>SqlText</a>)
--           -&gt; <a>Select</a> (<a>Column</a> <a>SqlInt4</a>, <a>Column</a> <a>SqlText</a>)
--   example = <a>orderBy</a> (<a>asc</a> fst &lt;&gt; <a>desc</a> snd)
--   </pre>
orderBy :: Order a -> Select a -> Select a

-- | An <a>Order</a> <tt>a</tt> represents a sort order and direction for
--   the elements of the type <tt>a</tt>. Multiple <a>Order</a>s can be
--   composed with <a>mappend</a> or <tt>(&lt;&gt;)</tt> from
--   <a>Data.Monoid</a>. If two rows are equal according to the first
--   <a>Order</a> in the <tt>mappend</tt>, the second is used, and so on.
data Order a

-- | Specify an ascending ordering by the given expression. (Any NULLs
--   appear last)
asc :: SqlOrd b => (a -> Column b) -> Order a

-- | Specify an descending ordering by the given expression. (Any NULLs
--   appear first)
desc :: SqlOrd b => (a -> Column b) -> Order a

-- | Specify an ascending ordering by the given expression. (Any NULLs
--   appear first)
ascNullsFirst :: SqlOrd b => (a -> Column b) -> Order a

-- | Specify an descending ordering by the given expression. (Any NULLs
--   appear last)
descNullsLast :: SqlOrd b => (a -> Column b) -> Order a

-- | Limit the results of the given query to the given maximum number of
--   items.
--   
--   <i>WARNING:</i> If you're planning on using limit/offset together
--   please use <a>offset</a> <i>before</i> you use <a>limit</a>, e.g.:
--   
--   <pre>
--   limit 10 (offset 50 yourQuery)
--   </pre>
--   
--   This is because Opaleye applies OFFSET and LIMIT to the query
--   separately. The result of the query given above is the following,
--   which will return 10 rows after skipping the first 50 (probably what
--   you want).
--   
--   <pre>
--   SELECT * FROM (SELECT * FROM yourTable OFFSET 50) LIMIT 10
--   </pre>
--   
--   However, reversing the order of the limit/offset will result in the
--   following, which will result in <i>no rows being returned</i>
--   (probably not what you want).
--   
--   <pre>
--   SELECT * FROM (SELECT * FROM yourTable LIMIT 10) OFFSET 50
--   </pre>
limit :: Int -> Select a -> Select a

-- | Offset the results of the given query by the given amount, skipping
--   that many result rows.
--   
--   <i>WARNING:</i> Please read the documentation of <a>limit</a> before
--   combining <a>offset</a> with <a>limit</a>.
offset :: Int -> Select a -> Select a

-- | Keep a row from each set where the given function returns the same
--   result. No ordering is guaranteed. Mutliple fields may be
--   distinguished by projecting out tuples of <tt>Column</tt>s. Use
--   <a>distinctOnBy</a> to control how the rows are chosen.
distinctOn :: Default Unpackspec b b => (a -> b) -> Select a -> Select a

-- | Keep the row from each set where the given function returns the same
--   result. The row is chosen according to which comes first by the
--   supplied ordering. However, no output ordering is guaranteed. Mutliple
--   fields may be distinguished by projecting out tuples of
--   <tt>Column</tt>s.
distinctOnBy :: Default Unpackspec b b => (a -> b) -> Order a -> Select a -> Select a

-- | Order the results of a given query exactly, as determined by the given
--   list of input columns. Note that this list does not have to contain an
--   entry for every result in your query: you may exactly order only a
--   subset of results, if you wish. Rows that are not ordered according to
--   the input list are returned <i>after</i> the ordered results, in the
--   usual order the database would return them (e.g. sorted by primary
--   key). Exactly-ordered results always come first in a result set.
--   Entries in the input list that are <i>not</i> present in result of a
--   query are ignored.
exact :: [Column b] -> (a -> Column b) -> Order a

-- | Typeclass for Postgres types which support ordering operations.
class PGOrd a
type SqlOrd = PGOrd
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlBool
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlDate
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlFloat8
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlFloat4
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlInt8
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlInt4
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlInt2
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlNumeric
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlText
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlTime
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlTimestamptz
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlTimestamp
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlCitext
instance Opaleye.Order.PGOrd Opaleye.SqlTypes.SqlUuid
instance Opaleye.Order.PGOrd a => Opaleye.Order.PGOrd (Opaleye.Internal.Column.Nullable a)


-- | Left, right, and full outer joins.
--   
--   <a>Opaleye.FunctionalJoin</a> provides a much nicer, Haskelly,
--   interface to joins than this module, which sticks to the (horrible)
--   standard "make missing rows NULL" interface that SQL provides.
--   
--   If you want inner joins, just use <tt>restrict</tt> instead.
--   
--   The use of the <a>Default</a> typeclass means that the compiler will
--   have trouble inferring types. It is strongly recommended that you
--   provide full type signatures when using the join functions.
--   
--   Example specialization:
--   
--   <pre>
--   leftJoin :: Select (Column a, Column b)
--            -&gt; Select (Column c, Column (Nullable d))
--            -&gt; (((Column a, Column b), (Column c, Column (Nullable d))) -&gt; Column <a>SqlBool</a>)
--            -&gt; Select ((Column a, Column b), (Column (Nullable c), Column (Nullable d)))
--   </pre>
module Opaleye.Join
leftJoin :: (Default Unpackspec fieldsL fieldsL, Default Unpackspec fieldsR fieldsR, Default NullMaker fieldsR nullableFieldsR) => Select fieldsL -> Select fieldsR -> ((fieldsL, fieldsR) -> Field SqlBool) -> Select (fieldsL, nullableFieldsR)

-- | <a>leftJoinA</a> is a convenient way of using left joins within arrow
--   notation
leftJoinA :: (Default Unpackspec fieldsR fieldsR, Default NullMaker fieldsR nullableFieldsR) => Select fieldsR -> SelectArr (fieldsR -> Field SqlBool) nullableFieldsR
rightJoin :: (Default Unpackspec fieldsL fieldsL, Default Unpackspec fieldsR fieldsR, Default NullMaker fieldsL nullableFieldsL) => Select fieldsL -> Select fieldsR -> ((fieldsL, fieldsR) -> Field SqlBool) -> Select (nullableFieldsL, fieldsR)
fullJoin :: (Default Unpackspec fieldsL fieldsL, Default Unpackspec fieldsR fieldsR, Default NullMaker fieldsL nullableFieldsL, Default NullMaker fieldsR nullableFieldsR) => Select fieldsL -> Select fieldsR -> ((fieldsL, fieldsR) -> Field SqlBool) -> Select (nullableFieldsL, nullableFieldsR)
leftJoinExplicit :: Unpackspec fieldsL fieldsL -> Unpackspec fieldsR fieldsR -> NullMaker fieldsR nullableFieldsR -> Select fieldsL -> Select fieldsR -> ((fieldsL, fieldsR) -> Field SqlBool) -> Select (fieldsL, nullableFieldsR)
leftJoinAExplict :: Unpackspec fieldsR fieldsR -> NullMaker fieldsR nullableFieldsR -> Select fieldsR -> SelectArr (fieldsR -> Field SqlBool) nullableFieldsR
rightJoinExplicit :: Unpackspec fieldsL fieldsL -> Unpackspec fieldsR fieldsR -> NullMaker fieldsL nullableFieldsL -> Select fieldsL -> Select fieldsR -> ((fieldsL, fieldsR) -> Field SqlBool) -> Select (nullableFieldsL, fieldsR)
fullJoinExplicit :: Unpackspec fieldsL fieldsL -> Unpackspec fieldsR fieldsR -> NullMaker fieldsL nullableFieldsL -> NullMaker fieldsR nullableFieldsR -> Select fieldsL -> Select fieldsR -> ((fieldsL, fieldsR) -> Field SqlBool) -> Select (nullableFieldsL, nullableFieldsR)
leftJoinInferrable :: (Default Unpackspec columnsL columnsL, Default Unpackspec columnsR columnsR, Default NullMaker columnsR nullableColumnsR, Map Nulled columnsR ~ nullableColumnsR) => Query columnsL -> Query columnsR -> ((columnsL, columnsR) -> Column PGBool) -> Query (columnsL, nullableColumnsR)
rightJoinInferrable :: (Default Unpackspec columnsL columnsL, Default Unpackspec columnsR columnsR, Default NullMaker columnsL nullableColumnsL, Map Nulled columnsL ~ nullableColumnsL) => Query columnsL -> Query columnsR -> ((columnsL, columnsR) -> Column PGBool) -> Query (nullableColumnsL, columnsR)
fullJoinInferrable :: (Default Unpackspec columnsL columnsL, Default Unpackspec columnsR columnsR, Default NullMaker columnsL nullableColumnsL, Default NullMaker columnsR nullableColumnsR, Map Nulled columnsL ~ nullableColumnsL, Map Nulled columnsR ~ nullableColumnsR) => Query columnsL -> Query columnsR -> ((columnsL, columnsR) -> Column PGBool) -> Query (nullableColumnsL, nullableColumnsR)

module Opaleye.Constant

-- | <a>toFields</a> provides a convenient typeclass wrapper around the
--   <a>Column</a> creation functions in <a>Opaleye.SqlTypes</a>. Besides
--   convenience it doesn't provide any additional functionality.
--   
--   It can be used with functions like <a>runInsert</a> to insert custom
--   Haskell types into the database. The following is an example of a
--   function for inserting custom types.
--   
--   <pre>
--   customInsert
--      :: ( <a>Default</a> <a>Constant</a> haskells fields )
--      =&gt; Connection
--      -&gt; <a>Table</a> fields fields'
--      -&gt; haskells
--      -&gt; IO Int64
--   customInsert conn table haskells = <a>runInsert</a> conn table $ <a>toFields</a> haskells
--   </pre>
--   
--   In order to use this function with your custom types, you need to
--   define an instance of <a>Default</a> <a>Constant</a> for your custom
--   types.
toFields :: Default Constant haskells fields => haskells -> fields
constant :: Default Constant haskells fields => haskells -> fields
newtype Constant haskells fields
Constant :: (haskells -> fields) -> Constant haskells fields
[constantExplicit] :: Constant haskells fields -> haskells -> fields
type ToFields = Constant
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant haskell (Opaleye.Internal.Column.Column sql) => Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant (GHC.Maybe.Maybe haskell) (Opaleye.Internal.Column.Column (Opaleye.Internal.Column.Nullable sql))
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant GHC.Base.String (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlText)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.ByteString.Lazy.Internal.ByteString (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlBytea)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.ByteString.Internal.ByteString (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlBytea)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.Text.Internal.Text (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlText)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.Text.Internal.Lazy.Text (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlText)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.Scientific.Scientific (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlNumeric)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant GHC.Types.Int (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlInt4)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant GHC.Int.Int32 (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlInt4)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant GHC.Int.Int64 (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlInt8)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant GHC.Types.Double (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlFloat8)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant GHC.Types.Bool (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlBool)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.UUID.Types.Internal.UUID (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlUuid)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.Time.Calendar.Days.Day (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlDate)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.Time.Clock.Internal.UTCTime.UTCTime (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlTimestamptz)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.Time.LocalTime.Internal.LocalTime.LocalTime (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlTimestamp)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.Time.LocalTime.Internal.ZonedTime.ZonedTime (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlTimestamptz)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlTime)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant (Data.CaseInsensitive.Internal.CI Data.Text.Internal.Text) (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlCitext)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant (Data.CaseInsensitive.Internal.CI Data.Text.Internal.Lazy.Text) (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlCitext)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.ByteString.Internal.ByteString (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlJson)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.ByteString.Lazy.Internal.ByteString (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlJson)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.Aeson.Types.Internal.Value (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlJson)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.ByteString.Internal.ByteString (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlJsonb)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.ByteString.Lazy.Internal.ByteString (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlJsonb)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant Data.Aeson.Types.Internal.Value (Opaleye.Internal.Column.Column Opaleye.SqlTypes.SqlJsonb)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant haskell (Opaleye.Internal.Column.Column sql) => Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant (GHC.Maybe.Maybe haskell) (GHC.Maybe.Maybe (Opaleye.Internal.Column.Column sql))
instance (Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant a (Opaleye.Internal.Column.Column b), Opaleye.PGTypes.IsSqlType b) => Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant [a] (Opaleye.Internal.Column.Column (Opaleye.SqlTypes.SqlArray b))
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant (Database.PostgreSQL.Simple.Range.PGRange GHC.Types.Int) (Opaleye.Internal.Column.Column (Opaleye.SqlTypes.SqlRange Opaleye.SqlTypes.SqlInt4))
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant (Database.PostgreSQL.Simple.Range.PGRange GHC.Int.Int64) (Opaleye.Internal.Column.Column (Opaleye.SqlTypes.SqlRange Opaleye.SqlTypes.SqlInt8))
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant (Database.PostgreSQL.Simple.Range.PGRange Data.Scientific.Scientific) (Opaleye.Internal.Column.Column (Opaleye.SqlTypes.SqlRange Opaleye.SqlTypes.SqlNumeric))
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant (Database.PostgreSQL.Simple.Range.PGRange Data.Time.LocalTime.Internal.LocalTime.LocalTime) (Opaleye.Internal.Column.Column (Opaleye.SqlTypes.SqlRange Opaleye.SqlTypes.SqlTimestamp))
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant (Database.PostgreSQL.Simple.Range.PGRange Data.Time.Clock.Internal.UTCTime.UTCTime) (Opaleye.Internal.Column.Column (Opaleye.SqlTypes.SqlRange Opaleye.SqlTypes.SqlTimestamptz))
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Constant.Constant (Database.PostgreSQL.Simple.Range.PGRange Data.Time.Calendar.Days.Day) (Opaleye.Internal.Column.Column (Opaleye.SqlTypes.SqlRange Opaleye.SqlTypes.SqlDate))
instance GHC.Base.Functor (Opaleye.Constant.Constant a)
instance GHC.Base.Applicative (Opaleye.Constant.Constant a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Constant.Constant
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Constant.Constant
instance Data.Profunctor.Product.Class.SumProfunctor Opaleye.Constant.Constant


-- | Perform aggregation on <a>Select</a>s. To aggregate a <a>Select</a>
--   you should construct an <a>Aggregator</a> encoding how you want the
--   aggregation to proceed, then call <a>aggregate</a> on it. The
--   <a>Aggregator</a> should be constructed from the basic
--   <a>Aggregator</a>s below by using the combining operations from
--   <a>Data.Profunctor.Product</a>.
module Opaleye.Aggregate

-- | Given a <a>Select</a> producing rows of type <tt>a</tt> and an
--   <a>Aggregator</a> accepting rows of type <tt>a</tt>, apply the
--   aggregator to the query.
--   
--   If you simply want to count the number of rows in a query you might
--   find the <a>countRows</a> function more convenient.
--   
--   By design there is no aggregation function of type <tt>Aggregator b b'
--   -&gt; <a>SelectArr</a> a b -&gt; <a>SelectArr</a> a b'</tt>. Such a
--   function would allow violation of SQL's scoping rules and lead to
--   invalid queries.
--   
--   Please note that when aggregating an empty query with no <tt>GROUP
--   BY</tt> clause, Opaleye's behaviour differs from Postgres's behaviour.
--   Postgres returns a single row whereas Opaleye returns zero rows.
--   Opaleye's behaviour is consistent with the meaning of aggregating over
--   groups of rows and Postgres's behaviour is inconsistent. When a query
--   has zero rows it has zero groups, and thus zero rows in the result of
--   an aggregation.
aggregate :: Aggregator a b -> Select a -> Select b

-- | An <a>Aggregator</a> takes a collection of rows of type <tt>a</tt>,
--   groups them, and transforms each group into a single row of type
--   <tt>b</tt>. This corresponds to aggregators using <tt>GROUP BY</tt> in
--   SQL.
--   
--   You should combine basic <a>Aggregator</a>s into <a>Aggregator</a>s on
--   compound types by using the operations in
--   <a>Data.Profunctor.Product</a>.
--   
--   An <a>Aggregator</a> corresponds closely to a <a>Fold</a> from the
--   <tt>foldl</tt> package. Whereas an <a>Aggregator</a> <tt>a</tt>
--   <tt>b</tt> takes each group of type <tt>a</tt> to a single row of type
--   <tt>b</tt>, a <a>Fold</a> <tt>a</tt> <tt>b</tt> takes a list of
--   <tt>a</tt> and returns a single value of type <tt>b</tt>.
data Aggregator a b

-- | Group the aggregation by equality on the input to <a>groupBy</a>.
groupBy :: Aggregator (Column a) (Column a)

-- | Sum all rows in a group.
sum :: Aggregator (Column a) (Column a)

-- | Count the number of non-null rows in a group.
count :: Aggregator (Column a) (Column SqlInt8)

-- | Count the number of rows in a group. This <a>Aggregator</a> is named
--   <tt>countStar</tt> after SQL's <tt>COUNT(*)</tt> aggregation function.
countStar :: Aggregator a (Column SqlInt8)

-- | Average of a group
avg :: Aggregator (Column SqlFloat8) (Column SqlFloat8)

-- | Maximum of a group
max :: SqlOrd a => Aggregator (Column a) (Column a)

-- | Maximum of a group
min :: SqlOrd a => Aggregator (Column a) (Column a)
boolOr :: Aggregator (Column SqlBool) (Column SqlBool)
boolAnd :: Aggregator (Column SqlBool) (Column SqlBool)
arrayAgg :: Aggregator (Column a) (Column (SqlArray a))
stringAgg :: Column SqlText -> Aggregator (Column SqlText) (Column SqlText)

-- | Count the number of rows in a query. This is different from
--   <a>aggregate</a> <a>count</a> because it always returns exactly one
--   row, even when the input query is empty.
countRows :: Select a -> Select (Column SqlInt8)

-- | Given a <a>Select</a> producing rows of type <tt>a</tt> and an
--   <a>Aggregator</a> accepting rows of type <tt>a</tt>, apply the
--   aggregator to the query.
--   
--   If you simply want to count the number of rows in a query you might
--   find the <a>countRows</a> function more convenient.
--   
--   By design there is no aggregation function of type <tt>Aggregator b b'
--   -&gt; <a>SelectArr</a> a b -&gt; <a>SelectArr</a> a b'</tt>. Such a
--   function would allow violation of SQL's scoping rules and lead to
--   invalid queries.
--   
--   Please note that when aggregating an empty query with no <tt>GROUP
--   BY</tt> clause, Opaleye's behaviour differs from Postgres's behaviour.
--   Postgres returns a single row whereas Opaleye returns zero rows.
--   Opaleye's behaviour is consistent with the meaning of aggregating over
--   groups of rows and Postgres's behaviour is inconsistent. When a query
--   has zero rows it has zero groups, and thus zero rows in the result of
--   an aggregation.
aggregate :: Aggregator a b -> Select a -> Select b

-- | Order the values within each aggregation in <a>Aggregator</a> using
--   the given ordering. This is only relevant for aggregations that depend
--   on the order they get their elements, like <a>arrayAgg</a> and
--   <a>stringAgg</a>.
--   
--   Note that this orders all aggregations with the same ordering. If you
--   need different orderings for different aggregations, use
--   <a>orderAggregate</a>.
aggregateOrdered :: Order a -> Aggregator a b -> Select a -> Select b

-- | Aggregate only distinct values
distinctAggregator :: Aggregator a b -> Aggregator a b

-- | Group the aggregation by equality on the input to <a>groupBy</a>.
groupBy :: Aggregator (Column a) (Column a)

-- | Sum all rows in a group.
sum :: Aggregator (Column a) (Column a)

-- | Count the number of non-null rows in a group.
count :: Aggregator (Column a) (Column SqlInt8)

-- | Count the number of rows in a group. This <a>Aggregator</a> is named
--   <tt>countStar</tt> after SQL's <tt>COUNT(*)</tt> aggregation function.
countStar :: Aggregator a (Column SqlInt8)

-- | Average of a group
avg :: Aggregator (Column SqlFloat8) (Column SqlFloat8)

-- | Maximum of a group
max :: SqlOrd a => Aggregator (Column a) (Column a)

-- | Maximum of a group
min :: SqlOrd a => Aggregator (Column a) (Column a)
boolOr :: Aggregator (Column SqlBool) (Column SqlBool)
boolAnd :: Aggregator (Column SqlBool) (Column SqlBool)
arrayAgg :: Aggregator (Column a) (Column (SqlArray a))
stringAgg :: Column SqlText -> Aggregator (Column SqlText) (Column SqlText)

-- | Count the number of rows in a query. This is different from
--   <a>aggregate</a> <a>count</a> because it always returns exactly one
--   row, even when the input query is empty.
countRows :: Select a -> Select (Column SqlInt8)

module Opaleye.Internal.Distinct
distinctExplicit :: Distinctspec columns columns' -> Query columns -> Query columns'
newtype Distinctspec a b
Distinctspec :: Aggregator a b -> Distinctspec a b
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Distinct.Distinctspec (Opaleye.Internal.Column.Column a) (Opaleye.Internal.Column.Column a)
instance GHC.Base.Functor (Opaleye.Internal.Distinct.Distinctspec a)
instance GHC.Base.Applicative (Opaleye.Internal.Distinct.Distinctspec a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Distinct.Distinctspec
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Distinct.Distinctspec
instance Data.Profunctor.Product.Class.SumProfunctor Opaleye.Internal.Distinct.Distinctspec

module Opaleye.Distinct

-- | Remove duplicate rows from the <a>Select</a>.
--   
--   Example type specialization:
--   
--   <pre>
--   distinct :: Select (Column a, Column b) -&gt; Select (Column a, Column b)
--   </pre>
--   
--   Assuming the <tt>makeAdaptorAndInstance</tt> splice has been run for
--   the product type <tt>Foo</tt>:
--   
--   <pre>
--   distinct :: Select (Foo (Column a) (Column b) (Column c)) -&gt; Select (Foo (Column a) (Column b) (Column c))
--   </pre>
--   
--   By design there is no <tt>distinct</tt> function of type <tt>SelectArr
--   a b -&gt; SelectArr a b</tt>. Such a function would allow violation of
--   SQL's scoping rules and lead to invalid queries.
distinct :: Default Distinctspec fields fields => Select fields -> Select fields
distinctExplicit :: Distinctspec columns columns' -> Query columns -> Query columns'


-- | Operators on <a>Column</a>s. Please note that numeric <a>Column</a>
--   types are instances of <a>Num</a>, so you can use <a>*</a>, <a>/</a>,
--   <a>+</a>, <a>-</a> on them.
module Opaleye.Operators
type SqlJsonIndex = PGJsonIndex

-- | Class of Postgres types that can be used to index json values.
--   
--   Warning: making additional instances of this class can lead to broken
--   code!
class PGJsonIndex a
type SqlIsJson = PGIsJson

-- | Class of Postgres types that represent json values. Used to overload
--   functions and operators that work on both <a>SqlJson</a> and
--   <a>SqlJsonb</a>.
--   
--   Warning: making additional instances of this class can lead to broken
--   code!
class PGIsJson a

-- | Keep only the rows of a query satisfying a given condition, using an
--   SQL <tt>WHERE</tt> clause.
--   
--   You would typically use <a>restrict</a> if you want to write your
--   query using <a>Arrow</a> notation. If you want to use a "point free"
--   style then <a>keepWhen</a> will suit you better.
--   
--   (If you are familiar with <a>MonadPlus</a> or <a>Alternative</a> it
--   may help you to know that <a>restrict</a> corresponds to the
--   <a>guard</a> function.)
restrict :: SelectArr (Field SqlBool) ()

-- | Add a <tt>WHERE EXISTS</tt> clause to the current query.
restrictExists :: SelectArr a b -> SelectArr a ()

-- | Add a <tt>WHERE NOT EXISTS</tt> clause to the current query.
restrictNotExists :: SelectArr a b -> SelectArr a ()

-- | Keep only the rows of a query satisfying a given condition, using an
--   SQL <tt>WHERE</tt> clause.
--   
--   You would typically use <a>keepWhen</a> if you want to write your
--   query using a "point free" style. If you want to use <a>Arrow</a>
--   notation then <a>restrict</a> will suit you better.
--   
--   This is the <a>SelectArr</a> equivalent of <a>filter</a> from the
--   <tt>Prelude</tt>.
keepWhen :: (a -> Field SqlBool) -> SelectArr a a
(.==) :: Column a -> Column a -> Field SqlBool
infix 4 .==
(./=) :: Column a -> Column a -> Field SqlBool
infix 4 ./=

-- | A polymorphic equality operator that works for all types that you have
--   run <tt>makeAdaptorAndInstance</tt> on. This may be unified with
--   <a>.==</a> in a future version.
(.===) :: Default EqPP fields fields => fields -> fields -> Field SqlBool
infix 4 .===

-- | A polymorphic inequality operator that works for all types that you
--   have run <tt>makeAdaptorAndInstance</tt> on. This may be unified with
--   <a>./=</a> in a future version.
(./==) :: Default EqPP fields fields => fields -> fields -> Field SqlBool
infix 4 ./==
(.>) :: SqlOrd a => Column a -> Column a -> Field SqlBool
infix 4 .>
(.<) :: SqlOrd a => Column a -> Column a -> Field SqlBool
infix 4 .<
(.<=) :: SqlOrd a => Column a -> Column a -> Field SqlBool
infix 4 .<=
(.>=) :: SqlOrd a => Column a -> Column a -> Field SqlBool
infix 4 .>=

-- | Integral division, named after <a>quot</a>. It maps to the <tt>/</tt>
--   operator in Postgres.
quot_ :: SqlIntegral a => Column a -> Column a -> Column a

-- | The remainder of integral division, named after <a>rem</a>. It maps to
--   <tt>MOD</tt> (<tt>%</tt>) in Postgres, confusingly described as
--   "modulo (remainder)".
rem_ :: SqlIntegral a => Column a -> Column a -> Column a

-- | Select the first case for which the condition is true.
case_ :: [(Field SqlBool, Column a)] -> Column a -> Column a

-- | Monomorphic if/then/else.
--   
--   This may be replaced by <a>ifThenElseMany</a> in a future version.
ifThenElse :: Field SqlBool -> Column a -> Column a -> Column a

-- | Polymorphic if/then/else.
ifThenElseMany :: Default IfPP fields fields => Field SqlBool -> fields -> fields -> fields

-- | Boolean or
(.||) :: Field SqlBool -> Field SqlBool -> Field SqlBool
infixr 2 .||

-- | Boolean and
(.&&) :: Field SqlBool -> Field SqlBool -> Field SqlBool
infixr 3 .&&

-- | Boolean not
not :: Field SqlBool -> Field SqlBool

-- | True when any element of the container is true
ors :: Foldable f => f (Field SqlBool) -> Field SqlBool

-- | Concatenate <a>Field</a> <a>SqlText</a>
(.++) :: Field SqlText -> Field SqlText -> Field SqlText

-- | To lowercase
lower :: Field SqlText -> Field SqlText

-- | To uppercase
upper :: Field SqlText -> Field SqlText

-- | Postgres <tt>LIKE</tt> operator
like :: Field SqlText -> Field SqlText -> Field SqlBool

-- | Postgres <tt>ILIKE</tt> operator
ilike :: Field SqlText -> Field SqlText -> Field SqlBool
charLength :: PGString a => Column a -> Column Int

-- | <a>in_</a> is designed to be used in prefix form.
--   
--   <a>in_</a> <tt>validProducts</tt> <tt>product</tt> checks whether
--   <tt>product</tt> is a valid product. <a>in_</a> <tt>validProducts</tt>
--   is a function which checks whether a product is a valid product.
in_ :: (Functor f, Foldable f) => f (Column a) -> Column a -> Field SqlBool

-- | True if the first argument occurs amongst the rows of the second,
--   false otherwise.
--   
--   This operation is equivalent to Postgres's <tt>IN</tt> operator but,
--   for expediency, is currently implemented using a <tt>LEFT JOIN</tt>.
--   Please file a bug if this causes any issues in practice.
inQuery :: Default EqPP fields fields => fields -> Query fields -> Select (Field SqlBool)

-- | Get JSON object field by key.
(.->) :: (SqlIsJson a, SqlJsonIndex k) => FieldNullable a -> Field k -> FieldNullable a
infixl 8 .->

-- | Get JSON object field as text.
(.->>) :: (SqlIsJson a, SqlJsonIndex k) => FieldNullable a -> Field k -> FieldNullable SqlText
infixl 8 .->>

-- | Get JSON object at specified path.
(.#>) :: SqlIsJson a => FieldNullable a -> Column (SqlArray SqlText) -> FieldNullable a
infixl 8 .#>

-- | Get JSON object at specified path as text.
(.#>>) :: SqlIsJson a => FieldNullable a -> Column (SqlArray SqlText) -> FieldNullable SqlText
infixl 8 .#>>

-- | Does the left JSON value contain within it the right value?
(.@>) :: Field SqlJsonb -> Field SqlJsonb -> Field SqlBool
infix 4 .@>

-- | Is the left JSON value contained within the right value?
(.<@) :: Field SqlJsonb -> Field SqlJsonb -> Field SqlBool
infix 4 .<@

-- | Does the key/element string exist within the JSON value?
(.?) :: Field SqlJsonb -> Field SqlText -> Field SqlBool
infix 4 .?

-- | Do any of these key/element strings exist?
(.?|) :: Field SqlJsonb -> Column (SqlArray SqlText) -> Field SqlBool
infix 4 .?|

-- | Do all of these key/element strings exist?
(.?&) :: Field SqlJsonb -> Column (SqlArray SqlText) -> Field SqlBool
infix 4 .?&
emptyArray :: IsSqlType a => Column (SqlArray a)
arrayPrepend :: Column a -> Column (SqlArray a) -> Column (SqlArray a)
singletonArray :: IsSqlType a => Column a -> Column (SqlArray a)
index :: SqlIntegral n => Column (SqlArray a) -> Column n -> Column (Nullable a)
overlap :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
liesWithin :: IsRangeType a => Column a -> Column (SqlRange a) -> Field SqlBool

-- | Access the upper bound of a range. For discrete range types it is the
--   exclusive bound.
upperBound :: IsRangeType a => Column (SqlRange a) -> Column (Nullable a)

-- | Access the lower bound of a range. For discrete range types it is the
--   inclusive bound.
lowerBound :: IsRangeType a => Column (SqlRange a) -> Column (Nullable a)
(.<<) :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
infix 4 .<<
(.>>) :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
infix 4 .>>
(.&<) :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
infix 4 .&<
(.&>) :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
infix 4 .&>
(.-|-) :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
infix 4 .-|-
timestamptzAtTimeZone :: Field SqlTimestamptz -> Field SqlText -> Field SqlTimestamp

-- | <i>Deprecated: Use <a>unsafeCast</a> instead. Will be removed in
--   version 0.7.</i>
doubleOfInt :: Field SqlInt4 -> Field SqlFloat8

-- | Identical to <a>restrictExists</a>. Will be deprecated in version 0.7.
exists :: QueryArr a b -> QueryArr a ()

-- | Identical to <a>restrictNotExists</a>. Will be deprecated in version
--   0.7.
notExists :: QueryArr a b -> QueryArr a ()
instance Opaleye.Operators.PGJsonIndex Opaleye.SqlTypes.SqlInt4
instance Opaleye.Operators.PGJsonIndex Opaleye.SqlTypes.SqlInt8
instance Opaleye.Operators.PGJsonIndex Opaleye.SqlTypes.SqlText
instance Opaleye.Operators.PGIsJson Opaleye.SqlTypes.SqlJson
instance Opaleye.Operators.PGIsJson Opaleye.SqlTypes.SqlJsonb


-- | Left, right, and full outer joins.
--   
--   The interface in this module is much nicer than the standard "make
--   missing rows NULL" interface that SQL provides. If you really want the
--   standard interface then use <a>Opaleye.Join</a>.
module Opaleye.FunctionalJoin
joinF :: (fieldsL -> fieldsR -> fieldsResult) -> (fieldsL -> fieldsR -> Field SqlBool) -> Select fieldsL -> Select fieldsR -> Select fieldsResult
leftJoinF :: (Default IfPP fieldsResult fieldsResult, Default Unpackspec fieldsL fieldsL, Default Unpackspec fieldsR fieldsR) => (fieldsL -> fieldsR -> fieldsResult) -> (fieldsL -> fieldsResult) -> (fieldsL -> fieldsR -> Field SqlBool) -> Select fieldsL -> Select fieldsR -> Select fieldsResult
rightJoinF :: (Default IfPP fieldsResult fieldsResult, Default Unpackspec fieldsL fieldsL, Default Unpackspec fieldsR fieldsR) => (fieldsL -> fieldsR -> fieldsResult) -> (fieldsR -> fieldsResult) -> (fieldsL -> fieldsR -> Field SqlBool) -> Select fieldsL -> Select fieldsR -> Select fieldsResult
fullJoinF :: (Default IfPP fieldsResult fieldsResult, Default Unpackspec fieldsL fieldsL, Default Unpackspec fieldsR fieldsR) => (fieldsL -> fieldsR -> fieldsResult) -> (fieldsL -> fieldsResult) -> (fieldsR -> fieldsResult) -> (fieldsL -> fieldsR -> Field SqlBool) -> Select fieldsL -> Select fieldsR -> Select fieldsResult


-- | Columns can be required or optional and, independently, nullable or
--   non-nullable.
--   
--   A required non-nullable <tt>SqlInt4</tt> (for example) is created with
--   <tt>required</tt> and gives rise to a
--   
--   <pre>
--   TableFields (Column SqlInt4) (Column SqlInt4)
--   </pre>
--   
--   The leftmost argument is the type of writes. When you insert or update
--   into this column you must give it a <tt>Column SqlInt4</tt> (which you
--   can create with <tt>sqlInt4 :: Int -&gt; Column SqlInt4</tt>).
--   
--   A required nullable <tt>SqlInt4</tt> is created with <tt>required</tt>
--   and gives rise to a
--   
--   <pre>
--   TableFields (Column (Nullable SqlInt4)) (Column (Nullable SqlInt4))
--   </pre>
--   
--   When you insert or update into this column you must give it a
--   <tt>Column (Nullable SqlInt4)</tt>, which you can create either with
--   <tt>sqlInt4</tt> and <tt>toNullable :: Column a -&gt; Column (Nullable
--   a)</tt>, or with <tt>null :: Column (Nullable a)</tt>.
--   
--   An optional non-nullable <tt>SqlInt4</tt> is created with
--   <tt>optional</tt> and gives rise to a
--   
--   <pre>
--   TableFields (Maybe (Column SqlInt4)) (Column SqlInt4)
--   </pre>
--   
--   Optional columns are those that can be omitted on writes, such as
--   those that have <tt>DEFAULT</tt>s or those that are <tt>SERIAL</tt>.
--   When you insert or update into this column you must give it a
--   <tt>Maybe (Column SqlInt4)</tt>. If you provide <tt>Nothing</tt> then
--   the column will be omitted from the query and the default value will
--   be used. Otherwise you have to provide a <tt>Just</tt> containing a
--   <tt>Column SqlInt4</tt>.
--   
--   An optional nullable <tt>SqlInt4</tt> is created with
--   <tt>optional</tt> and gives rise to a
--   
--   <pre>
--   TableFields (Maybe (Column (Nullable SqlInt4))) (Column (Nullable SqlInt4))
--   </pre>
--   
--   Optional columns are those that can be omitted on writes, such as
--   those that have <tt>DEFAULT</tt>s or those that are <tt>SERIAL</tt>.
--   When you insert or update into this column you must give it a
--   <tt>Maybe (Column (Nullable SqlInt4))</tt>. If you provide
--   <tt>Nothing</tt> then the default value will be used. Otherwise you
--   have to provide a <tt>Just</tt> containing a <tt>Column (Nullable
--   SqlInt4)</tt> (which can be null).
module Opaleye.Table

-- | Create a table with unqualified names.
table :: String -> TableFields writeFields viewFields -> Table writeFields viewFields

-- | Create a table.
tableWithSchema :: String -> String -> TableFields writeFields viewFields -> Table writeFields viewFields
data Table writerColumns viewColumns

-- | Infer either a <a>required</a> or <a>optional</a> column depending on
--   the write type. It's generally more convenient to use this than
--   <a>required</a> or <a>optional</a> but you do have to provide a type
--   signature instead.
tableColumn :: TableColumn writeType sqlType => String -> TableFields writeType (Column sqlType)
tableField :: TableColumn writeType sqlType => String -> TableFields writeType (Column sqlType)

-- | <a>optional</a> is for columns that you can omit on writes, such as
--   columns which have defaults or which are SERIAL.
optional :: String -> TableFields (Maybe (Column a)) (Column a)

-- | <a>required</a> is for columns which are not <a>optional</a>. You must
--   provide them on writes.
required :: String -> TableFields (Column a) (Column a)

-- | Example type specialization:
--   
--   <pre>
--   selectTable :: Table w (Column a, Column b)
--               -&gt; Select (Column a, Column b)
--   </pre>
--   
--   Assuming the <tt>makeAdaptorAndInstance</tt> splice has been run for
--   the product type <tt>Foo</tt>:
--   
--   <pre>
--   selectTable :: Table w (Foo (Column a) (Column b) (Column c))
--               -&gt; Select (Foo (Column a) (Column b) (Column c))
--   </pre>
selectTable :: Default Unpackspec fields fields => Table a fields -> Select fields

-- | Use <a>TableFields</a> instead. <a>TableColumns</a> will be deprecated
--   in version 0.7.
type TableColumns = TableProperties

-- | The new name for <a>TableColumns</a> and <a>TableProperties</a> which
--   will replace them in version 0.7.
type TableFields = TableProperties

-- | Internal only. Do not use. <a>View</a> will be deprecated in version
--   0.7.
data View columns

-- | Internal only. Do not use. <a>Writer</a> will be deprecated in version
--   0.7.
data Writer columns dummy
data Table writerColumns viewColumns

-- | For unqualified table names. Do not use the constructor. It is
--   internal and will be deprecated in version 0.7.
Table :: String -> TableFields writerColumns viewColumns -> Table writerColumns viewColumns

-- | Schema name, table name, table properties. Do not use the constructor.
--   It is internal and will be deprecated in version 0.7.
TableWithSchema :: String -> String -> TableFields writerColumns viewColumns -> Table writerColumns viewColumns

-- | Example type specialization:
--   
--   <pre>
--   selectTable :: Table w (Column a, Column b)
--               -&gt; Select (Column a, Column b)
--   </pre>
--   
--   Assuming the <tt>makeAdaptorAndInstance</tt> splice has been run for
--   the product type <tt>Foo</tt>:
--   
--   <pre>
--   selectTable :: Table w (Foo (Column a) (Column b) (Column c))
--               -&gt; Select (Foo (Column a) (Column b) (Column c))
--   </pre>
selectTable :: Default Unpackspec fields fields => Table a fields -> Select fields

-- | Create a table with unqualified names.
table :: String -> TableFields writeFields viewFields -> Table writeFields viewFields

-- | Create a table.
tableWithSchema :: String -> String -> TableFields writeFields viewFields -> Table writeFields viewFields
selectTableExplicit :: Unpackspec tablefields fields -> Table a tablefields -> Select fields

-- | Use <a>selectTable</a> instead. Will be deprecated in version 0.7.
queryTable :: Default Unpackspec fields fields => Table a fields -> Select fields

-- | Use <a>selectTableExplicit</a> instead. Will be deprecated in version
--   0.7.
queryTableExplicit :: Unpackspec tablefields fields -> Table a tablefields -> Select fields

module Opaleye.Internal.Manipulation

-- | Don't use this internal datatype. Instead you probably want
--   <a>rCount</a> or <a>rReturning</a>.
data Returning a b
[Count] :: Returning a Int64
[Returning] :: Default QueryRunner b c => (a -> b) -> Returning a [c]
[ReturningExplicit] :: QueryRunner b c -> (a -> b) -> Returning a [c]
arrangeInsertMany :: Table columns a -> NonEmpty columns -> Maybe OnConflict -> SqlInsert
arrangeInsertManyReturning :: Unpackspec columnsReturned ignored -> Table columnsW columnsR -> NonEmpty columnsW -> (columnsR -> columnsReturned) -> Maybe OnConflict -> Returning SqlInsert
arrangeInsertManyReturningSql :: Unpackspec columnsReturned ignored -> Table columnsW columnsR -> NonEmpty columnsW -> (columnsR -> columnsReturned) -> Maybe OnConflict -> String
arrangeInsertManySql :: Table columnsW columnsR -> NonEmpty columnsW -> Maybe OnConflict -> String
runInsertManyReturningExplicit :: QueryRunner columnsReturned haskells -> Connection -> Table columnsW columnsR -> [columnsW] -> (columnsR -> columnsReturned) -> Maybe OnConflict -> IO [haskells]
newtype Updater a b
Updater :: (a -> b) -> Updater a b
instance GHC.Base.Functor (Opaleye.Internal.Manipulation.Updater a)
instance GHC.Base.Applicative (Opaleye.Internal.Manipulation.Updater a)
instance Data.Profunctor.Unsafe.Profunctor Opaleye.Internal.Manipulation.Updater
instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.Internal.Manipulation.Updater
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Manipulation.Updater (Opaleye.Internal.Column.Column a) (Opaleye.Internal.Column.Column a)
instance Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Manipulation.Updater (Opaleye.Internal.Column.Column a) (GHC.Maybe.Maybe (Opaleye.Internal.Column.Column a))


-- | Inserts, updates and deletes
--   
--   Please note that Opaleye currently only supports INSERT or UPDATE with
--   constant values, not the result of SELECTs. That is, you can generate
--   SQL of the form
--   
--   <pre>
--   INSERT INTO thetable (<tt>John</tt>, 1);
--   </pre>
--   
--   but not
--   
--   <pre>
--   INSERT INTO thetable
--      SELECT <tt>John</tt>,
--      (SELECT num FROM thetable ORDER BY num DESC LIMIT 1) + 1;
--   </pre>
module Opaleye.Manipulation
data Delete haskells
Delete :: Table fieldsW fieldsR -> (fieldsR -> Field SqlBool) -> Returning fieldsR Int64 -> Delete haskells
[dTable] :: Delete haskells -> Table fieldsW fieldsR
[dWhere] :: Delete haskells -> fieldsR -> Field SqlBool
[dReturning] :: Delete haskells -> Returning fieldsR Int64
data Update haskells
Update :: Table fieldsW fieldsR -> (fieldsR -> fieldsW) -> (fieldsR -> Field SqlBool) -> Returning fieldsR haskells -> Update haskells
[uTable] :: Update haskells -> Table fieldsW fieldsR

-- | Be careful: providing <a>Nothing</a> to a column created by
--   <a>optional</a> updates the column to its default value. Many users
--   have been confused by this because they assume it means that the
--   column is to be left unchanged. For an easier time wrap your update
--   function in <a>updateEasy</a>.
[uUpdateWith] :: Update haskells -> fieldsR -> fieldsW
[uWhere] :: Update haskells -> fieldsR -> Field SqlBool
[uReturning] :: Update haskells -> Returning fieldsR haskells
data Insert haskells
Insert :: Table fieldsW fieldsR -> [fieldsW] -> Returning fieldsR haskells -> Maybe OnConflict -> Insert haskells
[iTable] :: Insert haskells -> Table fieldsW fieldsR
[iRows] :: Insert haskells -> [fieldsW]
[iReturning] :: Insert haskells -> Returning fieldsR haskells

-- | NB There is a clash of terminology between Haskell and Postgres.
--   
--   <ul>
--   <li><a>iOnConflict</a> <tt>=</tt> <a>Nothing</a> means omit <tt>ON
--   CONFLICT</tt> statement</li>
--   <li><a>iOnConflict</a> <tt>=</tt> <a>Just</a> <a>DoNothing</a> means
--   <tt>ON CONFLICT DO NOTHING</tt></li>
--   </ul>
[iOnConflict] :: Insert haskells -> Maybe OnConflict

-- | Run the <a>Insert</a>. To create an <a>Insert</a> use the
--   <a>Insert</a> constructor.
runInsert_ :: Connection -> Insert haskells -> IO haskells

-- | Run the <a>Update</a>. To create an <a>Update</a> use the
--   <a>Update</a> constructor.
runUpdate_ :: Connection -> Update haskells -> IO haskells

-- | Run the <a>Delete</a>. To create an <a>Delete</a> use the
--   <a>Delete</a> constructor.
runDelete_ :: Connection -> Delete Int64 -> IO Int64

-- | A convenient wrapper for writing your update function
--   
--   <pre>
--   uUpdateWith = updateEasy (\... -&gt; ...)
--   </pre>
updateEasy :: Default Updater fieldsR fieldsW => (fieldsR -> fieldsR) -> fieldsR -> fieldsW

-- | Return the number of rows inserted or updated
rCount :: Returning fieldsR Int64

-- | Return a function of the inserted or updated rows
--   
--   <tt>rReturning'</tt>s use of the <a>Default</a> typeclass means that
--   the compiler will have trouble inferring types. It is strongly
--   recommended that you provide full type signatures when using
--   <a>rReturning</a>.
rReturning :: Default QueryRunner fields haskells => (fieldsR -> fields) -> Returning fieldsR [haskells]

-- | Return a function of the inserted or updated rows. Explicit version.
--   You probably just want to use <a>rReturning</a> instead.
rReturningExplicit :: QueryRunner fields haskells -> (fieldsR -> fields) -> Returning fieldsR [haskells]

-- | Returns the number of rows inserted

-- | <i>Deprecated: <a>runInsert</a> will be removed in version 0.7. Use
--   <a>runInsertMany</a> instead.</i>
runInsert :: Connection -> Table fields fields' -> fields -> IO Int64

-- | <tt>runInsertReturning</tt>'s use of the <a>Default</a> typeclass
--   means that the compiler will have trouble inferring types. It is
--   strongly recommended that you provide full type signatures when using
--   <tt>runInsertReturning</tt>.

-- | <i>Deprecated: <a>runInsertReturning</a> will be removed in version
--   0.7. Use <a>runInsertManyReturning</a> instead.</i>
runInsertReturning :: Default QueryRunner fieldsReturned haskells => Connection -> Table fieldsW fieldsR -> fieldsW -> (fieldsR -> fieldsReturned) -> IO [haskells]

-- | <i>Deprecated: You probably want <a>runInsertMany</a> instead. Will be
--   removed in version 0.7.</i>
arrangeInsert :: Table columns a -> columns -> SqlInsert

-- | <i>Deprecated: You probably want <a>runInsertMany</a> instead. Will be
--   removed in version 0.7.</i>
arrangeInsertSql :: Table columns a -> columns -> String

-- | <i>Deprecated: You probably want <a>runInsertMany</a> instead. Will be
--   removed in version 0.7.</i>
arrangeInsertMany :: Table columns a -> NonEmpty columns -> SqlInsert

-- | <i>Deprecated: You probably want <a>runInsertMany</a> instead. Will be
--   removed in version 0.7.</i>
arrangeInsertManySql :: Table columns a -> NonEmpty columns -> String

-- | <i>Deprecated: You probably want <a>runUpdate</a> instead. Will be
--   removed in version 0.7.</i>
arrangeUpdate :: Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column SqlBool) -> SqlUpdate

-- | <i>Deprecated: You probably want <a>runUpdate</a> instead. Will be
--   removed in version 0.7.</i>
arrangeUpdateSql :: Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column SqlBool) -> String

-- | <i>Deprecated: You probably want <a>runDelete</a> instead. Will be
--   removed in version 0.7.</i>
arrangeDelete :: Table a columnsR -> (columnsR -> Column SqlBool) -> SqlDelete

-- | <i>Deprecated: You probably want <a>runDelete</a> instead. Will be
--   removed in version 0.7.</i>
arrangeDeleteSql :: Table a columnsR -> (columnsR -> Column SqlBool) -> String

-- | <i>Deprecated: You probably want <a>runInsertMany</a> instead. Will be
--   removed in version 0.7.</i>
arrangeInsertManyReturning :: Unpackspec columnsReturned ignored -> Table columnsW columnsR -> NonEmpty columnsW -> (columnsR -> columnsReturned) -> Returning SqlInsert

-- | <i>Deprecated: You probably want <a>runInsertManyReturning</a>
--   instead. Will be removed in version 0.7.</i>
arrangeInsertManyReturningSql :: Unpackspec columnsReturned ignored -> Table columnsW columnsR -> NonEmpty columnsW -> (columnsR -> columnsReturned) -> String

-- | <i>Deprecated: You probably want <a>runUpdateReturning</a> instead.
--   Will be removed in version 0.7.</i>
arrangeUpdateReturning :: Unpackspec columnsReturned ignored -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column SqlBool) -> (columnsR -> columnsReturned) -> Returning SqlUpdate

-- | <i>Deprecated: You probably want <a>runUpdateReturning</a> instead.
--   Will be removed in version 0.7.</i>
arrangeUpdateReturningSql :: Unpackspec columnsReturned ignored -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column SqlBool) -> (columnsR -> columnsReturned) -> String

-- | Insert rows into a table with <tt>ON CONFLICT DO NOTHING</tt>

-- | <i>Deprecated: Use runInsert_</i>
runInsertManyOnConflictDoNothing :: Connection -> Table columns columns' -> [columns] -> IO Int64

-- | Insert rows into a table with <tt>ON CONFLICT DO NOTHING</tt> and
--   return a function of the inserted rows
--   
--   <tt>runInsertManyReturningOnConflictDoNothing</tt>'s use of the
--   <a>Default</a> typeclass means that the compiler will have trouble
--   inferring types. It is strongly recommended that you provide full type
--   signatures when using it.

-- | <i>Deprecated: Use runInsert_</i>
runInsertManyReturningOnConflictDoNothing :: Default QueryRunner columnsReturned haskells => Connection -> Table columnsW columnsR -> [columnsW] -> (columnsR -> columnsReturned) -> IO [haskells]

-- | Use <a>runInsert_</a> instead. Will be deprecated in version 0.7.
runInsertMany :: Connection -> Table columns columns' -> [columns] -> IO Int64

-- | Use <a>runInsert_</a> instead. Will be deprecated in version 0.7.
runInsertManyReturning :: Default QueryRunner columnsReturned haskells => Connection -> Table columnsW columnsR -> [columnsW] -> (columnsR -> columnsReturned) -> IO [haskells]

-- | Use <a>runInsert_</a> instead. Will be deprecated in version 0.7.
runInsertReturningExplicit :: QueryRunner columnsReturned haskells -> Connection -> Table columnsW columnsR -> columnsW -> (columnsR -> columnsReturned) -> IO [haskells]

-- | Use <a>runInsert_</a> instead. Will be deprecated in version 0.7.
runInsertManyReturningExplicit :: QueryRunner columnsReturned haskells -> Connection -> Table columnsW columnsR -> [columnsW] -> (columnsR -> columnsReturned) -> IO [haskells]

-- | Use <a>runInsert_</a> instead. Will be deprecated in version 0.7.
runInsertManyReturningOnConflictDoNothingExplicit :: QueryRunner columnsReturned haskells -> Connection -> Table columnsW columnsR -> [columnsW] -> (columnsR -> columnsReturned) -> IO [haskells]

-- | Use <a>runUpdate_</a> instead. Will be deprecated in version 0.7.
runUpdateEasy :: Default Updater columnsR columnsW => Connection -> Table columnsW columnsR -> (columnsR -> columnsR) -> (columnsR -> Column SqlBool) -> IO Int64

-- | Use <a>runUpdate_</a> instead. Will be deprecated in version 0.7.
runUpdate :: Connection -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column SqlBool) -> IO Int64

-- | Use <a>runUpdate_</a> instead. Will be deprecated in version 0.7.
runUpdateReturning :: Default QueryRunner columnsReturned haskells => Connection -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column SqlBool) -> (columnsR -> columnsReturned) -> IO [haskells]

-- | Use <a>runUpdate_</a> instead. Will be deprecated in version 0.7.
runUpdateReturningExplicit :: QueryRunner columnsReturned haskells -> Connection -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column SqlBool) -> (columnsR -> columnsReturned) -> IO [haskells]

-- | Use <a>runDelete_</a> instead. Will be deprecated in 0.7.
runDelete :: Connection -> Table a columnsR -> (columnsR -> Column SqlBool) -> IO Int64
data Unpackspec columns columns'
data OnConflict

-- | <pre>
--   ON CONFLICT DO NOTHING
--   </pre>
DoNothing :: OnConflict

module Opaleye.TypeFamilies
type TableField f a b c d = A f ( 'TC '('(a, b, c), d))
type RecordField f a b c = A f ( 'C '(a, b, c))
type (:<*>) =  'S
type (:<$>) f = (:<*>) (Pure f)
type Id =  'I
type Pure =  'K
type family IMap f a
type F =  'H
type O =  'H OT
type H =  'H HT
type W =  'H WT
type N =  'Nullable
type NN =  'NonNullable
type Opt =  'OOpt
type Req =  'OReq
type Nulls =  'H NullsT

module Opaleye.RunSelect

-- | <tt>runSelect</tt>'s use of the <a>Default</a> typeclass means that
--   the compiler will have trouble inferring types. It is strongly
--   recommended that you provide full type signatures when using
--   <tt>runSelect</tt>.
--   
--   Example type specialization:
--   
--   <pre>
--   runSelect :: <a>Select</a> (Column <a>SqlInt4</a>, Column <a>SqlText</a>) -&gt; IO [(Int, String)]
--   </pre>
--   
--   Assuming the <tt>makeAdaptorAndInstance</tt> splice has been run for
--   the product type <tt>Foo</tt>:
--   
--   <pre>
--   runSelect :: <a>Select</a> (Foo (Column <a>SqlInt4</a>) (Column <a>SqlText</a>) (Column <a>SqlBool</a>)
--             -&gt; IO [Foo Int String Bool]
--   </pre>
runSelect :: Default FromFields fields haskells => Connection -> Select fields -> IO [haskells]

-- | <a>runSelectTF</a> has better type inference than <a>runSelect</a> but
--   only works with "higher-kinded data" types.
runSelectTF :: Default FromFields (rec O) (rec H) => Connection -> Select (rec O) -> IO [rec H]

-- | <tt>runSelectFold</tt> streams the results of a query incrementally
--   and consumes the results with a left fold.
--   
--   This fold is <i>not</i> strict. The stream consumer is responsible for
--   forcing the evaluation of its result to avoid space leaks.
runSelectFold :: Default FromFields fields haskells => Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b

-- | Declare a temporary cursor. The cursor is given a unique name for the
--   given connection.
--   
--   Returns <a>Nothing</a> when the query returns zero rows.
declareCursor :: Default FromFields fields haskells => Connection -> Select fields -> IO (Cursor haskells)

-- | Close the given cursor.
closeCursor :: Cursor fields -> IO ()

-- | Fold over a chunk of rows, calling the supplied fold-like function on
--   each row as it is received. In case the cursor is exhausted, a
--   <a>Left</a> value is returned, otherwise a <a>Right</a> value is
--   returned.
foldForward :: Cursor haskells -> Int -> (a -> haskells -> IO a) -> a -> IO (Either a a)
runSelectExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO [haskells]
runSelectFoldExplicit :: FromFields fields haskells -> Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b
declareCursorExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO (Cursor haskells)

-- | Cursor within a transaction.
data Cursor haskells
type FromFields = QueryRunner
type FromField = QueryRunnerColumn

module Opaleye.Values

-- | <a>values</a> implements Postgres's <tt>VALUES</tt> construct and
--   allows you to create a query that consists of the given rows.
--   
--   Example type specialization:
--   
--   <pre>
--   values :: [(Column a, Column b)] -&gt; Select (Column a, Column b)
--   </pre>
--   
--   Assuming the <tt>makeAdaptorAndInstance</tt> splice has been run for
--   the product type <tt>Foo</tt>:
--   
--   <pre>
--   queryTable :: [Foo (Column a) (Column b) (Column c)] -&gt; S.Select (Foo (Column a) (Column b) (Column c))
--   </pre>
values :: (Default Valuesspec fields fields, Default Unpackspec fields fields) => [fields] -> Select fields
valuesExplicit :: Unpackspec fields fields' -> Valuesspec fields fields' -> [fields] -> Select fields'


-- | An SQL-generating DSL targeting PostgreSQL. Allows Postgres queries to
--   be written within Haskell in a typesafe and composable fashion.
--   
--   You might like to look at
--   
--   <ul>
--   <li><a>Basic tutorial</a></li>
--   <li><a>Manipulation tutorial</a></li>
--   <li><a>Advanced tutorial</a></li>
--   <li>If you are confused about the <tt>Default</tt> typeclass, then the
--   <a>Default explanation</a></li>
--   </ul>
module Opaleye
type Field a = Field_  'NonNullable a
type FieldNullable a = Field_  'Nullable a
data Nullability
NonNullable :: Nullability
Nullable :: Nullability
type family Field_ (a :: Nullability) b

-- | Cursor within a transaction.
data Cursor haskells
type FromFields = QueryRunner
type FromField = QueryRunnerColumn

-- | <tt>runSelect</tt>'s use of the <a>Default</a> typeclass means that
--   the compiler will have trouble inferring types. It is strongly
--   recommended that you provide full type signatures when using
--   <tt>runSelect</tt>.
--   
--   Example type specialization:
--   
--   <pre>
--   runSelect :: <a>Select</a> (Column <a>SqlInt4</a>, Column <a>SqlText</a>) -&gt; IO [(Int, String)]
--   </pre>
--   
--   Assuming the <tt>makeAdaptorAndInstance</tt> splice has been run for
--   the product type <tt>Foo</tt>:
--   
--   <pre>
--   runSelect :: <a>Select</a> (Foo (Column <a>SqlInt4</a>) (Column <a>SqlText</a>) (Column <a>SqlBool</a>)
--             -&gt; IO [Foo Int String Bool]
--   </pre>
runSelect :: Default FromFields fields haskells => Connection -> Select fields -> IO [haskells]

-- | <a>runSelectTF</a> has better type inference than <a>runSelect</a> but
--   only works with "higher-kinded data" types.
runSelectTF :: Default FromFields (rec O) (rec H) => Connection -> Select (rec O) -> IO [rec H]

-- | <tt>runSelectFold</tt> streams the results of a query incrementally
--   and consumes the results with a left fold.
--   
--   This fold is <i>not</i> strict. The stream consumer is responsible for
--   forcing the evaluation of its result to avoid space leaks.
runSelectFold :: Default FromFields fields haskells => Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b
runSelectExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO [haskells]
runSelectFoldExplicit :: FromFields fields haskells -> Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b
