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


-- | Low-level binding to SQLite3.  Includes UTF8 and BLOB support.
--   
--   This package is not very different from the other SQLite3 bindings out
--   there, but it fixes a few deficiencies I was finding. As compared to
--   bindings-sqlite3, it is slightly higher-level, in that it supports
--   marshalling of data values to and from the database. In particular, it
--   supports strings encoded as UTF8, and BLOBs represented as
--   ByteStrings.
@package direct-sqlite
@version 2.3.20

module Database.SQLite3.Bindings.Types

-- | <a>http://www.sqlite.org/c3ref/sqlite3.html</a>
--   
--   <tt>CDatabase</tt> = <tt>sqlite3</tt>
data CDatabase

-- | <a>http://www.sqlite.org/c3ref/stmt.html</a>
--   
--   <tt>CStatement</tt> = <tt>sqlite3_stmt</tt>
data CStatement

-- | <a>http://www.sqlite.org/c3ref/value.html</a>
--   
--   <tt>CValue</tt> = <tt>sqlite3_value</tt>
data CValue

-- | <a>http://www.sqlite.org/c3ref/context.html</a>
--   
--   <tt>CContext</tt> = <tt>sqlite3_context</tt>
data CContext

-- | <a>https://www.sqlite.org/c3ref/blob.html</a>
--   
--   <tt>CBlob</tt> = <tt>sqlite3_blob</tt>
data CBlob

-- | <a>https://www.sqlite.org/c3ref/backup.html</a>
--   
--   <tt>CBackup</tt> = <tt>sqlite3_backup</tt>
data CBackup

-- | <a>http://www.sqlite.org/c3ref/c_abort.html</a>
newtype CError
CError :: CInt -> CError

-- | Note that this is a partial function. If the error code is invalid, or
--   perhaps introduced in a newer version of SQLite but this library has
--   not been updated to support it, the result is undefined.
--   
--   To be clear, if <a>decodeError</a> fails, it is <i>undefined
--   behavior</i>, not an exception you can handle.
--   
--   Therefore, do not use direct-sqlite with a different version of SQLite
--   than the one bundled (currently, 3.7.13). If you do, ensure that
--   <a>decodeError</a> and <a>decodeColumnType</a> are still exhaustive.
decodeError :: CError -> Error
encodeError :: Error -> CError
data Error

-- | Successful result
ErrorOK :: Error

-- | SQL error or missing database
ErrorError :: Error

-- | Internal logic error in SQLite
ErrorInternal :: Error

-- | Access permission denied
ErrorPermission :: Error

-- | Callback routine requested an abort
ErrorAbort :: Error

-- | The database file is locked
ErrorBusy :: Error

-- | A table in the database is locked
ErrorLocked :: Error

-- | A <tt>malloc()</tt> failed
ErrorNoMemory :: Error

-- | Attempt to write a readonly database
ErrorReadOnly :: Error

-- | Operation terminated by <tt>sqlite3_interrupt()</tt>
ErrorInterrupt :: Error

-- | Some kind of disk I/O error occurred
ErrorIO :: Error

-- | The database disk image is malformed
ErrorCorrupt :: Error

-- | Unknown opcode in <tt>sqlite3_file_control()</tt>
ErrorNotFound :: Error

-- | Insertion failed because database is full
ErrorFull :: Error

-- | Unable to open the database file
ErrorCan'tOpen :: Error

-- | Database lock protocol error
ErrorProtocol :: Error

-- | Database is empty
ErrorEmpty :: Error

-- | The database schema changed
ErrorSchema :: Error

-- | String or BLOB exceeds size limit
ErrorTooBig :: Error

-- | Abort due to constraint violation
ErrorConstraint :: Error

-- | Data type mismatch
ErrorMismatch :: Error

-- | Library used incorrectly
ErrorMisuse :: Error

-- | Uses OS features not supported on host
ErrorNoLargeFileSupport :: Error

-- | Authorization denied
ErrorAuthorization :: Error

-- | Auxiliary database format error
ErrorFormat :: Error

-- | 2nd parameter to sqlite3_bind out of range
ErrorRange :: Error

-- | File opened that is not a database file
ErrorNotADatabase :: Error

-- | <tt>sqlite3_step()</tt> has another row ready
ErrorRow :: Error

-- | <tt>sqlite3_step()</tt> has finished executing
ErrorDone :: Error

-- | <a>http://www.sqlite.org/c3ref/c_blob.html</a>
newtype CColumnType
CColumnType :: CInt -> CColumnType

-- | Note that this is a partial function. See <a>decodeError</a> for more
--   information.
decodeColumnType :: CColumnType -> ColumnType
encodeColumnType :: ColumnType -> CColumnType
data ColumnType
IntegerColumn :: ColumnType
FloatColumn :: ColumnType
TextColumn :: ColumnType
BlobColumn :: ColumnType
NullColumn :: ColumnType

-- | Index of a parameter in a parameterized query. Parameter indices start
--   from 1.
--   
--   When a query is <a>prepare</a>d, SQLite allocates an array indexed
--   from 1 to the highest parameter index. For example:
--   
--   <pre>
--   &gt;Right stmt &lt;- prepare conn "SELECT ?1, ?5, ?3, ?"
--   &gt;bindParameterCount stmt
--   ParamIndex 6
--   </pre>
--   
--   This will allocate an array indexed from 1 to 6 (<tt>?</tt> takes the
--   highest preceding index plus one). The array is initialized with null
--   values. When you bind a parameter with <a>bindSQLData</a>, it assigns
--   a new value to one of these indices.
--   
--   See <a>http://www.sqlite.org/lang_expr.html#varparam</a> for the
--   syntax of parameter placeholders, and how parameter indices are
--   assigned.
newtype ParamIndex
ParamIndex :: Int -> ParamIndex

-- | Index of a column in a result set. Column indices start from 0.
newtype ColumnIndex
ColumnIndex :: Int -> ColumnIndex

-- | Number of columns in a result set.
type ColumnCount = ColumnIndex
newtype CParamIndex
CParamIndex :: CInt -> CParamIndex
newtype CColumnIndex
CColumnIndex :: CInt -> CColumnIndex
type CColumnCount = CColumnIndex
newtype CNumBytes
CNumBytes :: CInt -> CNumBytes

-- | <a>http://www.sqlite.org/c3ref/c_static.html</a>
--   
--   <tt>Ptr CDestructor</tt> = <tt>sqlite3_destructor_type</tt>
data CDestructor

-- | Tells SQLite3 to make its own private copy of the data
c_SQLITE_TRANSIENT :: Ptr CDestructor
c_SQLITE_UTF8 :: CInt

-- | Number of arguments of a user defined SQL function.
newtype ArgCount
ArgCount :: Int -> ArgCount

-- | Index of an argument to a custom function. Indices start from 0.
type ArgIndex = ArgCount
newtype CArgCount
CArgCount :: CInt -> CArgCount

-- | Tells SQLite3 that the defined custom SQL function is deterministic.
c_SQLITE_DETERMINISTIC :: CInt

