tylisp 0.1.0

A domain-specific language for expressing complex type bounds
Documentation
  • Coverage
  • 20.25%
    32 out of 158 items documented0 out of 120 items with examples
  • Size
  • Source code size: 79.11 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 13.6 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 37s Average build duration of successful builds.
  • all releases: 37s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • e2-71828

TyLisp: a domain-specific language for type-system calculations

This crate is still experimental and likely to undergo significant changes. It is developed primarily to support the needs of memquery.

tylisp is a programming language embedded in Rust's macro and type systems. Its main purpose is to ease the burden of writing extremely-generic Rust code that comes from a proliferation of trait bounds. Because tylisp calculations occur entirely within the type system, any object that the used operations support will automatically be accepted.

tylisp has two distinct operating modes:

  • Eval mode will calculate a type, but doesn't provide any means to produce a value of that type. It's mostly used to convey extra context informtion that can help select one of several implementations.
  • Calc additionally provides a mechanism to apply the same actions to runtime values, which will produce a result value of the specified type. This allows us to define overloaded functions that have a return type dependent on argument types.

Semver Hazards

Writing code this way poses unique challenges to versioning. All of the Rust functions defined via tylisp expose their internal algorithm in the public API. Thus, any change to the internal workings of a function have the potential to break downstream code.

Best practice is to specify traditional trait bounds that constrain the input and output types, and manually verify that the tylisp code always satisfies these constraints.