unison-sqlite-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.Sqlite

Description

The Unison monorepo interface to SQLite.

This module provides a high(-er) level interface to SQLite than the sqlite-simple library, which it wraps. Code that interacts with SQLite in this monorepo should use this interface, rather than sqlite-simple or direct-sqlite directly.

Three variants of the main query interface are provided:

Synopsis

Connection management

data Connection Source #

A non-thread safe connection to a SQLite database.

Instances

Instances details
Show Connection Source # 
Instance details

Defined in Unison.Sqlite.Connection.Internal

withConnection Source #

Arguments

:: MonadUnliftIO m 
=> String

Connection name, for debugging.

-> FilePath

Path to SQLite database file.

-> (Connection -> m a) 
-> m a 

Perform an action with a connection to a SQLite database.

Note: the connection is created with PRAGMA foreign_keys = ON automatically, to work around the fact that SQLite does not automatically enforce foreign key integrity, because it elected to maintain backwards compatibility with code that was written before the foreign key integrity feature was implemented.

Transaction interface

data Transaction a Source #

Instances

Instances details
Applicative Transaction Source # 
Instance details

Defined in Unison.Sqlite.Transaction

Methods

pure :: a -> Transaction a #

(<*>) :: Transaction (a -> b) -> Transaction a -> Transaction b #

liftA2 :: (a -> b -> c) -> Transaction a -> Transaction b -> Transaction c #

(*>) :: Transaction a -> Transaction b -> Transaction b #

(<*) :: Transaction a -> Transaction b -> Transaction a #

Functor Transaction Source # 
Instance details

Defined in Unison.Sqlite.Transaction

Methods

fmap :: (a -> b) -> Transaction a -> Transaction b #

(<$) :: a -> Transaction b -> Transaction a #

Monad Transaction Source # 
Instance details

Defined in Unison.Sqlite.Transaction

Methods

(>>=) :: Transaction a -> (a -> Transaction b) -> Transaction b #

(>>) :: Transaction a -> Transaction b -> Transaction b #

return :: a -> Transaction a #

Monoid a => Monoid (Transaction a) Source # 
Instance details

Defined in Unison.Sqlite.Transaction

Semigroup a => Semigroup (Transaction a) Source # 
Instance details

Defined in Unison.Sqlite.Transaction

runTransaction :: (MonadIO m, HasCallStack) => Connection -> Transaction a -> m a Source #

Run a transaction on the given connection.

runTransactionWithRollback :: (MonadIO m, HasCallStack) => Connection -> ((forall void. a -> Transaction void) -> Transaction a) -> m a Source #

Run a transaction on the given connection, providing a function that can short-circuit (and roll back) the transaction.

runReadOnlyTransaction :: (MonadUnliftIO m, HasCallStack) => Connection -> ((forall x. Transaction x -> m x) -> m a) -> m a Source #

Run a transaction that is known to only perform reads.

The action is provided a function that peels off the Transaction newtype without sending the corresponding BEGIN/COMMIT statements.

The transaction is never retried, so it is (more) safe to interleave arbitrary IO actions. If the transaction does attempt a write and gets SQLITE_BUSY, it's your fault!

runWriteTransaction :: (HasCallStack, MonadUnliftIO m) => Connection -> ((forall x. Transaction x -> m x) -> m a) -> m a Source #

Run a transaction that is known to perform at least one write.

The action is provided a function that peels off the Transaction newtype without sending the corresponding BEGIN/COMMIT statements.

The transaction is never retried, so it is (more) safe to interleave arbitrary IO actions.

cacheTransaction :: forall k v. Cache k v -> (k -> Transaction v) -> k -> Transaction v Source #

Wrap a transaction with a cache; cache hits will not hit SQLite.

savepoint :: Transaction (Either a a) -> Transaction a Source #

Perform an atomic sub-computation within a transaction; if it returns Left, it's rolled back.

Unsafe things

unsafeIO :: HasCallStack => IO a -> Transaction a Source #

Perform IO inside a transaction, which should be idempotent, because it may be run more than once if the transaction needs to retry.

Warning: attempting to run a transaction inside a transaction will cause an exception!

unsafeUnTransaction :: Transaction a -> Connection -> IO a Source #

Unwrap the transaction newtype, throwing away the sending of BEGIN/COMMIT + automatic retry.

Executing queries

data Sql Source #

A SQL query.

Instances

Instances details
Show Sql Source # 
Instance details

Defined in Unison.Sqlite.Sql

Methods

showsPrec :: Int -> Sql -> ShowS #

