-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A minimalistic general high level API for relational databases -- -- A robust and concise yet powerful API for communication with arbitrary -- relational databases using SQL. -- -- Features: -- -- -- -- Links: -- -- @package hasql @version 0.4.1 -- | This is the API of the "hasql" library. For an introduction to the -- package and links to more documentation please refer to the -- package's index page. module Hasql -- | A monad transformer, which executes transactions. -- -- data Session b s m r -- | Given backend settings, session settings, and a session monad -- transformer, execute it in the inner monad. -- -- It uses the same trick as ST with the anonymous s type -- argument to prohibit the use of the result of sessionUnlifter -- outside of its creator session. session :: (Backend b, MonadBaseControl IO m) => b -> SessionSettings -> (forall s. Session b s m r) -> m r -- | Get a session unlifting function, which allows to execute a session in -- the inner monad using the resources of the current session. -- -- Using this function in combination with lift you can interleave -- Session with other monad transformers. -- -- This function has the following property: -- --
--   (sessionUnlifter >>= \unlift -> lift (unlift m)) ≡ m
--   
sessionUnlifter :: MonadBaseControl IO m => Session b s m (Session b s m r -> m r) -- | Settings of a session. data SessionSettings -- | A smart constructor for session settings. sessionSettings :: Word32 -> NominalDiffTime -> Maybe SessionSettings -- | A transaction specialized for a backend b, associated with -- its intermediate results using an anonymous type-argument s -- (same as in ST) and producing a result r. data Tx b s r -- | Execute a transaction in a session. -- -- This function ensures on the type level, that it's impossible to -- return TxListT s m r from it. tx :: (Backend b, MonadBase IO m) => Mode -> (forall s. Tx b s r) -> Session b s m r -- | A transaction mode defining how a transaction should be executed. -- -- type Mode = Maybe (IsolationLevel, Bool) -- | For reference see the Wikipedia info. data IsolationLevel :: * Serializable :: IsolationLevel RepeatableReads :: IsolationLevel ReadCommitted :: IsolationLevel ReadUncommitted :: IsolationLevel -- | Produces a lambda-expression, which takes as many parameters as there -- are placeholders in the quoted text and results in a Statement. -- -- E.g.: -- --
--   selectFive :: Statement b
--   selectFive = [q|SELECT (? + ?)|] 2 3
--   
q :: QuasiQuoter -- | Execute a statement, which produces no result. unit :: Backend b => Statement b -> Tx b s () -- | Execute a statement and count the amount of affected rows. Useful for -- resolving how many rows were updated or deleted. count :: (Backend b, Mapping b Word64) => Statement b -> Tx b s Word64 -- | Execute a statement, which produces a single result row: a -- SELECT or an INSERT, which produces a generated -- value (e.g., an auto-incremented id). single :: (Backend b, RowParser b r) => Statement b -> Tx b s (Maybe r) -- | Execute a SELECT statement, and produce a list of results. list :: (Backend b, RowParser b r) => Statement b -> Tx b s [r] -- | Execute a SELECT statement with a cursor, and produce a -- results stream. -- -- Cursor allows you to fetch virtually limitless results in a constant -- memory at a cost of a small overhead. Note that in most databases -- cursors require establishing a database transaction, so a -- NotInTransaction error will be raised if you run it improperly. stream :: (Backend b, RowParser b r) => Statement b -> TxListT s (Tx b s) r -- | A stream of results, which fetches only those that you reach. -- -- It's a wrapper around ListT, which uses the same trick as the -- ST monad to associate with the context transaction and become -- impossible to be used outside of it. This lets the library ensure that -- it is safe to automatically release all the resources associated with -- this stream. -- -- All the functions of the "list-t" library are applicable to this type, -- amongst which are head, toList, fold, -- traverse_. data TxListT s m r class RowParser b r parseRow :: RowParser b r => Vector (Result b) -> Either Text r -- | The only exception type that this API can raise. data Error -- | Cannot connect to a server. CantConnect :: Text -> Error -- | The connection got interrupted. ConnectionLost :: Text -> Error -- | An error returned from the database. ErroneousResult :: Text -> Error -- | Unexpected result structure. Indicates usage of inappropriate -- statement executor. UnexpectedResult :: Text -> Error -- | Incorrect statement template. UnparsableTemplate :: Text -> Error -- | An operation, which requires a database transaction was executed -- without one. NotInTransaction :: Error -- | Attempt to parse a row into an incompatible type. Indicates either a -- mismatching schema or an incorrect query. UnparsableRow :: Text -> Error instance Typeable Error instance Functor m => Functor (Session b s m) instance Applicative m => Applicative (Session b s m) instance Monad m => Monad (Session b s m) instance MonadTrans (Session b s) instance MonadIO m => MonadIO (Session b s m) instance Show Error instance Eq Error instance Ord Error instance Functor (Tx b s) instance Applicative (Tx b s) instance Monad (Tx b s) instance Functor m => Functor (TxListT s m) instance (Monad m, Functor m) => Applicative (TxListT s m) instance (Monad m, Functor m) => Alternative (TxListT s m) instance Monad m => Monad (TxListT s m) instance MonadTrans (TxListT s) instance Monad m => MonadPlus (TxListT s m) instance Monad m => Monoid (TxListT s m r) instance Monad m => MonadCons (TxListT s m) instance MonadTransUncons (TxListT s) instance Exception Error instance MonadBaseControl IO m => MonadBaseControl IO (Session b s m) instance MonadBase IO m => MonadBase IO (Session b s m) instance MonadTransControl (Session b s)