hkust-taco/mlscript
47.5
Weak · 7 November 2026
51.9k
lines of production code
Scala
primary language
4
measurements over time
What this system is
Features
Add compiler utility infrastructure for REPL, diagnostics, and scoping
The compiler now includes new utility classes to support interactive execution and clearer error reporting. ReplHost enables the compiler to spawn and communicate with an interactive Node.js process, allowing code to be executed and results (including syntax and runtime errors) to be captured. ReportFormatter provides structured, colorized diagnostic output with box-drawing characters and source-line context for lexical, parsing, compilation, and type errors. Scope manages symbol bindings, name allocation, and 'this' proxy resolution for code generation, while SymbolSubst and DebugPrinter support symbol substitution and internal tree debugging. These utilities form the backend support for improved REPL interaction and diagnostic clarity.
hkmc2/shared/src/main/scala/hkmc2/utils · high confidence
Added syntax highlighting for MLScript in Vim
Vim users can now benefit from syntax highlighting for MLScript files. A new syntax file (\vim/mlscript.vim\) has been added, providing color-coded support for keywords, operators, strings, comments, and other language constructs, improving code readability within the editor.
vim · high confidence
Initial Wasm backend instruction generation
The Wasm code generation backend is now available, introducing the \Instructions.scala\ module which defines the foundational WebAssembly text-format instructions. This includes control flow constructs (block, loop, if, call, return, branch), exception handling (throw, unreachable), and a structured base for numeric operations across i32, i64, f32, and f64 types, enabling the compiler to emit valid Wasm code.
hkmc2/shared/src/main/scala/hkmc2/codegen/wasm · high confidence
Initial repository setup and project scaffolding
The repository is initialized with essential configuration and documentation files, including a LICENSE (MIT), CONTRIBUTING.md, AGENTS.md, and a detailed README.md describing the MLscript compiler versions. Build and development environment settings are added, such as .sbtopts for JVM memory tuning, .scalafmt.conf for code formatting, flake.nix/flake.lock for Nix-based development, and tsconfig.json for TypeScript support. The web demo is scaffolded with index.html, index.css, and local\_testing.html, and version control is configured with .gitattributes and an updated .gitignore.
(repo-wide) · high confidence
Introduce InvalML type inference and constraint solving
The \hkmc2/invalml\ module now includes the core components for a new type inference system: \InvalML.scala\ defines the typing context and entry points, \ConstraintSolver.scala\ handles type constraint generation and solving, \TypeSimplifier.scala\ reduces complex types, \TypeTraverser.scala\ provides polarity-aware type traversal, and \PrettyPrinter.scala\ aids in debugging by displaying inferred types and their bounds.
hkmc2/shared/src/main/scala/hkmc2/invalml · high confidence
Introduce async JavaScript interop and virtualized file system operations
The compiler now supports asynchronous JavaScript interop via a new \AsyncLowering\ pass that transforms \async\ functions into awaitable wrappers, gated by the \effectHandlers\ configuration option. Additionally, file system and path operations are now abstracted behind virtualized \FileSystem\ and \Path\ traits, allowing the compiler to decouple from the underlying platform I/O. Also in this area: 1 commit (0 fixes) modifying hkmc2/js, hkmc2/shared, repository; 4 commits (1 fix) modifying hkmc2/shared; 3 commits (0 fixes) modifying hkmc2/shared, repository.
hkmc2/shared/src/main/scala/hkmc2 · medium confidence · unverified
Introduce core utility library for the hkmc2 project
This change adds a new set of foundational utility classes and extensions to the \hkmc2/shared/src/main/scala/utils\ package. It introduces \EitherOrBoth\ for handling three-state values, \SccAnalysis\ for strongly connected components decomposition, and \TraceLogger\ for structured debug output. Additionally, it provides \FastParseHelpers\ for line/column tracking, \Lazy\ and \Identity\ wrappers, topological sorting algorithms, and a comprehensive set of implicit extension methods (shorthands) for standard Scala types like \Option\, \List\, \String\, and \Map\ to improve code conciseness.
hkmc2/shared/src/main/scala/utils · high confidence
Introduce document pretty-printing library
Added a new pretty-printing library in the \document\ package to help users generate formatted text output with automatic indentation and line-breaking. The library provides a \Document\ type for building structured text, a \DocBuilder\ for constructing documents programmatically, and a \doc\ string interpolation that allows mixing literal text with dynamic content using markers for nesting, grouping, and breaks. This enables cleaner and more maintainable code for generating formatted strings compared to manual string concatenation.
hkmc2/shared/src/main/scala/hkmc2/utils/document · high confidence
Introduce new Block IR codegen infrastructure and optimization pipeline
The codegen module now features a new Block IR with dedicated traversers and transformers (BlockTraverser, BlockTransformer) to enable structured compiler passes. A new CompilationPipeline orchestrates these passes, including LambdaRewriter, Deforest, Lifter, HandlerLowering, ClassParamFlattener, and DeadParamElim. This infrastructure supports advanced optimizations like dead parameter elimination, dead constructor elimination, and first-class function transformation, fundamentally changing how the compiler processes and optimizes code. Also in this area: 1 commit (0 fixes) modifying hkmc2/js, hkmc2/shared, repository; 4 commits (1 fix) modifying hkmc2/shared; 3 commits (0 fixes) modifying hkmc2/shared, repository.
hkmc2/shared/src/main/scala/hkmc2/codegen · medium confidence · unverified
JVM platform support for file system, path, and compiler cache operations
The JVM build now includes platform-specific implementations for file system access, path handling, and compiler caching. A new \JavaFileSystem\ wraps the \os-lib\ library to provide read, write, append, existence checks, and modification-time retrieval, while \WrappedPath\ and \WrappedRelPath\ adapt \os.Path\ and \os.RelPath\ to the compiler's internal \Path\ and \RelPath\ abstractions. Additionally, \PlatformCompilerCache\ initializes in-memory caches using \TrieMap\ to support the new compiler caching feature on the JVM. These changes are accompanied by tests verifying the cache's concurrent behavior, including deadlock prevention for circular imports and bounded substitution growth.
hkmc2/jvm · high confidence
New JavaScript Compiler entry point and path configuration
A new \Compiler.scala\ file has been added to the JS module, exposing a \Compiler\ class and a \Paths\ configuration class to the JavaScript environment via \@JSExportTopLevel\. The \Compiler\ class provides a \compile\ method that accepts a file path, runs the internal \MLsCompiler\, and returns structured diagnostic information (including message bits, locations, and severity) as a JavaScript array. The \Paths\ class allows external configuration of the prelude, runtime, runtime source, and term files required for compilation.
hkmc2/js/src/main/scala/hkmc2 · high confidence
New deforestation rewriting pass for fusion optimization
A new \DeforestRewriter\ class has been added to the compiler's deforestation module to implement a flow-based rewriting pass. This component analyzes constructor destruction and match expressions to fuse them, eliminating intermediate data structures by extracting branch and rest functions. This change introduces the core logic for deforestation mk4, allowing the compiler to optimize code by removing unnecessary allocations during the transformation phase.
hkmc2/shared/src/main/scala/hkmc2/codegen/deforest · high confidence
Removals
Removed legacy parser, syntax definitions, and type inference engine
The \Parser\, \Syntax\, \Typing\, and \package\ modules in \src/main/scala/simplesub\ have been deleted. This removes the previous implementation of the language's parser (using fastparse), the abstract syntax tree definitions (including both simple and polarity-aware type representations), and the mutable-state-based type inference engine. Users relying on this specific version of the simple-sub language's core analysis components will no longer have access to these files, indicating a structural shift in how the language is processed.
src/main · high confidence
Behavioural changes
29 commits (7 fixes) modifying hkmc2/shared/src/main/scala/hkmc2/codegen/deforest
A change to existing behaviour in hkmc2/shared/src/main/scala/hkmc2/codegen/deforest — 29 commits (7 fixs), 2 files. Also in this area: 1 commit (0 fixes) modifying hkmc2/js, hkmc2/shared, repository; 5 commits (1 fix) modifying repository; 3 commits (0 fixes) modifying hkmc2/shared, repository; New semantics implementation for resolution, inheritance, and interface exposure; Introduce Block IR and new optimization pipeline.
repository · low confidence · unverified
34 commits (0 fixes) modifying hkmc2/shared/src/main/scala/hkmc2/semantics/ucs
A change to existing behaviour in hkmc2/shared/src/main/scala/hkmc2/semantics/ucs — 34 commits, 3 files: “Patch to first-class function transformer (\#404)”; “Improve Tuple.get handling (\#513)”; “Eta Expansion (\#326)”; and 31 more (refs \#404, \#513, \#326, \#262, \#421, …).
hkmc2/shared/src/main/scala/hkmc2/semantics/ucs · medium confidence · unverified
36 commits (6 fixes) modifying hkmc2/shared/src/main/scala/hkmc2/semantics/ups
A change to existing behaviour in hkmc2/shared/src/main/scala/hkmc2/semantics/ups — 36 commits (6 fixs), 3 files: “Complete deferred constructor-pattern resolution and inheritance lookup”; “Preserve source identifiers through compiler rewrites”; “Make annotation, statement, parameter-list and IR locations explicit”; and 33 more (refs \#503, \#421, \#543, \#378, \#343, …).
hkmc2/shared/src/main/scala/hkmc2/semantics/ups · medium confidence · unverified
Introduce new lexer, parser, and keyword infrastructure for HKMC2
The HKMC2 language syntax has been restructured with a new lexer, parser, and keyword system. The lexer now supports Unicode escapes in string literals (both traditional \\uXXXX and code point \\u{XXXXXX} forms) and improved numeric literal parsing. The keyword system centralizes precedence and associativity rules for operators and keywords, enabling features like juxtaposition syntax, suspension syntax (...), and refined operator precedence (e.g., / and \* are now left-associative with equal precedence). The parser has been rewritten to support new language constructs including let/set bindings with in-clauses, if/else/then/do, case/as patterns, try/finally, and various new keywords such as mut, using, staged, and dynamic selection (x!a). This change also adds support for symbolic suffix aliases, member projection syntax (Cls::mem), and improved error reporting with precise location tracking.
hkmc2/shared/src/main/scala/hkmc2/syntax · high confidence
Introduces platform-specific compiler caching for elaboration and prelude artifacts
A new \PlatformCompilerCache\ class has been added to the \hkmc2.utils\ package to manage cached compiler artifacts. This component initializes specific caches for elaboration results (\Artifact\) and prelude data (\PreludeArtifact\), enabling the system to store and retrieve these intermediate compilation states to avoid redundant processing.
hkmc2/js/src/main/scala/hkmc2/utils · high confidence
New semantics implementation for resolution, inheritance, and interface exposure
The \hkmc2/semantics\ package has been replaced with a new implementation that introduces a \NewResolver\ for symbol resolution, \InterfaceExposure\ for checking public API boundaries, and \Inheritance\ for validating class extension and override rules. This change adds support for sealing classes to their compilation unit unless marked \open\ or \abstract\, enforces strict rules on overriding non-open members, and tracks import provenance to ensure that imported definitions are correctly resolved and exposed. The new system also includes a \BlockImpl\ for desugaring block statements and a \SimpleSplit\ structure for handling pattern matching and control flow, providing a more robust foundation for the compiler's semantic analysis. Also in this area: 1 commit (0 fixes) modifying hkmc2/js, hkmc2/shared, repository; 4 commits (1 fix) modifying hkmc2/shared; 3 commits (0 fixes) modifying hkmc2/shared, repository.
hkmc2/shared/src/main/scala/hkmc2/semantics · medium confidence · unverified
Virtualized file system and path handling for JavaScript environments
The JavaScript compiler runtime now uses a virtualized abstraction for file system and path operations, replacing direct Node.js dependencies with platform-specific implementations. A new \InMemoryFileSystem\ provides a pure in-memory store for the web compiler and testing, while \VirtualPath\ and \VirtualRelPath\ offer a pure JavaScript path normalization engine that correctly resolves \.\ and \..\ segments to ensure consistent cache keys. The \PlatformFileSystem\ object now delegates to a \NodeFileSystem\ implementation (backed by new Scala.js facades for Node's \fs\ and \path\ modules) for native Node.js environments, ensuring that path identity and normalization behave consistently across both web and Node targets.
hkmc2/js/src/main/scala/hkmc2/io · high confidence
Web demo now displays typing and execution results with improved error reporting
The JavaScript file in the bin directory has been updated to enhance the web demo's output capabilities. Users will now see structured 'Typing Results' and 'Execution Results' sections in the UI, replacing the previous generic output. The demo also features improved error handling, specifically ensuring that unresolved symbols are not reported as errors (as noted in commit \#141), and provides clearer visual feedback for runtime errors and warnings using styled HTML output.
bin · high confidence
Test coverage
1 commit adding/updating tests in (repo-wide); 1 commit adding/updating tests in hkmc2SlopTests; 101 commits adding/updating tests in hkmc2/shared/src/test/mlscript/decls; 18 commits adding/updating tests in hkmc2/shared/src/test/mlscript/ups/fixpoint; 19 commits adding/updating tests in hkmc2/shared/src/test/mlscript-compile/apps; 19 commits adding/updating tests in hkmc2/shared/src/test/mlscript/ups/parametric; 28 commits adding/updating tests in hkmc2/shared/src/test/mlscript/apps; 3 commits adding/updating tests in hkmc2/shared/src/test/mlscript/examples; 31 commits adding/updating tests in hkmc2/shared/src/test/mlscript/ups/examples; 32 commits adding/updating tests in hkmc2/shared/src/test/mlscript/ups/syntax; 36 commits adding/updating tests in hkmc2/shared/src/test/mlscript/slop; 44 commits adding/updating tests in hkmc2/shared/src/test/mlscript/invalml; 46 commits adding/updating tests in hkmc2/shared/src/test/mlscript/syntax/annotations; 48 commits adding/updating tests in hkmc2/shared/src/test/mlscript/meta; 6 commits adding/updating tests in hkmc2/shared/src/test/mlscript-compile/wasm; Add nofib benchmark test suite for mlscript-compile; Added C++ test infrastructure for MLScript compilation; Added JavaScript test utilities and test class; Added MLscript compile test infrastructure and standard library modules; Added WASM-specific test suite for the new resolution system; Added accounting test documentation and placeholder files; Added benchmark test infrastructure and file watcher; Added benchmark tests for FingerTrees, LazySpreads, and nofib suites; Added compiler integration tests; Added comprehensive codegen tests for MLscript; Added comprehensive diff-test suite for MLscript basics; Added comprehensive test coverage for the Unified Pattern System (UPS); Added comprehensive test suite for the mlscript parser; Added deforestation test suite; Added flow analysis test suite for the MLScript compiler; Added nofib benchmark tests to the MLscript test suite; Added parser tests for MLscript language constructs; Added parsing test suite with lexer, parser, and rule definitions; Added parsing web demo with interactive examples and syntax visualization; Added pattern compilation tests for mlscript 0.3.x; Added regex pattern test suite; Added staged-module compiler tests for block-staging; Added staging tests for UCS pattern matching and desugaring; Added standard library test coverage for MLscript data structures and utilities; Added syntax regression tests for MLscript parsing and compilation; Added syntax tests for UCS pattern matching and control flow; Added test cases for MLscript parser, codegen, and lifting limitations; Added test coverage for UCS operator split syntax; Added test coverage for contextual parameters and type class resolution; Added test coverage for newline-separated 'and' operators in conditional expressions; Added test runners for apps, nofib, and wasm compilation tests; Added test suite for MLscript optimizations; Added test suite for UCS language features; Added test suite for UCS normalization edge cases; Added test suite for Unified Case Syntax (UCS) pattern matching; Added test suite for dead parameter elimination; Added test suite for effect handlers; Added test suite for general UCS pattern matching and code generation; Added test suite for overloaded modules in signatures; Added test suite for tail-call optimization and annotations; Added test suite for the MLscript lifter; Added test suite for the MLscript lifter; Added test suites for pattern matching and transformation identity; Added tests for UCS syntax features and error handling; Added tests for VirtualPath normalization and InMemoryFileSystem path resolution; Added tests for eta-expansion in deforestation optimization; Added tests for parsing-web-demo examples; Added tests for pattern-matching hygiene and variable scoping; Added tests for recursive pattern matching in the MLScript compiler; Added tests for the Object Buffer feature; Initial Wasm backend test suite; New diff-test infrastructure and test suite for the hkmc2 compiler; New test suite for the new resolution engine; Removed legacy Scala test suite for parser and type inference.
Dependencies
78 commits updating dependencies (3 manifests)
A dependency / build maintenance change in (dependencies) — 78 commits (4 fixs), 3 files.
(dependencies) · medium confidence · unverified
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 44 → 47 (+3.8)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.
Lenses
- Code Health 49 → 49 (+0.2)
- Architecture 92 → 91 (-1.2)
- Maturity 43 → 64 (+21.3)
- Readiness 67 → 65 (-2.3)
- Security 99 → 98 (-0.7)
- Accessibility 33 → 33 (+0.0)
- Performance 67 → 75 (+8.0)
Resolved (43)
- Duplicated block (9 lines × 2) (hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala)
- Duplicated block (9 lines × 2) (hkmc2/shared/src/main/scala/hkmc2/semantics/ups/Compiler.scala)
- Erasure.definitionType (cognitive 23) (hkmc2/shared/src/main/scala/hkmc2/codegen/Erasure.scala)
- Erasure.definitionType (cyclomatic 19) (hkmc2/shared/src/main/scala/hkmc2/codegen/Erasure.scala)
- Erasure.run (cognitive 76) (hkmc2/shared/src/main/scala/hkmc2/codegen/Erasure.scala)
- Erasure.run (cyclomatic 51) (hkmc2/shared/src/main/scala/hkmc2/codegen/Erasure.scala)
- FirstClassFunctionTransformer.applyPath (cognitive 16) (hkmc2/shared/src/main/scala/hkmc2/codegen/FirstClassFunctionTransformer.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/invalml/InvalML.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/invalml/InvalML.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/invalml/InvalML.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/semantics/flow/FlowAnalysis.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/semantics/flow/FlowAnalysis.scala)
- NewResolver.appShape (cognitive 50) (hkmc2/shared/src/main/scala/hkmc2/semantics/NewResolver.scala)
- NewResolver.appShape (cyclomatic 31) (hkmc2/shared/src/main/scala/hkmc2/semantics/NewResolver.scala)
- NewResolver.zipArgumentShapes (cognitive 32) (hkmc2/shared/src/main/scala/hkmc2/semantics/NewResolver.scala)
- NewResolver.zipArgumentShapes (cyclomatic 18) (hkmc2/shared/src/main/scala/hkmc2/semantics/NewResolver.scala)
- Off-boarding risk: anonymized user #1
- …and 23 more
New (58)
- AccessPath.findAccessPath (cognitive 19) (hkmc2/shared/src/main/scala/hkmc2/semantics/AccessPath.scala)
- BlockTransformer.applyResult (cognitive 18) (hkmc2/shared/src/main/scala/hkmc2/codegen/BlockTransformer.scala)
- BuiltinOperatorResults.apply (cyclomatic 22) (hkmc2/shared/src/main/scala/hkmc2/semantics/BuiltinOperatorResults.scala)
- Cloner.term (cyclomatic 61) (hkmc2/shared/src/main/scala/hkmc2/semantics/Cloner.scala)
- Dependency hygiene PARTLY measured — sbt declarations read, dependency currency not (Maven Central unreachable)
- Duplicated block (11 lines × 2) (hkmc2/shared/src/main/scala/hkmc2/codegen/UsedVarAnalyzer.scala)
- Duplicated block (9 lines × 2) (hkmc2/shared/src/main/scala/hkmc2/semantics/ups/Compiler.scala)
- Elaborator.param (cognitive 22) (hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala)
- Elaborator.params (cyclomatic 24) (hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala)
- Erasure.erasedDefinitionSignature (cognitive 26) (hkmc2/shared/src/main/scala/hkmc2/codegen/Erasure.scala)
- Erasure.erasedDefinitionSignature (cyclomatic 21) (hkmc2/shared/src/main/scala/hkmc2/codegen/Erasure.scala)
- FileTooLong: semantics/Cloner.scala (hkmc2/shared/src/main/scala/hkmc2/semantics/Cloner.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/codegen/flowAnalysis/FlowAnalysis.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/invalml/InvalML.scala)
- FixmeComment (hkmc2/shared/src/main/scala/hkmc2/invalml/InvalML.scala)
- Further sole-owners (lower concentration)
- Helpers.matchArgs (cognitive 18) (hkmc2/shared/src/main/scala/hkmc2/codegen/BlockSimplifier.scala)
- Hotspot: hkmc2/shared/src/main/scala/hkmc2/codegen/BlockTransformer.scala (hkmc2/shared/src/main/scala/hkmc2/codegen/BlockTransformer.scala)
- Hotspot: hkmc2/shared/src/main/scala/hkmc2/codegen/BlockTraverser.scala (hkmc2/shared/src/main/scala/hkmc2/codegen/BlockTraverser.scala)
- Hotspot: hkmc2/shared/src/main/scala/hkmc2/codegen/ErasedType.scala (hkmc2/shared/src/main/scala/hkmc2/codegen/ErasedType.scala)
- …and 38 more
Changes since last survey
- 83 commits — 71 feature/other, 12 fixes
By area
- hkmc2/shared — 68 commits
- (root) — 7 commits
- (repo) — 3 commits
- hkmc2/jvm — 3 commits
- doc/reference.md — 1 commit
- hkmc2/js — 1 commit
Notable commits
- fix: Deduplicate and consolidate parameter regression tests
- fix: Fix binary operator trees in the parser example (#594)
- fix: Fix grouped annotation targets and compiled pattern aliases (#604)
- fix: Fix interaction between if and curly-brace blocks (#584)
- fix: Fix iterable interfaces and align subclass parameter lists
- fix: Fix list termination in the fish benchmark formatter (#596)
- fix: Fix trailing-input error trees in the parser example (#595)
- fix: Isolate AI-authored regression tests in the slop suite
- fix: Split Cast nodes into path and result forms; make various related fixes (#614)
- fix: fix: avoid retaining lowering frames across statement sequences (#589)
- fix: fix: preserve outer receivers in module inlining and JS codegen (#588)
- fix: fix: preserve parameter assignments when lowering async functions (#587)
- change: Add slop tests to qtest (hkmc2MainTests) command; update AGENTS.md
- change: Avoid nullable type-view multiplication and clarify empty interfaces (#608)
- change: Avoid resolving ignored constructor fields
- change: Bind omitted optional arguments to null in shared IR
- change: Bump nix flake and update to JDK 25 (#613)
- change: Correct library and fixture declarations (#597)
- change: Derive identifiers of compiler-generated selections from their symbols (#611)
- change: Document resolution more
- …and 63 more
Architecture
- Unchanged — 0 containers · 1 contexts · 0 edges
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
hkust-taco/mlscript 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 7 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit bae948bd5896748e7fde850785d9fdefd585c925 — the exact code this score is about.
- Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.3+preprod-5f8314471808.