valiant-effectful: Effectful adapter for valiant

[ bsd3, database, library ] [ Propose Tags ] [ Report a vulnerability ]

Provides an Valiant effect for the effectful effect system, enabling compile-time checked SQL queries as an effect with pool-based handlers.

import Valiant.Effectful

myApp :: (Valiant :> es, IOE :> es) => Eff es [User]
myApp = do
  users <- fetchAllEff listUsers ()
  forM_ users $ \u -> executeEff updateLastSeen (userId u)
  pure users

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

[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
werror

Enable -Werror for development builds.

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.17 && <5), effectful-core (>=2.3 && <2.6), pg-wire (>=0.1 && <0.2), valiant (>=0.1 && <0.2), vector (>=0.12 && <0.14) [details]
Tested with ghc ==9.10.3
License BSD-3-Clause
Author Josh Burgess
Maintainer joshburgess.webdev@gmail.com
Uploaded by joshburgess at 2026-04-27T22:39:04Z
Category Database
Home page https://github.com/joshburgess/valiant
Bug tracker https://github.com/joshburgess/valiant/issues
Source repo head: git clone https://github.com/joshburgess/valiant(adapters/valiant-effectful)
Distributions
Downloads 2 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-04-28 [all 1 reports]

Readme for valiant-effectful-0.1.0.0

[back to package description]

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.