Shared subtypes: subtyping recursive parametrized algebraic data types

Sigplan Notices(2009)

引用 4|浏览25
暂无评分
摘要
A newtype declaration in Haskell introduces a new type renaming an existing type. The two types are viewed by the programmer as semantically different, but share the same runtime representation. When operations on the two semantic views coincide, the run-time cost of conversion between the two types is reduced to zero (in both directions) because of this common representation. We describe a new language feature called Shared Subtypes (SSubtypes), which generalizes these properties of the newtype declaration. SSubtypes allow programmers to specify subtype rules between types and sharing rules between data constructors. A value of a type T, where T is a subtype of U, can always be cast, at no cost, to value of type U. This free up-casting allows library functions that consume the supertype to be applied without cost to subtypes. Yet any semantic interpretations desired by the programmer can be enforced by the compiler. SSubtype declarations work particularly well with GADTs. GADTs use differing type indexes to make explicit semantic differences, by using a different index for each way of viewing the data. Shared subtypes allow GADTs to share the same runtime representation as a reference type, of which the GADT is a refinement.
更多
查看译文
关键词
subtyping,explicit semantic difference,newtype declaration,new type,existing type,sharing representation,shared subtypes,type index,gadts,recursive types,algebraic data type,reference type,runtime representation,type u.,algebraic data types,subtyping recursive,common representation,subtype,parametrized types,datatypes,data type,semantic interpretation,indexation
AI 理解论文
溯源树
样例
生成溯源树,研究论文发展脉络
Chat Paper
正在生成论文摘要