-- | The <a>Database.SQLite3</a> and <a>Database.SQLite3.Direct</a> modules
--   use higher-level representations of some types than those used in the
--   FFI signatures (<a>Database.SQLite3.Bindings</a>). This typeclass
--   helps with the conversions.
class FFIType public ffi | public -> ffi, ffi -> public
toFFI :: FFIType public ffi => public -> ffi
fromFFI :: FFIType public ffi => ffi -> public
instance GHC.Show.Show Database.SQLite3.Bindings.Types.CColumnType
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CColumnType
instance GHC.Show.Show Database.SQLite3.Bindings.Types.CError
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CError
instance GHC.Real.Integral Database.SQLite3.Bindings.Types.CArgCount
instance GHC.Real.Real Database.SQLite3.Bindings.Types.CArgCount
instance GHC.Num.Num Database.SQLite3.Bindings.Types.CArgCount
instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.CArgCount
instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.CArgCount
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CArgCount
instance GHC.Real.Integral Database.SQLite3.Bindings.Types.ArgCount
instance GHC.Real.Real Database.SQLite3.Bindings.Types.ArgCount
instance GHC.Num.Num Database.SQLite3.Bindings.Types.ArgCount
instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.ArgCount
instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.ArgCount
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.ArgCount
instance GHC.Real.Integral Database.SQLite3.Bindings.Types.CNumBytes
instance GHC.Real.Real Database.SQLite3.Bindings.Types.CNumBytes
instance GHC.Num.Num Database.SQLite3.Bindings.Types.CNumBytes
instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.CNumBytes
instance GHC.Show.Show Database.SQLite3.Bindings.Types.CNumBytes
instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.CNumBytes
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CNumBytes
instance GHC.Real.Integral Database.SQLite3.Bindings.Types.CColumnIndex
instance GHC.Real.Real Database.SQLite3.Bindings.Types.CColumnIndex
instance GHC.Num.Num Database.SQLite3.Bindings.Types.CColumnIndex
instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.CColumnIndex
instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.CColumnIndex
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CColumnIndex
instance GHC.Real.Integral Database.SQLite3.Bindings.Types.CParamIndex
instance GHC.Real.Real Database.SQLite3.Bindings.Types.CParamIndex
instance GHC.Num.Num Database.SQLite3.Bindings.Types.CParamIndex
instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.CParamIndex
instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.CParamIndex
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.CParamIndex
instance GHC.Real.Integral Database.SQLite3.Bindings.Types.ColumnIndex
instance GHC.Real.Real Database.SQLite3.Bindings.Types.ColumnIndex
instance GHC.Num.Num Database.SQLite3.Bindings.Types.ColumnIndex
instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.ColumnIndex
instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.ColumnIndex
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.ColumnIndex
instance GHC.Real.Integral Database.SQLite3.Bindings.Types.ParamIndex
instance GHC.Real.Real Database.SQLite3.Bindings.Types.ParamIndex
instance GHC.Num.Num Database.SQLite3.Bindings.Types.ParamIndex
instance GHC.Enum.Enum Database.SQLite3.Bindings.Types.ParamIndex
instance GHC.Classes.Ord Database.SQLite3.Bindings.Types.ParamIndex
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.ParamIndex
instance GHC.Show.Show Database.SQLite3.Bindings.Types.ColumnType
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.ColumnType
instance GHC.Show.Show Database.SQLite3.Bindings.Types.Error
instance GHC.Classes.Eq Database.SQLite3.Bindings.Types.Error
instance GHC.Show.Show Database.SQLite3.Bindings.Types.ParamIndex
instance GHC.Enum.Bounded Database.SQLite3.Bindings.Types.ParamIndex
instance GHC.Show.Show Database.SQLite3.Bindings.Types.ColumnIndex
instance GHC.Enum.Bounded Database.SQLite3.Bindings.Types.ColumnIndex
instance GHC.Show.Show Database.SQLite3.Bindings.Types.CParamIndex
instance GHC.Show.Show Database.SQLite3.Bindings.Types.CColumnIndex
instance GHC.Show.Show Database.SQLite3.Bindings.Types.ArgCount
instance GHC.Enum.Bounded Database.SQLite3.Bindings.Types.ArgCount
instance GHC.Show.Show Database.SQLite3.Bindings.Types.CArgCount
instance GHC.Enum.Bounded Database.SQLite3.Bindings.Types.CArgCount
instance Database.SQLite3.Bindings.Types.FFIType Database.SQLite3.Bindings.Types.ParamIndex Database.SQLite3.Bindings.Types.CParamIndex
instance Database.SQLite3.Bindings.Types.FFIType Database.SQLite3.Bindings.Types.ColumnIndex Database.SQLite3.Bindings.Types.CColumnIndex
instance Database.SQLite3.Bindings.Types.FFIType Database.SQLite3.Bindings.Types.Error Database.SQLite3.Bindings.Types.CError
instance Database.SQLite3.Bindings.Types.FFIType Database.SQLite3.Bindings.Types.ColumnType Database.SQLite3.Bindings.Types.CColumnType
instance Database.SQLite3.Bindings.Types.FFIType Database.SQLite3.Bindings.Types.ArgCount Database.SQLite3.Bindings.Types.CArgCount

module Database.SQLite3.Bindings

-- | <a>http://www.sqlite.org/c3ref/open.html</a>
--   
--   This sets the <tt>'Ptr CDatabase'</tt> even on failure.
c_sqlite3_open :: CString -> Ptr (Ptr CDatabase) -> IO CError

-- | <a>http://www.sqlite.org/c3ref/close.html</a>
c_sqlite3_close :: Ptr CDatabase -> IO CError

-- | <a>http://www.sqlite.org/c3ref/errcode.html</a>
c_sqlite3_errcode :: Ptr CDatabase -> IO CError

-- | <a>http://www.sqlite.org/c3ref/errcode.html</a>
c_sqlite3_errmsg :: Ptr CDatabase -> IO CString

-- | <a>http://www.sqlite.org/c3ref/interrupt.html</a>
c_sqlite3_interrupt :: Ptr CDatabase -> IO ()

-- | <a>http://www.sqlite.org/c3ref/profile.html</a>
c_sqlite3_trace :: Ptr CDatabase -> FunPtr (CTraceCallback a) -> Ptr a -> IO (Ptr ())
type CTraceCallback a = Ptr a -> CString  UTF-8 rendering of the SQL statement text as
 the statement first begins executing
 -> IO ()
mkCTraceCallback :: CTraceCallback a -> IO (FunPtr (CTraceCallback a))

-- | <a>http://www.sqlite.org/c3ref/get_autocommit.html</a>
c_sqlite3_get_autocommit :: Ptr CDatabase -> IO CInt

-- | <a>https://www.sqlite.org/c3ref/enable_shared_cache.html</a>
c_sqlite3_enable_shared_cache :: CInt -> IO CError
c_sqlite3_exec :: Ptr CDatabase -> CString -> FunPtr (CExecCallback a) -> Ptr a -> Ptr CString -> IO CError
type CExecCallback a = Ptr a -> CColumnCount  Number of columns, which is the number of elements in
 the following arrays.
 -> Ptr CString  Array of column values, as returned by
 'c_sqlite3_column_text'.  Null values are represented
 as null pointers.
 -> Ptr CString  Array of column names
 -> IO CInt  If the callback returns non-zero, then
 'c_sqlite3_exec' returns @SQLITE_ABORT@
 ('ErrorAbort').

