Skip to main content

Crate unitype_core

Crate unitype_core 

Source
Expand description

The symbolic core of unitype: a language-neutral representation of types, the values that inhabit them, and the propositions that relate them.

§The idea

A function signature is a proposition; an implementation of it is a proof. There can be many proofs of one proposition — in different languages, with different costs — and choosing among them at call time is what makes data and computation portable between systems. This crate holds the half of that idea which is pure: the representation, its canonical form, its identity, and the rules that decide what is well-typed. Running proofs lives in unitype-runtime; writing them out in a target language lives in unitype-codegen.

§Canonical form and identity

Every type has exactly one canonical serialization, and a type’s identity is the hash of those bytes. Two systems that have never met agree on whether they hold the same type by comparing 32 bytes, with no shared registry and no coordination. Names, documentation, and annotations are excluded from that hash, because they are not what makes a type what it is.

§Everything is a literal

Types, declarations, values, and expressions all serialize to plain JSON, so the representation is also the wire format and the authoring format. A type read out of one system can be written into another without a schema compiler in between.

Re-exports§

pub use canon::TypeId;
pub use canon::canonical_string;
pub use canon::decl_hash;
pub use canon::full_alias;
pub use canon::local_hash;
pub use canon::sig_hash;
pub use ident::Ident;
pub use ident::IdentError;
pub use ident::QualifiedName;
pub use ir::Expr;
pub use ir::Field;
pub use ir::FunctionSig;
pub use ir::LiteralValue;
pub use ir::LoadError;
pub use ir::SCHEMA_VERSION;
pub use ir::Type;
pub use ir::TypeDef;
pub use ir::TypeRef;
pub use ir::Universe;
pub use ir::Workspace;
pub use lang::LANGUAGES;
pub use lang::LanguageProfile;
pub use link::LinkKind;
pub use meta::BigO;
pub use meta::ImplProfile;
pub use meta::Metadata;
pub use value::Value;

Modules§

canon
Canonical form and content addressing.
check
Checking a workspace, and what you get once it passes.
ident
Validated identifiers and universe-qualified names.
ir
The symbolic representation: types, declarations, expressions, universes, and the workspaces that hold them.
lang
What each target language calls things.
link
Links: declared correspondences that let data cross between universes.
meta
Vocabulary shared with the runtime and codegen crates: free-form metadata and the complexity classes that distinguish one proof of a proposition from another.
reflect
The system, described in its own terms.
value
Values: the data that types describe.