hasql-backend-0.4.2: API for backends of "hasql"

Safe HaskellNone




An open API for implementation of specific backend drivers.



class Cx c where Source

Associated Types

type CxSettings c Source

Connection settings.

type CxError c Source

A connection acquisition error.


acquireCx :: CxSettings c -> IO (Either (CxError c) c) Source

releaseCx :: c -> IO () Source


data family ResultValue c Source

A raw value returned from the database.

type ResultRow c = Vector (ResultValue c) Source

A raw result row.

type ResultStream c = ListT IO (ResultRow c) Source

A stream of rows of a result.

type ResultMatrix c = Vector (ResultRow c) Source

A matrix of a result.


data Stmt c Source

A statement template packed with its values and settings.



data family StmtParam c Source

A prepared statement parameter.


class CxValue c v where Source

A support by a backend of mapping a specific data type.


class CxTx c where Source

A transaction execution support.

Associated Types

type TxError c Source

A transaction error.


runTx :: c -> TxMode -> Tx c a -> IO (Either (TxError c) (Maybe a)) Source

Given an established connection execute a transaction, returning either an error or a maybe result, in which a Nothing indicates that the transaction should be retried.

type TxMode = Maybe (TxIsolationLevel, TxWriteMode) Source

A mode, defining how a transaction should be executed.

  • Just (isolationLevel, write) indicates that a database transaction should be established with a specified isolation level and a write mode.
  • Nothing indicates that there should be no database transaction established on the backend and therefore it should be executed with no ACID guarantees, but also without any induced overhead.

type TxWriteMode = Maybe Bool Source

  • Nothing indicates a "read" mode.
  • Just True indicates a "write" mode.
  • Just False indicates a "write" mode without committing. This is useful for testing, allowing you to modify your database, producing some result based on your changes, and to let Hasql roll all the changes back on the exit from the transaction.

type Tx c = FreeT (TxF c) (MaybeT (EitherT (TxError c) IO)) Source

data TxF c x Source


UnitTx (Stmt c) x 
CountTx (Stmt c) (Word64 -> x) 
VectorTx (Stmt c) (Vector (ResultRow c) -> x) 
StreamTx Int (Stmt c) (ListT (Tx c) (ResultRow c) -> x) 


Functor (TxF c) 

unitTx :: Stmt c -> Tx c () Source

streamTx :: Int -> Stmt c -> Tx c (ListT (Tx c) (ResultRow c)) Source