Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lorenzoh/invariants.jl
Julia package for creating composable invariants with helpful error messages
https://github.com/lorenzoh/invariants.jl
julia
Last synced: 3 months ago
JSON representation
Julia package for creating composable invariants with helpful error messages
- Host: GitHub
- URL: https://github.com/lorenzoh/invariants.jl
- Owner: lorenzoh
- License: mit
- Created: 2022-02-23T06:02:02.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T21:11:40.000Z (almost 2 years ago)
- Last Synced: 2024-10-11T14:41:30.112Z (3 months ago)
- Topics: julia
- Language: Julia
- Homepage: https://lorenzoh.github.io/Invariants.jl/dev/documents/README.md
- Size: 1.16 MB
- Stars: 25
- Watchers: 4
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Invariants
[Documentation](https://lorenzoh.github.io/Invariants.jl/dev/documents/README.md)
A Julia package for writing invariants for
- providing helpful, detailed error messages to package users when they misuse the API
- creating interface test suites (as described [here](https://invenia.github.io/blog/2020/11/06/interfacetesting/))Designing the package, I focused on:
- reusability: invariants are easy to define and reuse, reducing boilerplate
- composability: invariants can be composed to create more complex invariants
- rich error messages: to be helpful, rich error messages should be easy to create## Example
```julia
using Invariants: check, invariant, mdinv = invariant("Is negative") do n
n < 0 ? nothing : md("`n` is not negative!")
endcheck(inv, 1)
check(inv, -1)
```