thentos-core-0.0.1.1: The swiss army knife of privacy-preserving identity management

Safe HaskellNone
LanguageHaskell2010

Thentos.Transaction.Core

Synopsis

Documentation

type ThentosQuery e a = EitherT (ThentosError e) (ReaderT Connection IO) a

data Defaultable a

Constructors

DefaultVal 
CustomVal a 

Instances

Eq a => Eq (Defaultable a) 
Ord a => Ord (Defaultable a) 
Read a => Read (Defaultable a) 
Show a => Show (Defaultable a) 
ToField a => ToField (Defaultable a) 

runThentosQuery :: Connection -> ThentosQuery e a -> IO (Either (ThentosError e) a)

Execute a ThentosQuery. Every query is a DB transaction, so the DB state won't change if there are any errors, nor will other queries encouter a possibly inconsistent interim state.

queryT :: (ToRow q, FromRow r) => Query -> q -> ThentosQuery e [r]

execT :: ToRow q => Query -> q -> ThentosQuery e Int64

createDB :: Connection -> IO ()

Creates the database schema if it does not already exist.

catchViolation :: MonadBaseControl IO m => (SqlError -> ConstraintViolation -> m a) -> m a -> m a

Like postgresql-simple's catchViolation, but generalized to MonadBaseControl IO m

catcher :: MonadBaseControl IO m => SqlError -> ConstraintViolation -> m (Either (ThentosError e) a)

Convert known SQL constraint errors to ThentosError, rethrowing unknown ones.

orDefault :: ToField a => Maybe a -> Defaultable a