-- | A couple important things to know about callbacks from Haskell code:
--   
--   <ul>
--   <li>If the callback throws an exception, apparently, the <i>whole
--   program</i> is terminated.</li>
--   <li>Remember to call <a>freeHaskellFunPtr</a> when you are done with
--   the wrapper, to avoid leaking memory.</li>
--   </ul>
mkCExecCallback :: CExecCallback a -> IO (FunPtr (CExecCallback a))

-- | <a>http://www.sqlite.org/c3ref/prepare.html</a>
--   
--   If the query contains no SQL statements, this returns
--   <tt>SQLITE_OK</tt> and sets the <tt><a>Ptr</a> <a>CStatement</a></tt>
--   to null.
c_sqlite3_prepare_v2 :: Ptr CDatabase -> CString -> CNumBytes -> Ptr (Ptr CStatement) -> Ptr CString -> IO CError

-- | <a>http://www.sqlite.org/c3ref/db_handle.html</a>
c_sqlite3_db_handle :: Ptr CStatement -> IO (Ptr CDatabase)

-- | <a>http://www.sqlite.org/c3ref/step.html</a>
c_sqlite3_step :: Ptr CStatement -> IO CError

-- | <a>http://www.sqlite.org/c3ref/reset.html</a>
--   
--   <i>Warning:</i> If the most recent <a>c_sqlite3_step</a> call failed,
--   this will return the corresponding error code.
c_sqlite3_reset :: Ptr CStatement -> IO CError

-- | <a>http://www.sqlite.org/c3ref/finalize.html</a>
--   
--   <i>Warning:</i> If the most recent <a>c_sqlite3_step</a> call failed,
--   this will return the corresponding error code.
c_sqlite3_finalize :: Ptr CStatement -> IO CError

-- | <a>http://www.sqlite.org/c3ref/clear_bindings.html</a>
--   
--   A look at the source reveals that this function always returns
--   <tt>SQLITE_OK</tt>.
c_sqlite3_clear_bindings :: Ptr CStatement -> IO CError

-- | <a>http://www.sqlite.org/c3ref/sql.html</a>
c_sqlite3_sql :: Ptr CStatement -> IO CString

-- | <a>http://www.sqlite.org/c3ref/bind_parameter_count.html</a>
--   
--   This returns the index of the largest (rightmost) parameter, which is
--   not necessarily the number of parameters. If numbered parameters like
--   <tt>?5</tt> are used, there may be gaps in the list.
c_sqlite3_bind_parameter_count :: Ptr CStatement -> IO CParamIndex

-- | <a>http://www.sqlite.org/c3ref/bind_parameter_name.html</a>
c_sqlite3_bind_parameter_name :: Ptr CStatement -> CParamIndex -> IO CString

-- | <a>http://www.sqlite.org/c3ref/bind_parameter_index.html</a>
c_sqlite3_bind_parameter_index :: Ptr CStatement -> CString -> IO CParamIndex

-- | <a>http://www.sqlite.org/c3ref/column_count.html</a>
c_sqlite3_column_count :: Ptr CStatement -> IO CColumnCount

-- | <a>http://www.sqlite.org/c3ref/column_name.html</a>
c_sqlite3_column_name :: Ptr CStatement -> CColumnIndex -> IO CString
c_sqlite3_bind_blob :: Ptr CStatement -> CParamIndex -> Ptr a -> CNumBytes -> Ptr CDestructor -> IO CError
c_sqlite3_bind_zeroblob :: Ptr CStatement -> CParamIndex -> CInt -> IO CError
c_sqlite3_bind_text :: Ptr CStatement -> CParamIndex -> CString -> CNumBytes -> Ptr CDestructor -> IO CError
c_sqlite3_bind_double :: Ptr CStatement -> CParamIndex -> Double -> IO CError
c_sqlite3_bind_int64 :: Ptr CStatement -> CParamIndex -> Int64 -> IO CError
c_sqlite3_bind_null :: Ptr CStatement -> CParamIndex -> IO CError
c_sqlite3_column_type :: Ptr CStatement -> CColumnIndex -> IO CColumnType
c_sqlite3_column_bytes :: Ptr CStatement -> CColumnIndex -> IO CNumBytes
c_sqlite3_column_blob :: Ptr CStatement -> CColumnIndex -> IO (Ptr a)
c_sqlite3_column_int64 :: Ptr CStatement -> CColumnIndex -> IO Int64
c_sqlite3_column_double :: Ptr CStatement -> CColumnIndex -> IO Double
c_sqlite3_column_text :: Ptr CStatement -> CColumnIndex -> IO CString

-- | <a>http://www.sqlite.org/c3ref/last_insert_rowid.html</a>
c_sqlite3_last_insert_rowid :: Ptr CDatabase -> IO Int64

-- | <a>http://www.sqlite.org/c3ref/changes.html</a>
c_sqlite3_changes :: Ptr CDatabase -> IO CInt

-- | <a>http://www.sqlite.org/c3ref/total_changes.html</a>
c_sqlite3_total_changes :: Ptr CDatabase -> IO CInt

-- | <a>http://sqlite.org/c3ref/create_function.html</a>
c_sqlite3_create_function_v2 :: Ptr CDatabase -> CString -> CArgCount -> CInt -> Ptr a -> FunPtr CFunc -> FunPtr CFunc -> FunPtr CFuncFinal -> FunPtr (CFuncDestroy a) -> IO CError
type CFunc = Ptr CContext -> CArgCount -> Ptr (Ptr CValue) -> IO ()
type CFuncFinal = Ptr CContext -> IO ()
type CFuncDestroy a = Ptr a -> IO ()
mkCFunc :: CFunc -> IO (FunPtr CFunc)
mkCFuncFinal :: CFuncFinal -> IO (FunPtr CFuncFinal)
mkCFuncDestroy :: CFuncDestroy a -> IO (FunPtr (CFuncDestroy a))

-- | <a>http://www.sqlite.org/c3ref/user_data.html</a>
c_sqlite3_user_data :: Ptr CContext -> IO (Ptr a)

-- | <a>http://www.sqlite.org/c3ref/context_db_handle.html</a>
c_sqlite3_context_db_handle :: Ptr CContext -> IO (Ptr CDatabase)

-- | <a>http://www.sqlite.org/c3ref/aggregate_context.html</a>
c_sqlite3_aggregate_context :: Ptr CContext -> CNumBytes -> IO (Ptr a)
c_sqlite3_value_type :: Ptr CValue -> IO CColumnType
c_sqlite3_value_bytes :: Ptr CValue -> IO CNumBytes
c_sqlite3_value_blob :: Ptr CValue -> IO (Ptr a)
c_sqlite3_value_text :: Ptr CValue -> IO CString
c_sqlite3_value_int64 :: Ptr CValue -> IO Int64
c_sqlite3_value_double :: Ptr CValue -> IO Double
c_sqlite3_result_null :: Ptr CContext -> IO ()
c_sqlite3_result_blob :: Ptr CContext -> Ptr a -> CNumBytes -> Ptr CDestructor -> IO ()
c_sqlite3_result_zeroblob :: Ptr CContext -> CNumBytes -> IO ()
c_sqlite3_result_text :: Ptr CContext -> CString -> CNumBytes -> Ptr CDestructor -> IO ()
c_sqlite3_result_int64 :: Ptr CContext -> Int64 -> IO ()
c_sqlite3_result_double :: Ptr CContext -> Double -> IO ()
c_sqlite3_result_value :: Ptr CContext -> Ptr CValue -> IO ()
c_sqlite3_result_error :: Ptr CContext -> CString -> CNumBytes -> IO ()

