Type-level computations for Ruby libraries
Type-level computations for Ruby libraries
复制标题
Ruby 库的类型级计算
DOI:
10.1145/3314221.3314630
复制
发表时间:
2019
期刊:
影响因子:
--
通讯作者:
Van Horn, David
中科院分区:
文献类型:
--
作者:
Kazerounian, Milod;Guria, Sankha Narayan;Vazou, Niki;Foster, Jeffrey S.;Van Horn, David
Many researchers have explored ways to bring static typing to dynamic languages. However, to date, such systems are not precise enough when types depend on values, which often arises when using certain Ruby libraries. For example, the type safety of a database query in Ruby on Rails depends on the table and column names used in the query. To address this issue, we introduce CompRDL, a type system for Ruby that allows library method type signatures to includetype-level computations(orcomp typesfor short). Combined with singleton types for table and column names, comp types let us give database query methods type signatures that compute a table’s schema to yield very precise type information. Comp types for hash, array, and string libraries can also increase precision and thereby reduce the need for type casts. We formalize CompRDL and prove its type system sound. Rather than type check the bodies of library methods with comp types—those methods may include native code or be complex—CompRDL inserts run-time checks to ensure library methods abide by their computed types. We evaluated CompRDL by writing annotations with type-level computations for several Ruby core libraries and database query APIs. We then used those annotations to type check two popular Ruby libraries and four Ruby on Rails web apps. We found the annotations were relatively compact and could successfully type check 132 methods across our subject programs. Moreover, the use of type-level computations allowed us to check more expressive properties, with fewer manually inserted casts, than was possible without type-level computations. In the process, we found two type errors and a documentation error that were confirmed by the developers. Thus, we believe CompRDL is an important step forward in bringing precise static type checking to dynamic languages.
登录
查看更多内容
DOI:
--
发表时间:
2013
期刊:
ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation
影响因子:
--
作者:
J. Cheney;S. Lindley;Gabriel Radanne;P. Wadler
通讯作者:
P. Wadler
DOI:
--
发表时间:
2014
期刊:
Dynamic Languages Symposium
影响因子:
--
作者:
T. Stephen Strickland;Brianna M. Ren;Jeffrey S. Foster
通讯作者:
Jeffrey S. Foster
DOI:
10.1145/2908080.2908110
发表时间:
2016
期刊:
Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation
影响因子:
--
作者:
Panagiotis Vekris;B. Cosman;Ranjit Jhala
通讯作者:
Ranjit Jhala
DOI:
--
发表时间:
2018
期刊:
and Abstract Interpretation - VMCAI'18
影响因子:
--
作者:
Kazerounian, Milod;Vazou, Niki;Bourgerie, Austin;Foster, Jeff;Torlak, Emina
通讯作者:
Torlak, Emina
DOI:
10.1145/3009837.3009886
发表时间:
2017
期刊:
Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages
影响因子:
--
作者:
Stephen Chang;Alex Knauth;B. Greenman
通讯作者:
B. Greenman