haskelldb-2.2.4: A library of combinators for generating and executing SQL statements.

Copyright | Anders Hockersten (c), chucky@dtek.chalmers.se
License | BSD-style
Maintainer | chucky@dtek.chalmers.se
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Database.HaskellDB.DriverAPI

Description

This exports an API that all drivers must conform to. It is used by the end user to load drivers either dynamically or statically.

Synopsis

- data DriverInterface = DriverInterface {
  - connect :: forall m a. MonadIO m => [(String, String)] -> (Database -> m a) -> m a
  - requiredOptions :: [(String, String)]
  }
- class Monad m => MonadIO m
- defaultdriver :: DriverInterface
- getOptions :: Monad m => [String] -> [(String, String)] -> m [String]
- getAnnotatedOptions :: Monad m => [(String, String)] -> [(String, String)] -> m [String]
- getGenerator :: Monad m => [(String, String)] -> m SqlGenerator

# Documentation

data DriverInterface Source

Interface which drivers should implement. The `connect` function takes some driver specific name, value pairs use to setup the database connection, and a database action to run. `requiredOptions` lists all required options with a short description, that is printed as help in the DBDirect program.

Constructors

DriverInterface |

Fields

connect :: forall m a. MonadIO m => [(String, String)] -> (Database -> m a) -> m a
requiredOptions :: [(String, String)]

class Monad m => MonadIO m

Monads in which `IO` computations may be embedded. Any monad built by applying a sequence of monad transformers to the `IO` monad will be an instance of this class.

Instances should satisfy the following laws, which state that `liftIO` is a transformer of monads:

-     liftIO . return = return

-     liftIO (m >>= f) = liftIO m >>= (liftIO . f)

Minimal complete definition

liftIO

Instances

MonadIO IO |
(Error e, MonadIO m) => MonadIO (ErrorT e m) |

defaultdriver :: DriverInterface Source

Default dummy driver, real drivers should overload this

getOptions Source

Arguments

:: Monad m |
=> [String] | names of options to get
-> [(String, String)] | options given
-> m [String] | a list of the same length as the first argument with the values of each option. Fails in the given monad if any options is not found.

Can be used by drivers to get option values from the given list of name, value pairs.

getAnnotatedOptions Source

Arguments

:: Monad m |
=> [(String, String)] | names and descriptions of options to get
-> [(String, String)] | options given
-> m [String] | a list of the same length as the first argument with the values of each option. Fails in the given monad if any options is not found.

Can be used by drivers to get option values from the given list of name, value pairs. It is intended for use with the `requiredOptions` value of the driver.

getGenerator Source

Arguments

:: Monad m |
=> [(String, String)] | options given
-> m SqlGenerator | An SQL generator. If there was no "generator" option, the default is used. Fails if the generator is unknown

Gets an `SqlGenerator` from the "generator" option in the given list. Currently available generators: "mysql", "postgresql", "sqlite", "default"