We formalize a new type system for Elixir, a dynamically typed functional programming language of growing popularity that runs on the Erlang virtual machine. Our system combines gradual typing with semantic subtyping to enable precise, sound, and practical static type analysis, without requiring any changes to Elixir's compilation pipeline or runtime. Type soundness is ensured by leveraging runtime checks -- both implicit, from the Erlang VM, and explicit, via developer-written guards. Central to our approach are two key innovations: the notion of "strong functions", which can be assigned precise types even when applied to inputs that may fall outside their intended domain; and a fine-grained analysis of guards that enables accurate type refinement for case expressions and guarded function definitions. While type information is erased before execution and not used by the compiler, our "safe erasure" gradual typing strategy maintains soundness and expressiveness without compromising compatibility or performance. This work lays the theoretical foundation for Elixir's new type system, outlines its integration into recent versions of the language, and demonstrates its effectiveness on large-scale industrial codebases.


翻译:我们为 Elixir 形式化了一种新的类型系统,Elixir 是一种运行在 Erlang 虚拟机上的动态类型函数式编程语言,其流行度日益增长。本系统将渐进类型化与语义子类型化相结合,实现了精确、可靠且实用的静态类型分析,且无需对 Elixir 的编译管道或运行时进行任何修改。类型安全性通过利用运行时检查来保障——既包括来自 Erlang 虚拟机的隐式检查,也包括开发者编写的守卫所实现的显式检查。本方法的核心在于两项关键创新:“强函数”概念,即便在输入可能超出其预期域时,也能为其分配精确类型;以及一种细粒度的守卫分析,能够对 case 表达式和带守卫的函数定义实现精确的类型精化。尽管类型信息在执行前被擦除且编译器不加以利用,我们的“安全擦除”渐进类型化策略在维持兼容性与性能的同时,保障了类型系统的健全性和表达力。本工作为 Elixir 的新类型系统奠定了理论基础,概述了其与语言最新版本的集成,并在大规模工业代码库上验证了其有效性。

0
下载
关闭预览

相关内容

《攻击场景描述形式化模型研究》
专知会员服务
32+阅读 · 2025年8月15日
AgentOps综述:分类、挑战与未来方向
专知会员服务
40+阅读 · 2025年8月6日
大规模语言模型增强推荐系统:分类、趋势、应用与未来
专知会员服务
41+阅读 · 2024年12月22日
《基于分类方法的自动人机对话》
专知会员服务
27+阅读 · 2023年7月18日
浅析Faiss在推荐系统中的应用及原理
凡人机器学习
11+阅读 · 2020年5月5日
绝对干货!NLP预训练模型:从transformer到albert
新智元
14+阅读 · 2019年11月10日
变分自编码器VAE:一步到位的聚类方案
PaperWeekly
25+阅读 · 2018年9月18日
干货 :基于用户画像的聚类分析
数据分析
22+阅读 · 2018年5月17日
国家自然科学基金
2+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
印度精确打击与指挥架构的断层
专知会员服务
4+阅读 · 7月20日
美空军AI完成F-16战斗机自主空战历史性试飞
专知会员服务
5+阅读 · 7月20日
深入Project Maven:为何人工智能在战场上依然失灵
锻造未来士兵:外骨骼、基因工程与赛博格
专知会员服务
7+阅读 · 7月19日
《无人机蜂群通信技术研究》50页
专知会员服务
8+阅读 · 7月19日
相关基金
国家自然科学基金
2+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员