Skip to content

Instantly share code, notes, and snippets.

@Aras14HD
Aras14HD / README.md
Last active August 25, 2024 19:57
A Unified Typesystem: Partial, Variant, Borrowed Types and more

A Unified Typesystem: Partial, Variant, Borrowed Types and more

Recently I stumbled over the blog post The Inconceivable Types of Rust.

It stuck with me, the ideas were great, but felt unpolished, so I thought about it and I want to share those thoughts with you. In this post I aim to outline what these concepts are and their applications, what syntax I feel fits well, and broadly how one might design a type checker for this.

Partials

Let's start with partial types, these already kind of exist in Rust in, what Considerations on Codecrafting called it, a shadow type system. A partial types is the type of variable, that has been partially moved or initialized (or borrowed or variant). These are currently undescribable and only exist within functions, a way to write them could be: