Let Functions Speak: Lightweight Parametric Polymorphism via Domain and Range Types

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: He, Siyuan, Jia, Songlin, Rompf, Tiark
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911541776875520
author He, Siyuan
Jia, Songlin
Rompf, Tiark
author_facet He, Siyuan
Jia, Songlin
Rompf, Tiark
contents Dynamic languages such as Python and JavaScript widely use function decorators to extend behavior. In TypeScript, a common way to type such patterns uses Parameters<T> and ReturnType<T>. In practice, this idiom relies on a function-type bound for T that is expressed using the unsafe type any, which weakens static guarantees. At the core is a standard typing principle: application is justified only when the callee is exposed as an arrow type. We present F<:DR, a calculus that adds domain and range projection types, Dom(T) and Range(T), for arbitrary types T. These projections permit typing applications through abstract function types: an argument of type Dom(T) witnesses callability, and the result is typed as Range(T). This design complements, rather than replaces, standard arrow-based application, which remains admissible via subtyping in System F<:. We mechanize F<:DR in Rocq and prove semantic type soundness using logical relations with path selection, which delays projection interpretation until function structure is resolved. The same technique extends to additional projection types, illustrated for primitive pairs, i.e., product types.
format Preprint
id arxiv_https___arxiv_org_abs_2603_23360
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Let Functions Speak: Lightweight Parametric Polymorphism via Domain and Range Types
He, Siyuan
Jia, Songlin
Rompf, Tiark
Programming Languages
Dynamic languages such as Python and JavaScript widely use function decorators to extend behavior. In TypeScript, a common way to type such patterns uses Parameters<T> and ReturnType<T>. In practice, this idiom relies on a function-type bound for T that is expressed using the unsafe type any, which weakens static guarantees. At the core is a standard typing principle: application is justified only when the callee is exposed as an arrow type. We present F<:DR, a calculus that adds domain and range projection types, Dom(T) and Range(T), for arbitrary types T. These projections permit typing applications through abstract function types: an argument of type Dom(T) witnesses callability, and the result is typed as Range(T). This design complements, rather than replaces, standard arrow-based application, which remains admissible via subtyping in System F<:. We mechanize F<:DR in Rocq and prove semantic type soundness using logical relations with path selection, which delays projection interpretation until function structure is resolved. The same technique extends to additional projection types, illustrated for primitive pairs, i.e., product types.
title Let Functions Speak: Lightweight Parametric Polymorphism via Domain and Range Types
topic Programming Languages
url https://arxiv.org/abs/2603.23360