-- | <a>http://www.sqlite.org/c3ref/create_collation.html</a>
c_sqlite3_create_collation_v2 :: Ptr CDatabase -> CString -> CInt -> Ptr a -> FunPtr (CCompare a) -> FunPtr (CFuncDestroy a) -> IO CError
type CCompare a = Ptr a -> CNumBytes -> CString -> CNumBytes -> CString -> IO CInt
mkCCompare :: CCompare a -> IO (FunPtr (CCompare a))

-- | <a>http://sqlite.org/c3ref/free.html</a>
c_sqlite3_free :: Ptr a -> IO ()

-- | <a>http://sqlite.org/c3ref/enable_load_extension.html</a>
c_sqlite3_enable_load_extension :: Ptr CDatabase -> Bool -> IO CError

-- | <a>https://www.sqlite.org/c3ref/wal_hook.html</a>
c_sqlite3_wal_hook :: Ptr CDatabase -> FunPtr CWalHook -> Ptr a -> IO (Ptr ())
type CWalHook = Ptr () -> Ptr CDatabase -> CString -> CInt -> IO CError
mkCWalHook :: CWalHook -> IO (FunPtr CWalHook)

-- | <a>https://www.sqlite.org/c3ref/blob_open.html</a>
c_sqlite3_blob_open :: Ptr CDatabase -> CString -> CString -> CString -> Int64 -> CInt -> Ptr (Ptr CBlob) -> IO CError

-- | <a>https://www.sqlite.org/c3ref/blob_close.html</a>
c_sqlite3_blob_close :: Ptr CBlob -> IO CError

-- | <a>https://www.sqlite.org/c3ref/blob_reopen.html</a>
c_sqlite3_blob_reopen :: Ptr CBlob -> Int64 -> IO CError

-- | <a>https://www.sqlite.org/c3ref/blob_bytes.html</a>
c_sqlite3_blob_bytes :: Ptr CBlob -> IO CInt

-- | <a>https://www.sqlite.org/c3ref/blob_read.html</a>
c_sqlite3_blob_read :: Ptr CBlob -> Ptr a -> CInt -> CInt -> IO CError

-- | <a>https://www.sqlite.org/c3ref/blob_write.html</a>
c_sqlite3_blob_write :: Ptr CBlob -> Ptr a -> CInt -> CInt -> IO CError
c_sqlite3_backup_init :: Ptr CDatabase -> CString -> Ptr CDatabase -> CString -> IO (Ptr CBackup)
c_sqlite3_backup_finish :: Ptr CBackup -> IO CError
c_sqlite3_backup_step :: Ptr CBackup -> CInt -> IO CError
c_sqlite3_backup_remaining :: Ptr CBackup -> IO CInt
c_sqlite3_backup_pagecount :: Ptr CBackup -> IO CInt


-- | This API is a slightly lower-level version of <a>Database.SQLite3</a>.
--   Namely:
--   
--   <ul>
--   <li>It returns errors instead of throwing them.</li>
--   <li>It only uses cheap conversions. None of these bindings convert
--   from <a>String</a> or <a>Text</a>.</li>
--   </ul>
module Database.SQLite3.Direct

-- | <a>http://www.sqlite.org/c3ref/open.html</a>
open :: Utf8 -> IO (Either (Error, Utf8) Database)

-- | <a>http://www.sqlite.org/c3ref/close.html</a>
close :: Database -> IO (Either Error ())

-- | <a>http://www.sqlite.org/c3ref/errcode.html</a>
errcode :: Database -> IO Error

-- | <a>http://www.sqlite.org/c3ref/errcode.html</a>
errmsg :: Database -> IO Utf8

-- | <a>http://www.sqlite.org/c3ref/profile.html</a>
--   
--   Enable/disable tracing of SQL execution. Tracing can be disabled by
--   setting <a>Nothing</a> as the logger callback.
--   
--   Warning: If the logger callback throws an exception, your whole
--   program will crash. Enable only for debugging!
setTrace :: Database -> Maybe (Utf8 -> IO ()) -> IO ()

-- | <a>http://www.sqlite.org/c3ref/get_autocommit.html</a>
--   
--   Return <a>True</a> if the connection is in autocommit mode, or
--   <a>False</a> if a transaction started with <tt>BEGIN</tt> is still
--   active.
--   
--   Be warned that some errors roll back the transaction automatically,
--   and that <tt>ROLLBACK</tt> will throw an error if no transaction is
--   active. Use <a>getAutoCommit</a> to avoid such an error:
--   
--   <pre>
--   autocommit &lt;- <a>getAutoCommit</a> conn
--   <a>when</a> (not autocommit) $
--       <a>exec</a> conn "ROLLBACK"
--   </pre>
getAutoCommit :: Database -> IO Bool

-- | <a>https://www.sqlite.org/c3ref/enable_shared_cache.html</a>
--   
--   Enable or disable shared cache for all future connections.
setSharedCacheEnabled :: Bool -> IO (Either Error ())
exec :: Database -> Utf8 -> IO (Either (Error, Utf8) ())

-- | Like <a>exec</a>, but invoke the callback for each result row.
--   
--   If the callback throws an exception, it will be rethrown by
--   <a>execWithCallback</a>.
execWithCallback :: Database -> Utf8 -> ExecCallback -> IO (Either (Error, Utf8) ())
type ExecCallback = ColumnCount  Number of columns, which is the number of items in
 the following lists.  This will be the same for
 every row.
 -> [Utf8]  List of column names.  This will be the same
 for every row.
 -> [Maybe Utf8]  List of column values, as returned by 'columnText'.
 -> IO ()

-- | <a>http://www.sqlite.org/c3ref/prepare.html</a>
--   
--   If the query contains no SQL statements, this returns <tt><a>Right</a>
--   <a>Nothing</a></tt>.
prepare :: Database -> Utf8 -> IO (Either Error (Maybe Statement))

-- | <a>http://www.sqlite.org/c3ref/db_handle.html</a>
getStatementDatabase :: Statement -> IO Database

-- | <a>http://www.sqlite.org/c3ref/step.html</a>
step :: Statement -> IO (Either Error StepResult)

-- | <a>http://www.sqlite.org/c3ref/reset.html</a>
--   
--   Warning:
--   
--   <ul>
--   <li>If the most recent <a>step</a> call failed, this will return the
--   corresponding error.</li>
--   <li>This does not reset the bindings on a prepared statement. Use
--   <a>clearBindings</a> to do that.</li>
--   </ul>
reset :: Statement -> IO (Either Error ())

-- | <a>http://www.sqlite.org/c3ref/finalize.html</a>
--   
--   <i>Warning:</i> If the most recent <a>step</a> call failed, this will
--   return the corresponding error.
finalize :: Statement -> IO (Either Error ())

-- | <a>http://www.sqlite.org/c3ref/clear_bindings.html</a>
--   
--   Set all parameters in the prepared statement to null.
clearBindings :: Statement -> IO ()

-- | <a>http://www.sqlite.org/c3ref/sql.html</a>
--   
--   Return a copy of the original SQL text used to compile the statement.
statementSql :: Statement -> IO (Maybe Utf8)

