module Database.Relational.Query.Monad.Trans.Config (
QueryConfig, queryConfig,
runQueryConfig, askQueryConfig
) where
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Reader (ReaderT, runReaderT, ask)
import Control.Applicative (Applicative)
import Database.Relational.Query.Component (Config)
newtype QueryConfig m a =
QueryConfig (ReaderT Config m a)
deriving (Monad, Functor, Applicative)
runQueryConfig :: QueryConfig m a -> Config -> m a
runQueryConfig (QueryConfig r) = runReaderT r
queryConfig :: Monad m => m a -> QueryConfig m a
queryConfig = QueryConfig . lift
askQueryConfig :: Monad m => QueryConfig m Config
askQueryConfig = QueryConfig ask