@hackage / valiant-fused-effects

Fused-effects adapter for valiant

Latest0.1.0.1

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-fused-effects

fused-effects adapter for valiant.

Provides a Valiant effect, a ValiantPoolC carrier (built on ReaderC Pool), and Has (Reader Pool) sig m-constrained smart constructors.

Quick start

import Control.Carrier.Lift (runM)
import Valiant (newPool, defaultPoolConfig, poolConnString)
import Valiant.FusedEffects

myApp :: (Has (Reader Pool) sig m, MonadIO m) => m [User]
myApp = do
  users <- fetchAllF listUsers ()
  pure users

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

What you get

  • Effect: data Valiant
  • Carrier: type ValiantPoolC m = ReaderC Pool m with runValiantPool :: Pool -> ValiantPoolC m a -> m a
  • Query operations: fetchOneF, fetchAllF, fetchScalarF, fetchOneOrThrowF, fetchExistsF
  • Command operations: executeF, executeReturningF, executeBatchF
  • Transactions: withTransactionF
  • Raw access: withConnectionF

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