show :: Sql -> String #

showList :: [Sql] -> ShowS #

sql :: QuasiQuoter Source #

A quasi-quoter for producing a Sql from a SQL query string, using the Haskell variables in scope for each named parameter.

For example, the query

let qux = 5 :: Int

[sql|
  SELECT foo
  FROM bar
  WHERE baz = :qux
|]

would produce a value like

Sql
  { query = "SELECT foo FROM bar WHERE baz = ?"
  , params = [SQLInteger 5]
  }

which, of course, will require a qux with a ToField instance in scope.

There are five valid syntaxes for interpolating a variable:

  • :colon, which denotes a single-field variable
  • @at, followed by 1+ bare @, which denotes a multi-field variable
  • $dollar, which denotes an entire Sql fragment
  • IN :colon, which denotes an IN expression, where the right-hand side is a list of scalars
  • VALUES :colon, which denotes an entire VALUES literal (1+ tuples)

As an example of the @at syntax, consider a variable plonk with a two-field ToRow instance. A query that interpolates plonk might look like:

[sql|
  SELECT foo
  FROM bar
  WHERE stuff = @plonk
    AND other = @
|]

As an example of $dollar syntax,

let foo = [sql| bar |] in [sql| $foo baz |]

splices foo into the second fragment, and is equivalent to

[sql| bar baz |]

As an example of IN :colon syntax, the query

[sql| IN :foo |]

will require a list "foo" to be in scope, whose elements have ToField instances, and will expand to SQL that looks like

IN (?, ?, ?, ?)

depending on how man elements "foo" has.

As an example of VALUES :colon syntax, the query

[sql| VALUES :foo |]

will require a non-empty list "foo" to be in scope, whose elements have ToRow instances, and will expand to SQL that looks like

VALUES (?, ?), (?, ?), (?, ?)

depending on how many elements "foo" has, and how wide its rows are.

Without results

With results

Queries that return results have many different variants.

Every function name begins with the string query.

  1. Row count. The caller may expect exactly one, zero or one, or zero or more rows, in which case the function name includes the string One, Maybe, or (List or Stream), respectively. Example: queryListRow.
  2. Row width. The caller may expect the returned rows may contain exactly one or more than one column, in which case the function name includes the string Col or Row, respectively. Example: queryOneCol.
  3. Result checks. The caller may want to perform additional validation on the returned rows, in which case the function name includes the string Check. Example: queryMaybeColCheck.

All together, the full anatomy of a query function is:

query(List|Maybe|One)(Row|Col)[Check]

With checks

Rows modified

Data version

newtype DataVersion Source #

Constructors

DataVersion Int64 

Instances

Instances details
Show DataVersion Source # 
Instance details

Defined in Unison.Sqlite.DataVersion

Eq DataVersion Source # 
Instance details

Defined in Unison.Sqlite.DataVersion

Journal mode

Vacuum

vacuum :: Connection -> IO Bool Source #

VACUUM, and return whether or not the vacuum succeeded. A vacuum fails if the connection has any open transactions.

vacuumInto :: Connection -> FilePath -> IO () Source #

VACUUM INTO

Exceptions

data SomeSqliteException Source #

The root exception for all exceptions thrown by this library.

SomeException (from base)
  └── SomeSqliteException
        └── SqliteConnectException
        └── SqliteQueryException

A SomeSqliteException should not be inspected or used for control flow when run in a trusted environment, where the database can be assumed to be uncorrupt. Rather, wherever possible, the user of this library should write code that is guaranteed not to throw exceptions, by checking the necessary preconditions first. If that is not possible, it should be considered a bug in this library.

When actions are run on an untrusted codebase, e.g. one downloaded from a remote server, it is sufficient to catch just one exception type, SomeSqliteException.

Constructors

forall e.Exception e => SomeSqliteException e 

data SqliteQueryException Source #

A SqliteQueryException represents an exception thrown during processing a query, paired with some context that resulted in the exception.

A SqliteQueryException may result from a number of different conditions:

  • The underlying sqlite library threw an exception.
  • A postcondition violation of a function like queryMaybeRow, which asserts that the resulting relation will have certain number of rows,
  • A postcondition violation of a function like queryListRowCheck, which takes a user-defined check as an argument.

A SqliteQueryException should not be inspected or used for control flow when run in a trusted environment, where the database can be assumed to be uncorrupt. Rather, wherever possible, the user of this library should write code that is guaranteed not to throw exceptions, by checking the necessary preconditions first. If that is not possible, it should be considered a bug in this library.