-- | <a>http://www.sqlite.org/c3ref/bind_parameter_count.html</a>
--   
--   This returns the index of the largest (rightmost) parameter. Note that
--   this is not necessarily the number of parameters. If numbered
--   parameters like <tt>?5</tt> are used, there may be gaps in the list.
--   
--   See <a>ParamIndex</a> for more information.
bindParameterCount :: Statement -> IO ParamIndex

-- | <a>http://www.sqlite.org/c3ref/bind_parameter_name.html</a>
bindParameterName :: Statement -> ParamIndex -> IO (Maybe Utf8)

-- | <a>http://www.sqlite.org/c3ref/bind_parameter_index.html</a>
bindParameterIndex :: Statement -> Utf8 -> IO (Maybe ParamIndex)

-- | <a>http://www.sqlite.org/c3ref/column_count.html</a>
columnCount :: Statement -> IO ColumnCount

-- | <a>http://www.sqlite.org/c3ref/column_name.html</a>
columnName :: Statement -> ColumnIndex -> IO (Maybe Utf8)
bindInt64 :: Statement -> ParamIndex -> Int64 -> IO (Either Error ())
bindDouble :: Statement -> ParamIndex -> Double -> IO (Either Error ())
bindText :: Statement -> ParamIndex -> Utf8 -> IO (Either Error ())
bindBlob :: Statement -> ParamIndex -> ByteString -> IO (Either Error ())
bindZeroBlob :: Statement -> ParamIndex -> Int -> IO (Either Error ())
bindNull :: Statement -> ParamIndex -> IO (Either Error ())
columnType :: Statement -> ColumnIndex -> IO ColumnType
columnInt64 :: Statement -> ColumnIndex -> IO Int64
columnDouble :: Statement -> ColumnIndex -> IO Double
columnText :: Statement -> ColumnIndex -> IO Utf8
columnBlob :: Statement -> ColumnIndex -> IO ByteString

-- | <a>http://www.sqlite.org/c3ref/enable_load_extension.html</a>
--   
--   Enable or disable extension loading.
setLoadExtensionEnabled :: Database -> Bool -> IO (Either Error ())

-- | <a>http://www.sqlite.org/c3ref/last_insert_rowid.html</a>
lastInsertRowId :: Database -> IO Int64

-- | <a>http://www.sqlite.org/c3ref/changes.html</a>
--   
--   Return the number of rows that were changed, inserted, or deleted by
--   the most recent <tt>INSERT</tt>, <tt>DELETE</tt>, or <tt>UPDATE</tt>
--   statement.
changes :: Database -> IO Int

-- | <a>http://www.sqlite.org/c3ref/total_changes.html</a>
--   
--   Return the total number of row changes caused by <tt>INSERT</tt>,
--   <tt>DELETE</tt>, or <tt>UPDATE</tt> statements since the
--   <a>Database</a> was opened.
totalChanges :: Database -> IO Int

-- | <a>http://sqlite.org/c3ref/create_function.html</a>
--   
--   Create a custom SQL function or redefine the behavior of an existing
--   function.
createFunction :: Database -> Utf8 -> Maybe ArgCount -> Bool -> (FuncContext -> FuncArgs -> IO ()) -> IO (Either Error ())

-- | Like <a>createFunction</a> except that it creates an aggregate
--   function.
createAggregate :: Database -> Utf8 -> Maybe ArgCount -> a -> (FuncContext -> FuncArgs -> a -> IO a) -> (FuncContext -> a -> IO ()) -> IO (Either Error ())

-- | Delete an SQL function (scalar or aggregate).
deleteFunction :: Database -> Utf8 -> Maybe ArgCount -> IO (Either Error ())
funcArgCount :: FuncArgs -> ArgCount
funcArgType :: FuncArgs -> ArgIndex -> IO ColumnType
funcArgInt64 :: FuncArgs -> ArgIndex -> IO Int64
funcArgDouble :: FuncArgs -> ArgIndex -> IO Double
funcArgText :: FuncArgs -> ArgIndex -> IO Utf8
funcArgBlob :: FuncArgs -> ArgIndex -> IO ByteString
funcResultInt64 :: FuncContext -> Int64 -> IO ()
funcResultDouble :: FuncContext -> Double -> IO ()
funcResultText :: FuncContext -> Utf8 -> IO ()
funcResultBlob :: FuncContext -> ByteString -> IO ()
funcResultZeroBlob :: FuncContext -> Int -> IO ()
funcResultNull :: FuncContext -> IO ()

-- | <a>https://www.sqlite.org/c3ref/context_db_handle.html</a>
getFuncContextDatabase :: FuncContext -> IO Database

-- | <a>http://www.sqlite.org/c3ref/create_collation.html</a>
createCollation :: Database -> Utf8 -> (Utf8 -> Utf8 -> Ordering) -> IO (Either Error ())

-- | Delete a collation.
deleteCollation :: Database -> Utf8 -> IO (Either Error ())

-- | <a>http://www.sqlite.org/c3ref/interrupt.html</a>
--   
--   Cause any pending operation on the <a>Database</a> handle to stop at
--   its earliest opportunity. This simply sets a flag and returns
--   immediately. It does not wait for the pending operation to finish.
--   
--   You'll need to compile with <tt>-threaded</tt> for this to do any
--   good. Without <tt>-threaded</tt>, FFI calls block the whole RTS,
--   meaning <a>interrupt</a> would never run at the same time as
--   <a>step</a>.
interrupt :: Database -> IO ()

-- | <a>https://www.sqlite.org/c3ref/blob_open.html</a>
--   
--   Open a blob for incremental I/O.
blobOpen :: Database -> Utf8 -> Utf8 -> Utf8 -> Int64 -> Bool -> IO (Either Error Blob)

-- | <a>https://www.sqlite.org/c3ref/blob_close.html</a>
blobClose :: Blob -> IO (Either Error ())

-- | <a>https://www.sqlite.org/c3ref/blob_reopen.html</a>
blobReopen :: Blob -> Int64 -> IO (Either Error ())

-- | <a>https://www.sqlite.org/c3ref/blob_bytes.html</a>
blobBytes :: Blob -> IO Int

-- | <a>https://www.sqlite.org/c3ref/blob_read.html</a>
blobRead :: Blob -> Int -> Int -> IO (Either Error ByteString)
blobReadBuf :: Blob -> Ptr a -> Int -> Int -> IO (Either Error ())

-- | <a>https://www.sqlite.org/c3ref/blob_write.html</a>
blobWrite :: Blob -> ByteString -> Int -> IO (Either Error ())
backupInit :: Database -> Utf8 -> Database -> Utf8 -> IO (Either Error Backup)
backupFinish :: Backup -> IO (Either Error ())
backupStep :: Backup -> Int -> IO (Either Error BackupStepResult)
backupRemaining :: Backup -> IO Int
backupPagecount :: Backup -> IO Int
newtype Database
Database :: (Ptr CDatabase) -> Database
newtype Statement
Statement :: (Ptr CStatement) -> Statement
data ColumnType
IntegerColumn :: ColumnType
FloatColumn :: ColumnType
TextColumn :: ColumnType
BlobColumn :: ColumnType
NullColumn :: ColumnType

-- | The context in which a custom SQL function is executed.
newtype FuncContext
FuncContext :: (Ptr CContext) -> FuncContext

-- | The arguments of a custom SQL function.
data FuncArgs
FuncArgs :: CArgCount -> (Ptr (Ptr CValue)) -> FuncArgs

