-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A minimalistic general high level API for relational databases -- @package hasql @version 0.1.4 -- | 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. type Session b = ReaderT (Pool (Connection b)) -- | Given backend settings, session settings, and a session monad -- transformer, execute it in the inner monad. session :: Backend b => MonadBaseControl IO m => b -> SessionSettings -> Session b 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 backend b, running on an -- anonymous state-thread s and producing a result r. data Tx b s r -- | Execute a transaction in a session. tx :: Backend b => MonadBase IO m => Mode -> (forall s. Tx b s r) -> Session b m r -- | A transaction mode defining how a transaction should be executed. -- --
-- 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 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 => ListMonad (TxListT s m) instance ListTrans (TxListT s) instance Exception Error