CMU-CS-25-134
Computer Science Department
School of Computer Science, Carnegie Mellon University



CMU-CS-25-134

Typed Closure Conversion with Sum Types for
Analyzing Higher-Order Functions in Resource Aware ML

Lauren Sands

M.S. Thesis

August 2025

CMU-CS-25-134.pdf


Keywords: Higher-Order Functions, Static Analysis, Logical Relations, Closure Conversion, Resource Aware ML

Resource Aware ML (RaML) is a tool that statically infers resource bounds for OCaml programs. However, RaML cannot derive bounds for functions whose cost depends on values that are not arguments. Partially-applied higher-order functions, which are common in OCaml code, often cannot be analyzed for this reason. This thesis introduces a closure conversion transformation that rewrites higher-order programs into ones analyzable by RaML. Unlike traditional closure conversion which wraps functions with environments represented using existential types, this algorithm uses sum types, which allows RaML to access internal types and infer bounds. The transformation is well-typed and preserves semantics and cost, ensuring that analysis of the transformed program remains sound with respect to the original code.

56 pages

Thesis Committee:
Jan Hoffmann (Chair)
Stephanie Balzer

Srinivasan Seshan, Head, Computer Science Department
Martial Hebert, Dean, School of Computer Science


Return to: SCS Technical Report Collection
School of Computer Science

This page maintained by reports@cs.cmu.edu