@hackage valiant-fused-effects0.1.0.0

Fused-effects adapter for valiant

  • Installation

  • Tested Compilers

  • Dependencies (4)

  • Dependents (0)

  • Package Flags

      werror
       (off by default)

      Enable -Werror for development builds.

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.