persistent-discover: Persistent module discover utilities

[ bsd3, library, program, web ] [ Propose Tags ]

This package provides an executable for discovering Persistent model definition files, as well as a library function to glob all persistent model files. Please see the README on GitHub at

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,,,,,
Change log
Dependencies base (>=4.12 && <5), directory, discover-instances, dlist, file-embed, filepath, mtl, persistent (>=, persistent-discover, some-dict-of, template-haskell (>=, text [details]
License BSD-3-Clause
Copyright Matt Parsons
Author Matt Parsons
Category Web
Home page
Bug tracker
Source repo head: git clone
Uploaded by parsonsmatt at 2023-10-04T00:30:24Z
Distributions LTSHaskell:, NixOS:, Stackage:
Executables persistent-discover
Downloads 1010 total (20 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-10-04 [all 1 reports]

Readme for persistent-discover-

[back to package description]


build status

Supports automatic discovery of your persistent models.

As an executable

Let's say you've got a ton of persistent database models, all defined in a module hierarchy like this:


If you're using persistent to automatically generate migrations, you'll want to have all the [EntityDef] in scope from each module. You can do that by importing each module that defines models and calling $(discoverEntities), introduced in persistent-2.13.

But you may forget to import a module.

This utility imports all the modules defined in the current directory and sub-directories, and then it calls $(discoverEntities) for you.

To use it, place the following command in a file, located in the same directory that your Haskell modules are in:

{-# OPTIONS_GHC -F -pgmF persistent-discover #-}

Let's say we put that in src/Models/All.hs. This generates a module Models.All that exports a single item: allEntities, which is a [EntityDef] and can be used by migrateModels to properly perform migrations.

You'll need to add persistent-discover to the build-tool-depends on your cabal file for this to work.