majjoha / typology

Playground for exploring type-level programming.

Home Page:https://github.com/majjoha/typology

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typology

CI

Typology is a playground for exploring type-level programming in TypeScript. The various types range from simple representations of natural numbers to types that can compute Fibonacci numbers.

Examples

Addition

const three: Add<Succ<Zero>, Succ<Succ<Zero>>> = {
  n: {
    n: {
      n: "zero"
    },
  },
}

Factorial

const six: Factorial<Three> = { n: { n: { n: { n: { n: { n: "zero" } } } } } }

Convert strings to numbers

const five: FromString<"{ n: { n: { n: { n: { n: zero } } } } }"> = {
  n: { n: { n: { n: { n: "zero" } } } },
}

Boolean logic

const two: IfElse<
  And<
    LessThan<Four, Six>,
    Not<GreaterThan<Five, Ten>>
  >,
  ToString<Succ<Succ<Zero>>>,
  never
> = "{ n: { n: zero } }"

Fibonacci numbers

const five: Fibonacci<Five> = { n: { n: { n: { n: { n: "zero" } } } } }

License

See LICENSE.

About

Playground for exploring type-level programming.

https://github.com/majjoha/typology

License:GNU General Public License v3.0


Languages

Language:TypeScript 98.9%Language:JavaScript 1.1%