-- | The type of blob handles used for incremental blob I/O
data Blob
Blob :: Database -> (Ptr CBlob) -> Blob

-- | A handle for an online backup process.
data Backup
Backup :: Database -> (Ptr CBackup) -> Backup
data StepResult
Row :: StepResult
Done :: StepResult
data BackupStepResult

-- | There are still more pages to be copied.
BackupOK :: BackupStepResult

-- | All pages were successfully copied.
BackupDone :: BackupStepResult
data Error

-- | Successful result
ErrorOK :: Error

-- | SQL error or missing database
ErrorError :: Error

-- | Internal logic error in SQLite
ErrorInternal :: Error

-- | Access permission denied
ErrorPermission :: Error

-- | Callback routine requested an abort
ErrorAbort :: Error

-- | The database file is locked
ErrorBusy :: Error

-- | A table in the database is locked
ErrorLocked :: Error

-- | A <tt>malloc()</tt> failed
ErrorNoMemory :: Error

-- | Attempt to write a readonly database
ErrorReadOnly :: Error

-- | Operation terminated by <tt>sqlite3_interrupt()</tt>
ErrorInterrupt :: Error

-- | Some kind of disk I/O error occurred
ErrorIO :: Error

-- | The database disk image is malformed
ErrorCorrupt :: Error

-- | Unknown opcode in <tt>sqlite3_file_control()</tt>
ErrorNotFound :: Error

-- | Insertion failed because database is full
ErrorFull :: Error

-- | Unable to open the database file
ErrorCan'tOpen :: Error

-- | Database lock protocol error
ErrorProtocol :: Error

-- | Database is empty
ErrorEmpty :: Error

-- | The database schema changed
ErrorSchema :: Error

-- | String or BLOB exceeds size limit
ErrorTooBig :: Error

-- | Abort due to constraint violation
ErrorConstraint :: Error

-- | Data type mismatch
ErrorMismatch :: Error

-- | Library used incorrectly
ErrorMisuse :: Error

-- | Uses OS features not supported on host
ErrorNoLargeFileSupport :: Error

-- | Authorization denied
ErrorAuthorization :: Error

-- | Auxiliary database format error
ErrorFormat :: Error

-- | 2nd parameter to sqlite3_bind out of range
ErrorRange :: Error

-- | File opened that is not a database file
ErrorNotADatabase :: Error

-- | <tt>sqlite3_step()</tt> has another row ready
ErrorRow :: Error

-- | <tt>sqlite3_step()</tt> has finished executing
ErrorDone :: Error

-- | A <a>ByteString</a> containing UTF8-encoded text with no NUL
--   characters.
newtype Utf8
Utf8 :: ByteString -> Utf8

-- | Index of a parameter in a parameterized query. Parameter indices start
--   from 1.
--   
--   When a query is <a>prepare</a>d, SQLite allocates an array indexed
--   from 1 to the highest parameter index. For example:
--   
--   <pre>
--   &gt;Right stmt &lt;- prepare conn "SELECT ?1, ?5, ?3, ?"
--   &gt;bindParameterCount stmt
--   ParamIndex 6
--   </pre>
--   
--   This will allocate an array indexed from 1 to 6 (<tt>?</tt> takes the
--   highest preceding index plus one). The array is initialized with null
--   values. When you bind a parameter with <a>bindSQLData</a>, it assigns
--   a new value to one of these indices.
--   
--   See <a>http://www.sqlite.org/lang_expr.html#varparam</a> for the
--   syntax of parameter placeholders, and how parameter indices are
--   assigned.
newtype ParamIndex
ParamIndex :: Int -> ParamIndex

-- | Index of a column in a result set. Column indices start from 0.
newtype ColumnIndex
ColumnIndex :: Int -> ColumnIndex

-- | Number of columns in a result set.
type ColumnCount = ColumnIndex

-- | Number of arguments of a user defined SQL function.
newtype ArgCount
ArgCount :: Int -> ArgCount

-- | Index of an argument to a custom function. Indices start from 0.
type ArgIndex = ArgCount
instance GHC.Show.Show Database.SQLite3.Direct.Backup
instance GHC.Classes.Eq Database.SQLite3.Direct.Backup
instance GHC.Show.Show Database.SQLite3.Direct.Blob
instance GHC.Classes.Eq Database.SQLite3.Direct.Blob
instance GHC.Show.Show Database.SQLite3.Direct.FuncContext
instance GHC.Classes.Eq Database.SQLite3.Direct.FuncContext
instance GHC.Classes.Ord Database.SQLite3.Direct.Utf8
instance GHC.Classes.Eq Database.SQLite3.Direct.Utf8
instance GHC.Show.Show Database.SQLite3.Direct.BackupStepResult
instance GHC.Classes.Eq Database.SQLite3.Direct.BackupStepResult
instance GHC.Show.Show Database.SQLite3.Direct.StepResult
instance GHC.Classes.Eq Database.SQLite3.Direct.StepResult
instance GHC.Show.Show Database.SQLite3.Direct.Statement
instance GHC.Classes.Eq Database.SQLite3.Direct.Statement
instance GHC.Show.Show Database.SQLite3.Direct.Database
instance GHC.Classes.Eq Database.SQLite3.Direct.Database
instance GHC.Show.Show Database.SQLite3.Direct.Utf8
instance Data.String.IsString Database.SQLite3.Direct.Utf8
instance GHC.Base.Monoid Database.SQLite3.Direct.Utf8

module Database.SQLite3

-- | <a>http://www.sqlite.org/c3ref/open.html</a>
open :: Text -> IO Database

-- | <a>http://www.sqlite.org/c3ref/close.html</a>
close :: Database -> IO ()

-- | Execute zero or more SQL statements delimited by semicolons.
exec :: Database -> Text -> IO ()

-- | Like <a>exec</a>, but print result rows to <a>stdout</a>.
--   
--   This is mainly for convenience when experimenting in GHCi. The output
--   format may change in the future.
execPrint :: Database -> Text -> IO ()

-- | Like <a>exec</a>, but invoke the callback for each result row.
execWithCallback :: Database -> Text -> ExecCallback -> IO ()
type ExecCallback = ColumnCount  Number of columns, which is the number of items in the following lists.  This will be the same for every row. -> [Text]  List of column names.  This will be the same for every row. -> [Maybe Text]  List of column values, as returned by 'columnText'. -> IO ()

-- | <a>http://www.sqlite.org/c3ref/prepare.html</a>
--   
--   Unlike <a>exec</a>, <a>prepare</a> only executes the first statement,
--   and ignores subsequent statements.
--   
--   If the query string contains no SQL statements, this <a>fail</a>s.
prepare :: Database -> Text -> IO Statement

-- | <a>http://www.sqlite.org/c3ref/prepare.html</a>
--   
--   It can help to avoid redundant Utf8 to Text conversion if you already
--   have Utf8
--   
--   If the query string contains no SQL statements, this <a>fail</a>s.
prepareUtf8 :: Database -> Utf8 -> IO Statement

-- | <a>http://www.sqlite.org/c3ref/step.html</a>
step :: Statement -> IO StepResult

-- | <a>http://www.sqlite.org/c3ref/reset.html</a>
--   
--   Note that in the C API, <tt>sqlite3_reset</tt> returns an error code
--   if the most recent <tt>sqlite3_step</tt> indicated an error. We do not
--   replicate that behavior here. <a>reset</a> never throws an exception.
reset :: Statement -> IO ()

