Skip to content

fusemc-dev/tau

Repository files navigation

Banner

Tau

Type-checking the everlasting flame at v0.1.1

Tau (τ) is a runtime type-validation library for GraalVM Polyglot values. It was primarily designed for Fuse's needs of seamless type-safe integration with JavaScript. Despite its origins, Tau is a general-purpose library and doesn't rely on Fuse in any way.

Getting Started

You'll surely find the artifacts to depend on here once Tau leaves its beta stage.

Templates

Note

Throughout this section, the /.../ circumfix syntax is used to denote Value literals. /42/ thus defines a Value of 42. You will shortly discover that the /.../ syntax isn't used coincidentally.

Type validation in Tau is done through Templates. A template may be thought of as a reusable, bidirectional type-schema, that is capable of describing itself.

A Template functions as a type-safe mapping from a Value to some type T, and vice versa. The former operation is referred to as lower, and the latter as raise. Both operations produce an Option which signals whether the conversion was successful.

Tip

Tau.lower()/Tau.raise() are convenient ways to assert that the respective operation was successful, throwing an absurdly pretty exception if it wasn't:

Tau.lower(Template.STRING, /"Marie"/);

A Template may be composed declaratively from primitives and factory methods found in the Template class.

Descriptions

Being written specifically for Fuse, Tau was developed with user-facing exceptiosn in mind. Hence, Tau includes an awfully over-engineered Description system.

A Description is a textual representation of a some type schema. Tau is capable of inferring a Description from multiple sources, as well as building one from a Template.

The source a Description was inferred from is called a Domain. When inferring a description, Tau annotates it with the domain it's coming from. The domain is visible in a description as a set of purple brackets.

snippet

About

GraalJS runtime type-validation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages