Skip to content
CAI
Software that uses CAICheck a score

7sharp9/write-you-an-inference-in-fsharp

46.4

Weak · 17 September 2026

2.2k

lines of production code

F#

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is a collection of experimental F\# implementations of the Hindley-Milner type inference algorithm, designed to explore various type system extensions and implementation strategies. It provides distinct modules for basic, pure, and mutable inference engines, along with specialized variants supporting row polymorphism, arbitrary-rank polymorphism, and split constraint solving. Each component includes core type system definitions, unification logic, and benchmarking utilities to validate correctness and measure performance.

Features

Initial implementation of mutable Hindley-Milner type inference

Added a new HMMutable module providing a mutable Hindley-Milner type inference engine for a functional expression language. The implementation introduces mutable type variables (tvar) to track unification state, supporting features like let-polymorphism through generalization and instantiation. It includes core type system components such as expression and type representations, an environment for variable binding, and algorithms for unification with occurs-check adjustment. A sample Program.fs demonstrates the inference on various lambda-calculus expressions and includes a benchmarking loop to measure performance.

HMMutable · high confidence

Initial implementation of pure HM with row polymorphism

This change introduces a new module, HMPure-Rowpolymorphism, which provides a pure implementation of Hindley-Milner type inference extended with row polymorphism. The code defines the core type system structures (expressions, types, schemes, and environments) and implements the type inference algorithm, including unification and row extension/restriction logic. A test bank is included to validate the inference against various record and function expressions, and the entry point runs these tests while measuring performance.

HMPure-Rowpolymorphism · high confidence

Introduce HMPure module for pure type inference

Added the HMPure module, which implements a pure type inference engine for a simple lambda calculus with integers, booleans, and conditionals. This includes the core type system definitions (expressions, types, schemes, environments, and substitutions) and the Hindley-Milner type inference algorithm (generalization, instantiation, and unification). A Program.fs entry point was added to run a test bank of expressions and benchmark the inference performance, relying on the ExtCore and FSharp.Core libraries.

HMPure · high confidence

Introduce Hindley-Milner type checking for basic expressions

Adds a new HMBasic module implementing the Hindley-Milner polymorphic type-checking algorithm based on Cardelli's paper. This feature enables the inference of types for expressions involving identifiers, lambda abstractions, applications, and let/letrec bindings. The implementation includes core type system components such as type variables, type operators, environment management, and unification, along with a demonstration program that runs a test bank of expressions to verify type inference and performance.

HMBasic · high confidence

Introduce arbitrary-rank type inference engine

Adds a new HMRankN module implementing Hindley-Milner type inference extended to support arbitrary-rank polymorphism, allowing forall quantifiers to appear at any negative position in types (e.g., rank-2 and rank-3). The implementation follows the Peyton Jones & Shields (2007) algorithm, introducing bidirectional type checking, subsumption-based call-site checking, and skolemisation with escape checks to ensure type safety. A demo Program.fs validates the engine with standard rank-1 examples, rank-2 functions accepting polymorphic arguments, and rank-3 nested polymorphism, while also demonstrating expected failures for monomorphic functions passed where polymorphic ones are required.

HMRankN · high confidence

Introduce mutable HM with row polymorphism type inference

Added a new implementation of a mutable Hindley-Milner type inference engine supporting row polymorphism, including record selection, extension, and restriction. The module defines the core expression and type ASTs, along with unification, generalization, and environment handling logic. A demonstration program exercises this engine against a bank of test cases involving records and higher-order functions, measuring inference performance.

HMMutable-RowPolymorphism · high confidence

Introduce split Hindley-Milner type inference with constraint generation and solving

The HMSplitSolve module implements a type inference system that separates constraint generation from solving. It defines core type representations (TVar, TCon, TArr), expression syntax (including let, if, fix, and binary operations), and a type environment. The implementation includes functions for instantiating polymorphic types, generalizing types, and generating constraints via \constraintsExpr\. A solver component handles unification, including an occurs check to prevent infinite types, and applies substitutions to resolve constraints. The entry point demonstrates the inference process on a test bank of expressions, printing inferred types, generated constraints, and substitutions.

HMSplitSolve · high confidence

Dependencies

Add F\# project files and dependencies for Hindley-Milner type inference experiments

This change introduces a set of new F\# project files (inference.fsproj) for various Hindley-Milner (HM) type inference implementations, including basic, mutable, pure, row-polymorphism, split-solve, and rank-N variants. Most projects target .NET Core 3.0 (netcoreapp3.0), while the HMRankN project targets .NET 8.0 (net8.0). The project files reference F\# source files (e.g., HMBasic.fs, HMMutableRowPolymorphism.fs) and Program.fs. Additionally, a paket.dependencies file is added, specifying NuGet sources and dependencies on ExtCore (version 0.8.46) and FSharp.Core (version 4.3.4), with a corresponding paket.lock file generated.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 46.

Lenses

  • Code Health 91
  • Architecture 100
  • Maturity 50
  • Readiness 17
  • Security 100

Changes since last survey

  • 103 commits — 96 feature/other, 7 fixes

By area

  • (root) — 33 commits
  • HMRankN/HMRankN.fs — 20 commits
  • (repo) — 9 commits
  • HMSplitSolve/HMSplitSolve.fs — 9 commits
  • HMMutable/Program.fs — 4 commits
  • HMMutable-RowPolymorphism/inference.fsproj — 3 commits
  • HMSplitSolve/Program.fs — 3 commits
  • HMBasic/Program.fs — 2 commits
  • HMBasic/inference.fsproj — 2 commits
  • HMCombinedSolve/HMCombinedSolve.fs — 2 commits
  • HMRankN/Prelude.fs — 2 commits
  • .paket/paket.exe — 1 commit
  • HMBasic/HMBasic.fs — 1 commit
  • HMCombinedSolve/Program.fs — 1 commit
  • HMCombinedSolve/inference.fsproj — 1 commit
  • HMMutable-RowPolymorphism/HMMutableRowpolymorphism.fs — 1 commit
  • HMMutable-RowPolymorphism/Program.fs — 1 commit
  • HMMutable/HMMutable.fs — 1 commit
  • HMMutable/inference.fsproj — 1 commit
  • HMPure-Rowpolymorphism/HMPureRowpolymorphism.fs — 1 commit

Notable commits

  • fix: Add let anf fix bound functions to infer
  • fix: Fix allBinders to match spec and remove recursion
  • fix: Fix escape check and argument generalisation in rank-n inference
  • fix: Fix freeTyVars
  • fix: Fix project file
  • fix: Potential fix for pull request finding
  • fix: Potential fix for pull request finding
  • change: Add 7 basic inference tests
  • change: Add Combined solver skeleton
  • change: Add HM mutable skeleton
  • change: Add HM pure docs
  • change: Add WIP
  • change: Add a basic implementation of HM from ports based on cardelli paper
  • change: Add a little more progress:- zonk and quantify
  • change: Add a test bank
  • change: Add base test bank for combined inference
  • change: Add basic inference test and print inference and constraints
  • change: Add binop and if expressions
  • change: Add code location
  • change: Add code section
  • …and 83 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

7sharp9/write-you-an-inference-in-fsharp was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 17 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 0645a5d93e1705d127cc09374b78904928c89ffb — the exact code this score is about.
  • Scored under rubric-2026.09.13 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-d1ef6c0bd534.