When actions are run on an untrusted codebase, e.g. one downloaded from a remote server, it is sufficient to catch just one exception type, SqliteQueryException.

class (Show e, Typeable e) => SqliteExceptionReason e Source #

A type that is intended to be used as additional context for a sqlite-related exception.

newtype ExpectedAtMostOneRowException Source #

A query was expected to return exactly one row, but it did not. The exception carries a string representation of the rows that were actually returned.

Constructors

ExpectedAtMostOneRowException 

Fields

newtype ExpectedExactlyOneRowException Source #

A query was expected to return exactly one row, but it did not. The exception carries a string representation of the rows that were actually returned.

Re-exports

data h :. t infixr 3 #

A composite type to parse your custom data structures without having to define dummy newtype wrappers every time.

instance FromRow MyData where ...
instance FromRow MyData2 where ...

then I can do the following for free:

res <- query' c "..."
forM res $ \(MyData{..} :. MyData2{..}) -> do
  ....

Constructors

h :. t infixr 3 

Instances

Instances details
(Read h, Read t) => Read (h :. t) 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

readsPrec :: Int -> ReadS (h :. t) #

readList :: ReadS [h :. t] #

readPrec :: ReadPrec (h :. t) #

readListPrec :: ReadPrec [h :. t] #

(Show h, Show t) => Show (h :. t) 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

showsPrec :: Int -> (h :. t) -> ShowS #

show :: (h :. t) -> String #

showList :: [h :. t] -> ShowS #

(Eq h, Eq t) => Eq (h :. t) 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

(==) :: (h :. t) -> (h :. t) -> Bool #

(/=) :: (h :. t) -> (h :. t) -> Bool #

(Ord h, Ord t) => Ord (h :. t) 
Instance details

Defined in Database.SQLite.Simple.Types

Methods

compare :: (h :. t) -> (h :. t) -> Ordering #

(<) :: (h :. t) -> (h :. t) -> Bool #

(<=) :: (h :. t) -> (h :. t) -> Bool #

(>) :: (h :. t) -> (h :. t) -> Bool #

(>=) :: (h :. t) -> (h :. t) -> Bool #

max :: (h :. t) -> (h :. t) -> h :. t #

min :: (h :. t) -> (h :. t) -> h :. t #

(FromRow a, FromRow b) => FromRow (a :. b) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a :. b) #

(ToRow a, ToRow b) => ToRow (a :. b) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a :. b) -> [SQLData] #

class FromField a where #

A type that may be converted from a SQL type.

Methods

fromField :: FieldParser a #

Convert a SQL value to a Haskell value.

Returns a list of exceptions if the conversion fails. In the case of library instances, this will usually be a single ResultError, but may be a UnicodeException.

Implementations of fromField should not retain any references to the Field nor the ByteString arguments after the result has been evaluated to WHNF. Such a reference causes the entire LibPQ.Result to be retained.

For example, the instance for ByteString uses copy to avoid such a reference, and that using bytestring functions such as drop and takeWhile alone will also trigger this memory leak.

Instances

Instances details
FromField Int16 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Int32 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Int64 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Int8 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Word16 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Word32 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Word64 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Word8 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField ByteString 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField ByteString 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField SQLData 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Null 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Text 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Text 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Day 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField UTCTime 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Integer 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Bool 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Double 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Float 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Int 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField Word 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField a => FromField (Maybe a) 
Instance details

Defined in Database.SQLite.Simple.FromField

FromField [Char] 
Instance details

Defined in Database.SQLite.Simple.FromField

class FromRow a where #

A collection type that can be converted from a sequence of fields. Instances are provided for tuples up to 10 elements and lists of any length.

Note that instances can defined outside of sqlite-simple, which is often useful. For example, here's an instance for a user-defined pair:

data User = User { name :: String, fileQuota :: Int }

instance FromRow User where
    fromRow = User <$> field <*> field

The number of calls to field must match the number of fields returned in a single row of the query result. Otherwise, a ConversionFailed exception will be thrown.

Note the caveats associated with user-defined implementations of fromRow.

Generic implementation

Since version 0.4.18.1 it is possible in some cases to derive a generic implementation for FromRow. With a Generic instance for User, the example above could be written:

instance FromRow User where

With -XDeriveAnyClass -XDerivingStrategies the same can be written:

deriving anyclass instance FromRow User

For more details refer to GFromRow.

Minimal complete definition

Nothing

Methods

fromRow :: RowParser a #

Instances

Instances details
FromField a => FromRow (Only a) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (Only a) #

