About

Metadata

  • Last updated , by joshburgess
  • License BSD-3-Clause
  • Categories Databases
  • Maintained by: joshburgess.webdev@gmail.com

  • Lottery factor: 1

Links

Installation

Tested Compilers

  1. 9.10.3

Package Flags

Use the -f option with cabal commands to enable flags

    werror (off by default)

    Enable -Werror for development builds.

Readme

valiant-effectful

Effectful adapter for valiant.

Provides a dynamic Valiant effect that any Eff action can request via Valiant :> es, plus a pool-based handler.

Quick start

import Effectful
import Valiant (newPool, defaultPoolConfig, poolConnString)
import Valiant.Effectful

myApp :: (Valiant :> es, IOE :> es) => Eff es [User]
myApp = do
  users <- fetchAllEff listUsers ()
  count <- fetchScalarEff countUsers ()
  liftIO $ putStrLn $ "got " <> show count <> " users"
  pure users

main :: IO ()
main = do
  pool <- newPool defaultPoolConfig { poolConnString = "postgres://..." }
  users <- runEff . runValiant pool $ myApp
  print users

What you get

  • Effect: data Valiant :: Effect
  • Handlers: runValiant pool and runValiantWith (custom handler, useful for tests)
  • Query operations: fetchOneEff, fetchAllEff, fetchScalarEff, fetchOneOrThrowEff, fetchExistsEff
  • Command operations: executeEff, executeReturningEff, executeBatchEff
  • Transactions: withTransactionEff, withTransactionLevelEff
  • Raw access: withConnectionEff

See the valiant tutorial for the underlying Statement and valiant prepare workflow.