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.


翻译:诸如Python和JavaScript等动态语言广泛使用函数装饰器来扩展行为。在TypeScript中,对此类模式进行类型标注的常见做法涉及 Parameters<T> 与 ReturnType<T>。实践中,这一惯用法依赖于一个用不安全类型 any 表达的函数类型约束 T,从而削弱了静态保证。其核心是一个标准类型化原则:仅当被调用者暴露为箭头类型时,应用才具有合法性。我们提出 F<:DR 演算,为任意类型 T 添加定义域(Dom(T))与值域(Range(T))投影类型。这些投影允许通过抽象函数类型对应用进行类型化:类型为 Dom(T) 的实参证明了可调用性,而结果则被类型化为 Range(T)。该设计并非替代而是在 System F<: 中通过子类型化保持标准箭头型应用的可容许性。我们在Rocq中对 F<:DR 进行机械化,并利用带路径选择的逻辑关系证明语义类型安全性——这种路径选择延迟了投影解释,直到函数结构被解析。相同技术可扩展至其他投影类型,例如针对原始对(即积类型)的投影。

0
下载
关闭预览

相关内容

【牛津大学博士论文】从多模态数据中学习表示,258页pdf
【CVPR2024】生成式多模态模型是优秀的类增量学习器
专知会员服务
32+阅读 · 2024年3月28日
使用多模态语言模型生成图像
专知会员服务
32+阅读 · 2023年8月23日
少即是多?非参数语言模型,68页ppt
专知会员服务
24+阅读 · 2020年11月22日
Attention模型方法综述 | 多篇经典论文解读
PaperWeekly
107+阅读 · 2018年6月11日
用PyTorch实现各种GANs(附论文和代码地址)
各种相似性度量及Python实现
机器学习算法与Python学习
11+阅读 · 2017年7月6日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
12+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 4月28日
VIP会员
最新内容
美空军新型反无人机部队初探
专知会员服务
1+阅读 · 今天5:45
《防空交战流程的概率建模研究》
专知会员服务
4+阅读 · 今天5:04
ICML 2026 教程 | 数值优化理论还重要吗?
专知会员服务
4+阅读 · 7月26日
ICM 2026 | 陶哲轩:人工智能时代的数学
专知会员服务
7+阅读 · 7月26日
《反无人机交战场景下的战斗归零研究》
专知会员服务
7+阅读 · 7月26日
博士论文 | 用代码结构感知方法推进代码大模型
相关基金
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
12+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员