Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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, md

inv = invariant("Is negative") do n
n < 0 ? nothing : md("`n` is not negative!")
end

check(inv, 1)
check(inv, -1)
```