FromField a => FromRow [a] 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser [a] #

(FromRow a, FromRow b) => FromRow (a :. b) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a :. b) #

(FromField a, FromField b) => FromRow (a, b) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b) #

(FromField a, FromField b, FromField c) => FromRow (a, b, c) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c) #

(FromField a, FromField b, FromField c, FromField d) => FromRow (a, b, c, d) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d) #

(FromField a, FromField b, FromField c, FromField d, FromField e) => FromRow (a, b, c, d, e) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e) #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f) => FromRow (a, b, c, d, e, f) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f) #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g) => FromRow (a, b, c, d, e, f, g) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g) #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h) => FromRow (a, b, c, d, e, f, g, h) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h) #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i) => FromRow (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i) #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j) => FromRow (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j) #

newtype Only a #

The 1-tuple type or single-value "collection".

This type is structurally equivalent to the Identity type, but its intent is more about serving as the anonymous 1-tuple type missing from Haskell for attaching typeclass instances.

Parameter usage example:

encodeSomething (Only (42::Int))

Result usage example:

xs <- decodeSomething
forM_ xs $ \(Only id) -> {- ... -}

Constructors

Only 

Fields

Instances

Instances details
Functor Only 
Instance details

Defined in Data.Tuple.Only

Methods

fmap :: (a -> b) -> Only a -> Only b #

(<$) :: a -> Only b -> Only a #

Data a => Data (Only a) 
Instance details

Defined in Data.Tuple.Only

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Only a -> c (Only a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Only a) #

toConstr :: Only a -> Constr #

dataTypeOf :: Only a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Only a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Only a)) #