-- | <a>http://www.sqlite.org/c3ref/finalize.html</a>
--   
--   Like <a>reset</a>, <a>finalize</a> never throws an exception.
finalize :: Statement -> IO ()

-- | <a>http://www.sqlite.org/c3ref/clear_bindings.html</a>
--   
--   Set all parameters in the prepared statement to null.
clearBindings :: Statement -> IO ()

-- | <a>http://www.sqlite.org/c3ref/bind_parameter_count.html</a>
--   
--   This returns the index of the largest (rightmost) parameter. Note that
--   this is not necessarily the number of parameters. If numbered
--   parameters like <tt>?5</tt> are used, there may be gaps in the list.
--   
--   See <a>ParamIndex</a> for more information.
bindParameterCount :: Statement -> IO ParamIndex

-- | <a>http://www.sqlite.org/c3ref/bind_parameter_name.html</a>
--   
--   Return the N-th SQL parameter name.
--   
--   Named parameters are returned as-is. E.g. ":v" is returned as <tt>Just
--   ":v"</tt>. Unnamed parameters, however, are converted to
--   <tt>Nothing</tt>.
--   
--   Note that the parameter index starts at 1, not 0.
bindParameterName :: Statement -> ParamIndex -> IO (Maybe Text)

-- | <a>http://www.sqlite.org/c3ref/column_count.html</a>
columnCount :: Statement -> IO ColumnCount

-- | <a>http://www.sqlite.org/c3ref/column_name.html</a>
--   
--   Return the name of a result column. If the column index is out of
--   range, return <a>Nothing</a>.
columnName :: Statement -> ColumnIndex -> IO (Maybe Text)

-- | If the index is not between 1 and <a>bindParameterCount</a> inclusive,
--   this fails with <a>ErrorRange</a>. Otherwise, it succeeds, even if the
--   query skips this index by using numbered parameters.
--   
--   Example:
--   
--   <pre>
--   &gt; stmt &lt;- prepare conn "SELECT ?1, ?3, ?5"
--   &gt; bindSQLData stmt 1 (SQLInteger 1)
--   &gt; bindSQLData stmt 2 (SQLInteger 2)
--   &gt; bindSQLData stmt 6 (SQLInteger 6)
--   *** Exception: SQLite3 returned ErrorRange while attempting to perform bind int64.
--   &gt; step stmt &gt;&gt; columns stmt
--   [SQLInteger 1,SQLNull,SQLNull]
--   </pre>
bindSQLData :: Statement -> ParamIndex -> SQLData -> IO ()

-- | Convenience function for binding values to all parameters. This will
--   <a>fail</a> if the list has the wrong number of parameters.
bind :: Statement -> [SQLData] -> IO ()

-- | Convenience function for binding named values to all parameters. This
--   will <a>fail</a> if the list has the wrong number of parameters or if
--   an unknown name is used.
--   
--   Example:
--   
--   <pre>
--   stmt &lt;- prepare conn "SELECT :foo + :bar"
--   bindNamed stmt [(":foo", SQLInteger 1), (":bar", SQLInteger 2)]
--   </pre>
bindNamed :: Statement -> [(Text, SQLData)] -> IO ()
bindInt :: Statement -> ParamIndex -> Int -> IO ()
bindInt64 :: Statement -> ParamIndex -> Int64 -> IO ()
bindDouble :: Statement -> ParamIndex -> Double -> IO ()
bindText :: Statement -> ParamIndex -> Text -> IO ()
bindBlob :: Statement -> ParamIndex -> ByteString -> IO ()
bindZeroBlob :: Statement -> ParamIndex -> Int -> IO ()
bindNull :: Statement -> ParamIndex -> IO ()
column :: Statement -> ColumnIndex -> IO SQLData
columns :: Statement -> IO [SQLData]

-- | This avoids extra API calls using the list of column types. If passed
--   types do not correspond to the actual types, the values will be
--   converted according to the rules at
--   <a>http://www.sqlite.org/c3ref/column_blob.html</a>. If the list
--   contains more items that number of columns, the result is undefined.
typedColumns :: Statement -> [Maybe ColumnType] -> IO [SQLData]
columnType :: Statement -> ColumnIndex -> IO ColumnType
columnInt64 :: Statement -> ColumnIndex -> IO Int64
columnDouble :: Statement -> ColumnIndex -> IO Double

-- | This will throw a <a>DecodeError</a> if the datum contains invalid
--   UTF-8. If this behavior is undesirable, you can use <a>columnText</a>
--   from <a>Database.SQLite3.Direct</a>, which does not perform conversion
--   to <a>Text</a>.
columnText :: Statement -> ColumnIndex -> IO Text
columnBlob :: Statement -> ColumnIndex -> IO ByteString

-- | <a>http://www.sqlite.org/c3ref/last_insert_rowid.html</a>
lastInsertRowId :: Database -> IO Int64

-- | <a>http://www.sqlite.org/c3ref/changes.html</a>
--   
--   Return the number of rows that were changed, inserted, or deleted by
--   the most recent <tt>INSERT</tt>, <tt>DELETE</tt>, or <tt>UPDATE</tt>
--   statement.
changes :: Database -> IO Int

-- | <a>http://sqlite.org/c3ref/create_function.html</a>
--   
--   Create a custom SQL function or redefine the behavior of an existing
--   function. If the function is deterministic, i.e. if it always returns
--   the same result given the same input, you can set the boolean flag to
--   let <tt>sqlite</tt> perform additional optimizations.
createFunction :: Database -> Text -> Maybe ArgCount -> Bool -> (FuncContext -> FuncArgs -> IO ()) -> IO ()

-- | Like <a>createFunction</a> except that it creates an aggregate
--   function.
createAggregate :: Database -> Text -> Maybe ArgCount -> a -> (FuncContext -> FuncArgs -> a -> IO a) -> (FuncContext -> a -> IO ()) -> IO ()

-- | Delete an SQL function (scalar or aggregate).
deleteFunction :: Database -> Text -> Maybe ArgCount -> IO ()
funcArgCount :: FuncArgs -> ArgCount
funcArgType :: FuncArgs -> ArgIndex -> IO ColumnType
funcArgInt64 :: FuncArgs -> ArgIndex -> IO Int64
funcArgDouble :: FuncArgs -> ArgIndex -> IO Double
funcArgText :: FuncArgs -> ArgIndex -> IO Text
funcArgBlob :: FuncArgs -> ArgIndex -> IO ByteString
funcResultSQLData :: FuncContext -> SQLData -> IO ()
funcResultInt64 :: FuncContext -> Int64 -> IO ()
funcResultDouble :: FuncContext -> Double -> IO ()
funcResultText :: FuncContext -> Text -> IO ()
funcResultBlob :: FuncContext -> ByteString -> IO ()
funcResultZeroBlob :: FuncContext -> Int -> IO ()
funcResultNull :: FuncContext -> IO ()

-- | <a>https://www.sqlite.org/c3ref/context_db_handle.html</a>
getFuncContextDatabase :: FuncContext -> IO Database

-- | <a>http://www.sqlite.org/c3ref/create_collation.html</a>
createCollation :: Database -> Text -> (Text -> Text -> Ordering) -> IO ()

