valiant-plugin: Compile-time checked SQL for Haskell, GHC source plugin

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

GHC source plugin that validates queryFile calls at compile time by reading cached metadata from the .valiant/ directory.


[Skip to Readme]

Modules

  • Valiant
    • Valiant.Plugin
      • Valiant.Plugin.Cache
      • Valiant.Plugin.Config

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 aeson (>=2.1 && <2.3), base (>=4.17 && <5), bytestring (>=0.11 && <0.13), containers (>=0.6 && <0.8), cryptohash-sha256 (>=0.11 && <0.12), directory (>=1.3 && <1.4), edit-distance (>=0.2 && <0.3), filepath (>=1.4 && <1.6), ghc (>=9.6 && <9.12), text (>=2.0 && <2.2), time (>=1.12 && <1.15) [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:38:46Z
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(plugin)
Distributions
Downloads 3 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2026-04-28 [all 2 reports]

Readme for valiant-plugin-0.1.0.0

[back to package description]

valiant-plugin

GHC source plugin for valiant. Validates raw .sql files against a .valiant/ cache at compile time.

How it fits

The valiant workflow has three steps:

  1. Run valiant prepare against a live PostgreSQL database. The CLI reads each .sql file in your project, sends it to Postgres via PREPARE / DESCRIBE, and writes the parameter and result types into .valiant/.
  2. Add valiant-plugin to your project's ghc-options (typically via -fplugin=Valiant.Plugin). The plugin watches for queryFile calls in your Haskell source.
  3. At compile time, the plugin reads the cached metadata for each referenced .sql file and rewrites the call to a typed Statement value. Mismatches between the SQL types and the Haskell types you ask for become compile errors.

No Template Haskell. No code generation. Just metadata lookup at compile time.

Enabling the plugin

In your .cabal file:

ghc-options: -fplugin=Valiant.Plugin
build-depends:
  , valiant
  , valiant-plugin

In your Haskell source:

import Valiant

listUsers :: Statement () User
listUsers = queryFile "sql/list-users.sql"

The queryFile call becomes a typed Statement () User after the plugin runs, with the type checked against .valiant/list-users.sql.json.

Documentation

License

BSD-3-Clause. See LICENSE.