Crate tylisp[][src]

Expand description

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.

Re-exports

pub use typenum;

Modules

engine
macros
marker_traits

Marker traits to ease integration with traditional Rust code

ops

Macros

calc
calc_bound
calc_ty
defmacro

Setup a new macro function, and some match arms for implementation

defun

Setup a new function, and some match arms for implementation

defun_nocalc
defun_rust
eval

Shorthand for resolving a lisp expression into its resultant type

literal

Define types as lisp literals, which evaluate to themselves

non_calc_literal
partial
sexpr

sexprs, the building blocks of everything Lisp

sexpr_pat

Build an sexpr type from expressions.

sexpr_pat_ty

Build an sexpr type from expressions.

sexpr_quoted_types
sexpr_quoted_vals

Internal macro to extract quoted expressions from an sexpr

sexpr_val

Build an sexpr type from expressions.

uuid_new_v4

Construct a new random UUID

Structs

ConstId
HCons
HNil
Quote

Traits

LispId
WithConstId