Skip to content

Toy project to demo implementing addition and multiplication in TypeScript's type space.

Notifications You must be signed in to change notification settings

lebashdev/typescript-church-numerals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Overview

In TypeScript there are two spaces: the value space in which runtime computation and evaluation is performed, and the type space, where compile-time analysis is done. The code space contains the code we ship, while the type space only exists in our IDE.

The goal of the code in type-space.ts is to replicate the logic from value-space.ts, but only with types. That code can only be evaluated at compile-time, or when the static analyzer performs type inference. It has no purpose other than demonstrating that TypeScript's type system can represent simple computations.

It relies on Church Encoding to represent any positive integer, and some advanced type expressions to simulate recursive functions that take types as parameters, instead of actual values.

About

Toy project to demo implementing addition and multiplication in TypeScript's type space.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published