persistent-template: Type-safe, non-relational, multi-backend persistence.

[ database, library, mit, yesod ] [ Propose Tags ]

Hackage documentation generation is not reliable. For up to date documentation, please see:

[Skip to Readme]


Maintainer's Corner

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS] 0.5.0,, 0.5.1, 0.6.1, 0.6.2, 0.6.3,, 0.7.0, 0.8.0, 0.8.1,,, 0.8.2, 0.9.0,,, 1.0.0,,, 1.1.0, 1.1.1, 1.1.2,,,,,, 1.1.3,, 1.2.0,,,,,,, 1.3.0, 1.3.1,,,,,,, 2.0.0,,,, 2.0.1,, 2.0.2,,, 2.0.3,,, 2.0.4, 2.0.5, 2.0.7, 2.0.8, 2.1,, 2.1.1, 2.1.3,,,,,,,, 2.1.4, 2.1.5, 2.1.6, 2.1.7, 2.1.8,, 2.5, 2.5.1,,,,,,, 2.5.2, 2.5.3,, 2.5.4, 2.6.0, 2.7.0, 2.7.1, 2.7.2, 2.7.3, 2.7.4, 2.8.0,, 2.8.1, 2.8.2,,,,,, 2.9,, (info)
Change log
Dependencies base (>=4.10 && <5) [details]
License MIT
Author Michael Snoyman <>
Maintainer Michael Snoyman <>, Greg Weber <>
Category Database, Yesod
Home page
Bug tracker
Source repo head: git clone git://
Uploaded by parsonsmatt at 2021-03-30T13:46:52Z
Distributions Debian:, FreeBSD:, LTSHaskell:, NixOS:, Stackage:, openSUSE:
Downloads 147308 total (690 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2021-03-30 [all 3 reports]

Readme for persistent-template-

[back to package description]


This package was absorbed into persistent with the release.


Provides Template Haskell helpers for persistent. For more information, see the chapter in the Yesod book.

code organization

The TH.hs module contains code generators. persistent-template uses EntityDefs that it gets from the quasi-quoter. The quasi-quoter is in persistent Quasi.hs Similarly many of the types come from the persistent library

Development tips

To get a better idea of what code you're generating, you can output the content of Template Haskell expressions to a file:

stack test persistent-template --ghc-options='-ddump-splices -ddump-to-file'

The output will be in the .stack-work directory. The exact path will depend on your specific setup, but if you search for files ending in .dump-splices you'll find the output (find .stack-work -type f -name '*.dump-splices')

If you make changes to the generated code, it is highly recommended to compare the output with your changes to output from master (even better if this diff is included in your PR!). Seemingly small changes can have dramatic changes on the generated code.

For example, embedding an EntityDef in a function that was called for every field of that Entity made the number of generated lines O(N^2) for that function—very bad!