Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/konn/ghc-typelits-presburger
Presburger arithmetic solver for built-in type-level naturals
https://github.com/konn/ghc-typelits-presburger
compiler-plugin dependent-types ghc ghc-plugin haskell presburger-arithmetic-solver solver type-level-programming
Last synced: 11 days ago
JSON representation
Presburger arithmetic solver for built-in type-level naturals
- Host: GitHub
- URL: https://github.com/konn/ghc-typelits-presburger
- Owner: konn
- Created: 2016-05-22T09:53:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-26T15:17:16.000Z (11 months ago)
- Last Synced: 2024-05-01T22:44:01.495Z (6 months ago)
- Topics: compiler-plugin, dependent-types, ghc, ghc-plugin, haskell, presburger-arithmetic-solver, solver, type-level-programming
- Language: Haskell
- Size: 1.22 MB
- Stars: 6
- Watchers: 5
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# `ghc-typelits-presburger` and `singletons-presburger` -- GHC Plugin for sloving type-level natural constratins with Presburger Arithmetic solver [![Build Status](https://travis-ci.org/konn/ghc-typelits-presburger.svg?branch=master)](https://travis-ci.org/konn/ghc-typelits-presburger) [![Hackage](https://img.shields.io/hackage/v/ghc-typelits-presburger.svg)](https://hackage.haskell.org/package/ghc-typelits-presburger)
The packages in this monorepo augments type-level naturals in GHC with Presburger Arithmetic solver.
Roughly speaking, it automatically solves constraints expressed by addition, constant-factor multiplicatiojn, and (in)equalities at compile time.Since 0.3.0.0, integration with [`singletons`][singletons] package is separated to another plugin [`singletons-presburger`][singletons-presburger].
If you need to deal with `singletons` package, please use that instead.[singletons]: https://hackage.haskell.org/package/singletons
[singletons-presburger]: https://hackage.haskell.org/package/singletons## Usage
Add this package to your build-depends and add the following pragma on top of your program.```haskell
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Presburger #-}
```Since 0.5, one don't need to add `equational-reasoning` to dependency; but if you want to solve constraints involving symbols defined in `equational-reaoning`, such as `IsTrue` and `Empty`, one must explicitly depend on it, otherwise the solver can't handle constructor information.
## Note
This package includes the modified version of code from [`presburger` package](https://hackage.haskell.org/package/presburger) by yav, because yav's original package doesn't compile with GHC 8.4.