Speaker: Ki-Yung Ahn
Time:2008-12-24 10:00:00
Place:Room 308, Bldg 302, SNU


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.


[ List ]