Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


Implementations of various type systems in OCaml.

Subscribe to updates I use type-systems

Statistics on type-systems

Number of watchers on Github 1305
Number of open issues 9
Main language OCaml
Average time to merge a PR less than a minute
Open pull requests 0+
Closed pull requests 0+
Last commit over 6 years ago
Repo Created over 6 years ago
Repo Last Updated 3 months ago
Size 451 KB
Organization / Authortomprimozic
Page Updated
Do you use type-systems? Leave a review!
View open issues (9)
View type-systems activity
View on github
Book a Mock Interview With Me (Silicon Valley Engineering Leader, 100s of interviews conducted)
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating type-systems for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Grow Your Own Type System

This repository contains implementations of different type systems in OCaml.

It is meant to help out anyone who wants to learn more about advanced type systems and type inference or experiment by extending or implementing their own. The implementations are minimal and contain code that is (hopefully) simple and clear.

  • algorithm_w contains one of the most basic yet efficient implementation of Damas-Hindley-Milner type inference algorithm (used in functional languages such as OCaml, Haskell and Elm) called Algorithm W. Uses references to simulate type substitutions and assigns ranks/levels to type variables to simplify let-generalization.

  • extensible_rows extends algorithm_w with type inference for extensible records/rows with scoped labels, based on Daan Leijen's excellent paper. Although this is just one way of implementing extensible records, it's extremly simple and surprisingly useful, and was incorporated into the programming language Elm.

  • extensible_rows2 is an optimized implementation of extensible_rows.

  • first_class_polymorphism extends algorithm_w with type checking and partial type inference for first-class and higher-rank polymorphism, based on another one of Daan Leijen's papers. This system requires slightly more type annotations than other attempts at type inference for first-class polymorphism, such as MLF, but is considerably simpler to implements and use.

  • gradual_typing is another simple extension of algorithm_w based on a paper by Jeremy G. Siek and Manish Vachharajani. Gradual typing combines the benefits of static and dynamic typing, allowing programmers to make dynamic programs safer by adding static type information, and make static programs more flexible by delaying type-checking until runtime when necessary.

  • refined_types is an experiment that extends the HM type system with dependent types in the form of function contracts. It uses an external automatic theorem prover to verify that function contracts are satisfied, to prevent many of the most common software errors, such as division by zero and out-of-bounds array access.

type-systems open issues Ask a question     (View All Issues)
  • about 4 years Type system zoo?
  • about 6 years System FC
  • over 6 years First class polymorphism + refined types?
type-systems questions on Stackoverflow (View All Questions)
  • Software engineering benefits of type systems used in functional languages
  • What are the differences and similarities of Scala and Haskell type systems?
  • What makes Haskell's type system more "powerful" than other languages' type systems?
  • Type systems of functional object-oriented languages
  • How is the syntax of type systems read?
  • What are the limits of type checking and type systems?
  • What is a "kind" in the context of Type Systems?
  • How should I handle strong name issues associated with plugin type systems in .Net
  • Intense study of Type Systems / Type Theory
  • Tax implementations in stock management type systems
  • Comparing design by contract to type systems
  • need explanation on type-systems
  • Basic Concepts of Language Type Systems
  • What type systems can prevent goal suspension in logical languages?
  • Functional Programming and Type Systems
  • Can good type systems distinguish between matrices in different bases?
  • Best way to resolve a DNS TXT record on Linux/Unix/Posix/BSD type systems?
  • Is my understanding of type systems correct?
  • Good information about type systems based on contracts/constraints?
type-systems list of languages used
Other projects in OCaml
Powered by Autocode - Instant Webhooks, Scripts and APIs
Autocode logo wordmark