pubgrub: The PubGrub version solver

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

PubGrub is a version-solving algorithm: unit propagation with conflict-driven learning, and, when there is no solution, a proof of why that can be written out for a person to read.

This is a Haskell implementation that is generic over the domain. A type class says what the variables, values, sets of values and facts are; a callback answers the solver's questions one variable at a time; and the explanation of a failure is worded by the domain.

Start with the tutorial in PubGrub.Tutorial. PubGrub.Cookbook has how-to guides, and PubGrub explains the model and re-exports what a user normally needs. The domain of Haskell packages is the pubgrub-cabal package.


[Skip to Readme]

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.20 && <4.23), co-log-core (>=0.3.2 && <0.4), containers (>=0.7 && <0.9), text (>=2.1 && <2.2) [details]
Tested with ghc ==9.10.3 || ==9.12.2 || ==9.14.1
License BSD-3-Clause
Copyright (c) 2026 Tweag I/O by Modus Create
Author Andrea Bedini
Maintainer andrea.bedini@moduscreate.com
Uploaded by andreabedini at 2026-11-09T05:06:14Z
Category Distribution
Home page https://github.com/tweag/pubgrub-hs
Bug tracker https://github.com/tweag/pubgrub-hs/issues
Source repo head: git clone https://github.com/tweag/pubgrub-hs.git(pubgrub)
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for pubgrub-0.1.0.0

[back to package description]

pubgrub

PubGrub is a version-solving algorithm. Given a request and a way to read what each version of each package needs, it finds a version for every package the request needs, or proves that there is none, and the proof can be written out for a person to read:

1. Because lib 1 depends on util 1 and util has no version 1, lib 1 is forbidden.

Because util has no version 2 and lib 2 depends on util 2, lib 2 is forbidden.
And because lib 1 is forbidden (1), lib 1 or 2 is forbidden.
So, because app 1 depends on lib 1 or 2 and app 1 is requested, version solving failed.

This package implements it in Haskell, once, for any domain: the things being solved for need not be packages, and their values need not be versions. You describe the domain with a type class, answer the solver's questions with a callback, and choose the words its explanations use.

Using it

Add pubgrub to your package's build-depends, and import PubGrub.

Documentation

The documentation is in the package's modules:

  • PubGrub.Tutorial — start here. It builds a small domain, solves in it, breaks it, and explains the failure. The proof above is its output.
  • PubGrub.Cookbook — how-to guides: versions and ranges, requests and constraints, a provider over an index of releases, merging facts that say the same thing, explanations in your own words, watching the search, releasing a lock.
  • PubGrub — how the solver sees a problem, and the reference for everything the library exports.

The domain of Haskell packages, over Cabal's package descriptions, is the pubgrub-cabal package.