-- | Delete a collation.
deleteCollation :: Database -> Text -> IO ()

-- | <a>http://www.sqlite.org/c3ref/interrupt.html</a>
--   
--   Cause any pending operation on the <a>Database</a> handle to stop at
--   its earliest opportunity. This simply sets a flag and returns
--   immediately. It does not wait for the pending operation to finish.
--   
--   You'll need to compile with <tt>-threaded</tt> for this to do any
--   good. Without <tt>-threaded</tt>, FFI calls block the whole RTS,
--   meaning <a>interrupt</a> would never run at the same time as
--   <a>step</a>.
interrupt :: Database -> IO ()

-- | Make it possible to interrupt the given database operation with an
--   asynchronous exception. This only works if the program is compiled
--   with base &gt;= 4.3 and <tt>-threaded</tt>.
--   
--   It works by running the callback in a forked thread. If interrupted,
--   it uses <a>interrupt</a> to try to stop the operation.
interruptibly :: Database -> IO a -> IO a

-- | <a>https://www.sqlite.org/c3ref/blob_open.html</a>
--   
--   Open a blob for incremental I/O.
blobOpen :: Database -> Text -> Text -> Text -> Int64 -> Bool -> IO Blob

-- | <a>https://www.sqlite.org/c3ref/blob_close.html</a>
blobClose :: Blob -> IO ()

-- | <a>https://www.sqlite.org/c3ref/blob_reopen.html</a>
blobReopen :: Blob -> Int64 -> IO ()

-- | <a>https://www.sqlite.org/c3ref/blob_bytes.html</a>
blobBytes :: Blob -> IO Int

-- | <a>https://www.sqlite.org/c3ref/blob_read.html</a>
blobRead :: Blob -> Int -> Int -> IO ByteString
blobReadBuf :: Blob -> Ptr a -> Int -> Int -> IO ()

-- | <a>https://www.sqlite.org/c3ref/blob_write.html</a>
blobWrite :: Blob -> ByteString -> Int -> IO ()
backupInit :: Database -> Text -> Database -> Text -> IO Backup
backupFinish :: Backup -> IO (())
backupStep :: Backup -> Int -> IO BackupStepResult
backupRemaining :: Backup -> IO Int
backupPagecount :: Backup -> IO Int
data Database
data Statement
data SQLData
SQLInteger :: !Int64 -> SQLData
SQLFloat :: !Double -> SQLData
SQLText :: !Text -> SQLData
SQLBlob :: !ByteString -> SQLData
SQLNull :: SQLData

-- | Exception thrown when SQLite3 reports an error.
--   
--   direct-sqlite may throw other types of exceptions if you misuse the
--   API.
data SQLError
SQLError :: !Error -> Text -> Text -> SQLError

-- | Error code returned by API call
[sqlError] :: SQLError -> !Error

-- | Text describing the error
[sqlErrorDetails] :: SQLError -> Text

-- | Indicates what action produced this error, e.g. <tt>exec "SELECT *
--   FROM foo"</tt>
[sqlErrorContext] :: SQLError -> Text
data ColumnType
IntegerColumn :: ColumnType
FloatColumn :: ColumnType
TextColumn :: ColumnType
BlobColumn :: ColumnType
NullColumn :: ColumnType

-- | The context in which a custom SQL function is executed.
data FuncContext

-- | The arguments of a custom SQL function.
data FuncArgs

-- | The type of blob handles used for incremental blob I/O
data Blob

-- | A handle for an online backup process.
data Backup
data StepResult
Row :: StepResult
Done :: StepResult
data BackupStepResult

-- | There are still more pages to be copied.
BackupOK :: BackupStepResult

-- | All pages were successfully copied.
BackupDone :: BackupStepResult
data Error

-- | Successful result
ErrorOK :: Error

-- | SQL error or missing database
ErrorError :: Error

-- | Internal logic error in SQLite
ErrorInternal :: Error

-- | Access permission denied
ErrorPermission :: Error

-- | Callback routine requested an abort
ErrorAbort :: Error

-- | The database file is locked
ErrorBusy :: Error

-- | A table in the database is locked
ErrorLocked :: Error

-- | A <tt>malloc()</tt> failed
ErrorNoMemory :: Error

-- | Attempt to write a readonly database
ErrorReadOnly :: Error

-- | Operation terminated by <tt>sqlite3_interrupt()</tt>
ErrorInterrupt :: Error

-- | Some kind of disk I/O error occurred
ErrorIO :: Error

-- | The database disk image is malformed
ErrorCorrupt :: Error

-- | Unknown opcode in <tt>sqlite3_file_control()</tt>
ErrorNotFound :: Error

-- | Insertion failed because database is full
ErrorFull :: Error

-- | Unable to open the database file
ErrorCan'tOpen :: Error

-- | Database lock protocol error
ErrorProtocol :: Error

-- | Database is empty
ErrorEmpty :: Error

-- | The database schema changed
ErrorSchema :: Error

-- | String or BLOB exceeds size limit
ErrorTooBig :: Error

-- | Abort due to constraint violation
ErrorConstraint :: Error

-- | Data type mismatch
ErrorMismatch :: Error

-- | Library used incorrectly
ErrorMisuse :: Error

-- | Uses OS features not supported on host
ErrorNoLargeFileSupport :: Error

-- | Authorization denied
ErrorAuthorization :: Error

-- | Auxiliary database format error
ErrorFormat :: Error

-- | 2nd parameter to sqlite3_bind out of range
ErrorRange :: Error

-- | File opened that is not a database file
ErrorNotADatabase :: Error

-- | <tt>sqlite3_step()</tt> has another row ready
ErrorRow :: Error

-- | <tt>sqlite3_step()</tt> has finished executing
ErrorDone :: Error

-- | Index of a parameter in a parameterized query. Parameter indices start
--   from 1.
--   
--   When a query is <a>prepare</a>d, SQLite allocates an array indexed
--   from 1 to the highest parameter index. For example:
--   
--   <pre>
--   &gt;Right stmt &lt;- prepare conn "SELECT ?1, ?5, ?3, ?"
--   &gt;bindParameterCount stmt
--   ParamIndex 6
--   </pre>
--   
--   This will allocate an array indexed from 1 to 6 (<tt>?</tt> takes the
--   highest preceding index plus one). The array is initialized with null
--   values. When you bind a parameter with <a>bindSQLData</a>, it assigns
--   a new value to one of these indices.
--   
--   See <a>http://www.sqlite.org/lang_expr.html#varparam</a> for the
--   syntax of parameter placeholders, and how parameter indices are
--   assigned.
newtype ParamIndex
ParamIndex :: Int -> ParamIndex

-- | Index of a column in a result set. Column indices start from 0.
newtype ColumnIndex
ColumnIndex :: Int -> ColumnIndex

-- | Number of columns in a result set.
type ColumnCount = ColumnIndex

-- | Number of arguments of a user defined SQL function.
newtype ArgCount
ArgCount :: Int -> ArgCount

-- | Index of an argument to a custom function. Indices start from 0.
type ArgIndex = ArgCount
instance GHC.Classes.Eq Database.SQLite3.SQLError
instance GHC.Show.Show Database.SQLite3.SQLData
instance GHC.Classes.Eq Database.SQLite3.SQLData
instance GHC.Show.Show Database.SQLite3.SQLError
instance GHC.Exception.Exception Database.SQLite3.SQLError
