Skip to content

Latest commit

 

History

History
50 lines (43 loc) · 1 KB

README.md

File metadata and controls

50 lines (43 loc) · 1 KB

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.