gmapT :: (forall b. Data b => b -> b) -> Only a -> Only a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Only a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Only a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Only a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Only a -> m (Only a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Only a -> m (Only a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Only a -> m (Only a) #

Generic (Only a) 
Instance details

Defined in Data.Tuple.Only

Associated Types

type Rep (Only a) :: Type -> Type #

Methods

from :: Only a -> Rep (Only a) x #

to :: Rep (Only a) x -> Only a #

Read a => Read (Only a) 
Instance details

Defined in Data.Tuple.Only

Show a => Show (Only a) 
Instance details

Defined in Data.Tuple.Only

Methods

showsPrec :: Int -> Only a -> ShowS #

show :: Only a -> String #

showList :: [Only a] -> ShowS #

NFData a => NFData (Only a) 
Instance details

Defined in Data.Tuple.Only

Methods

rnf :: Only a -> () #

Eq a => Eq (Only a) 
Instance details

Defined in Data.Tuple.Only

Methods

(==) :: Only a -> Only a -> Bool #

(/=) :: Only a -> Only a -> Bool #

Ord a => Ord (Only a) 
Instance details

Defined in Data.Tuple.Only

Methods

compare :: Only a -> Only a -> Ordering #

(<) :: Only a -> Only a -> Bool #

(<=) :: Only a -> Only a -> Bool #

(>) :: Only a -> Only a -> Bool #

(>=) :: Only a -> Only a -> Bool #

max :: Only a -> Only a -> Only a #

min :: Only a -> Only a -> Only a #

FromField a => FromRow (Only a) 
Instance details

Defined in Database.SQLite.Simple.FromRow

Methods

fromRow :: RowParser (Only a) #

ToField a => ToRow (Only a) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: Only a -> [SQLData] #

type Rep (Only a) 
Instance details

Defined in Data.Tuple.Only

type Rep (Only a) = D1 ('MetaData "Only" "Data.Tuple.Only" "Only-0.1-DItEcvi68ww8z5TVixWVcj" 'True) (C1 ('MetaCons "Only" 'PrefixI 'True) (S1 ('MetaSel ('Just "fromOnly") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

data RowParser a #

Instances

Instances details
Alternative RowParser 
Instance details

Defined in Database.SQLite.Simple.Internal

Methods

empty :: RowParser a #

(<|>) :: RowParser a -> RowParser a -> RowParser a #

some :: RowParser a -> RowParser [a] #

many :: RowParser a -> RowParser [a] #

Applicative RowParser 
Instance details

Defined in Database.SQLite.Simple.Internal

Methods

pure :: a -> RowParser a #

(<*>) :: RowParser (a -> b) -> RowParser a -> RowParser b #

liftA2 :: (a -> b -> c) -> RowParser a -> RowParser b -> RowParser c #

(*>) :: RowParser a -> RowParser b -> RowParser b #

(<*) :: RowParser a -> RowParser b -> RowParser a #

Functor RowParser 
Instance details

Defined in Database.SQLite.Simple.Internal

Methods

fmap :: (a -> b) -> RowParser a -> RowParser b #

(<$) :: a -> RowParser b -> RowParser a #

Monad RowParser 
Instance details

Defined in Database.SQLite.Simple.Internal

Methods

(>>=) :: RowParser a -> (a -> RowParser b) -> RowParser b #

(>>) :: RowParser a -> RowParser b -> RowParser b #

return :: a -> RowParser a #

MonadPlus RowParser 
Instance details

Defined in Database.SQLite.Simple.Internal

Methods

mzero :: RowParser a #

mplus :: RowParser a -> RowParser a -> RowParser a #

data SQLData #

Instances

Instances details
Generic SQLData 
Instance details

Defined in Database.SQLite3

Associated Types

type Rep SQLData :: Type -> Type #

Methods

from :: SQLData -> Rep SQLData x #

to :: Rep SQLData x -> SQLData #

Show SQLData 
Instance details

Defined in Database.SQLite3

Eq SQLData 
Instance details

Defined in Database.SQLite3

Methods

(==) :: SQLData -> SQLData -> Bool #

(/=) :: SQLData -> SQLData -> Bool #

FromField SQLData 
Instance details

Defined in Database.SQLite.Simple.FromField

ToField SQLData 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: SQLData -> SQLData #

type Rep SQLData 
Instance details

Defined in Database.SQLite3

class ToField a where #

A type that may be used as a single parameter to a SQL query.

Methods

toField :: a -> SQLData #

Prepare a value for substitution into a query string.

Instances

Instances details
ToField Int16 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Int16 -> SQLData #

ToField Int32 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Int32 -> SQLData #

ToField Int64 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Int64 -> SQLData #

ToField Int8 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Int8 -> SQLData #

ToField Word16 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Word16 -> SQLData #

ToField Word32 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Word32 -> SQLData #

ToField Word64 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Word64 -> SQLData #

ToField Word8 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Word8 -> SQLData #

ToField ByteString 
Instance details

Defined in Database.SQLite.Simple.ToField

ToField ByteString 
Instance details

Defined in Database.SQLite.Simple.ToField

ToField SQLData 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: SQLData -> SQLData #

ToField Null 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Null -> SQLData #

ToField Text 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Text -> SQLData #

ToField Text 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Text -> SQLData #

ToField Day 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Day -> SQLData #

ToField UTCTime 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: UTCTime -> SQLData #

ToField Integer 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Integer -> SQLData #

ToField Bool 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Bool -> SQLData #

ToField Double 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Double -> SQLData #

ToField Float 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Float -> SQLData #

ToField Int 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Int -> SQLData #

ToField Word 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Word -> SQLData #

ToField a => ToField (Maybe a) 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: Maybe a -> SQLData #

ToField [Char] 
Instance details

Defined in Database.SQLite.Simple.ToField

Methods

toField :: [Char] -> SQLData #

class ToRow a where #

A collection type that can be turned into a list of SQLData elements.

Since version 0.4.18.1 it is possible in some cases to derive a generic implementation for ToRow. Refer to the documentation for FromRow to see how this can be done.

Minimal complete definition

Nothing

Methods

toRow :: a -> [SQLData] #

ToField a collection of values.

Instances

Instances details
ToRow () 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: () -> [SQLData] #

ToField a => ToRow (Only a) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: Only a -> [SQLData] #

ToField a => ToRow [a] 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: [a] -> [SQLData] #

(ToRow a, ToRow b) => ToRow (a :. b) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a :. b) -> [SQLData] #

(ToField a, ToField b) => ToRow (a, b) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b) -> [SQLData] #

(ToField a, ToField b, ToField c) => ToRow (a, b, c) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d) => ToRow (a, b, c, d) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e) => ToRow (a, b, c, d, e) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f) => ToRow (a, b, c, d, e, f) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e, f) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f, ToField g) => ToRow (a, b, c, d, e, f, g) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e, f, g) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f, ToField g, ToField h) => ToRow (a, b, c, d, e, f, g, h) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e, f, g, h) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f, ToField g, ToField h, ToField i) => ToRow (a, b, c, d, e, f, g, h, i) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e, f, g, h, i) -> [SQLData] #

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f, ToField g, ToField h, ToField i, ToField j) => ToRow (a, b, c, d, e, f, g, h, i, j) 
Instance details

Defined in Database.SQLite.Simple.ToRow

Methods

toRow :: (a, b, c, d, e, f, g, h, i, j) -> [SQLData] #