1.8.0
Version 1.8 (2024-09-09)
After a summer break, the team is happy to release Nickel 1.8!
This release ships with an important rework of the contract system, and in particular the interface of custom contracts. The new system is more intuitive for users implementing their own contracts, and makes it possible to use a limited form of boolean logic on contracts that have been added to the stdlib (std.contract.one_of
, std.contract.all_of
, std.contract.not
,
std.contract.check
).
We advise reading the updated manual section on writing custom contracts and to migrate your custom contracts to take advantage of the simplification of the interface and those new operators. Most custom contracts can likely be implemented as validators (see std.contract.from_validator
).
The contract system rework is backward compatible and existing custom contracts will continue to work as before. Though in the future, Nickel will probably emit a warning of deprecation when a custom contract is defined as a naked function instead of using one of the new contract constructors.
A limited form of subtyping has been added in 1.8 as well, making it easier to use records as dictionaries in statically typed code. A new paragraph has been added to the typing chapter of the manual accordingly.
Breaking changes
- Formatting: to better accommodate the new contract system, the formatting of
function applications and definitions have been changed. To avoid a large,
irrelevant diff on your next commits, we advise formatting your whole
codebase first after upgrading to 1.8 in a separate commit.
Core language
- Contract system rework:
- Do not evaluate types away by @yannham in #1954
- Add a contract node to the AST by @yannham in #1955
- Add dedicated node and constructor for general custom contracts by @yannham in #1964
- Introduce validators for building custom contracts by @yannham in #1970
- Split contracts into an immediate part and a delayed part by @yannham in #1975
- Re-introduce unified representation for custom contracts, migrate builtin contracts by @yannham in #1987
- Allow some function equality comparison by @yannham in #1978
- Dictionary subtyping:
- Add record/split_pair and record/disjoint_merge by @yannham in #1982
- Optimize
std.contract.Equal
using %record/split_pair% by @yannham in #1988 - [Optimization] Cache contract generation and pre-compile some match expression by @yannham in #2013
- Fix and improve contract generation optimization for static types by @yannham in #2017
Stdlib
- Comparisons for number, string, array, and record by @jeremyschlatter in #1985
- Add boolean contract combinators to the stdlib by @yannham in #1995
- Add short-circuiting fold_left by @jneem in #2000
- Add trigonometric functions, pi, e and log to the number module by @Hugal31 in #2006
Documentation
- Pass on the contract chapter of the manual by @yannham in #1999
- Adding documentation for subtyping by @Eckaos in #1990
LSP
- Combine metadata for completion items instead of choosing arbitrarily. by @jneem in #1940
- Don't blacklist files forever by @thufschmitt in #1973
- Make the LSP configurable by @thufschmitt in #1974
- More aggressive type/contract deduplication on hover by @jneem in #1984
Tooling
- Add span information for TOML imports by @yannham in #1949
- Update to latest topiary-queries (formatting) by @yannham in #2032
New Contributors
- @Eckaos made their first contribution in #1977
- @jeremyschlatter made their first contribution in #1986
- @Hugal31 made their first contribution in #2006
Full Changelog: 1.7.0...1.8.0