Haskell's overlooked object system (original) (raw)
Related papers
Type Systems For Object-Oriented Programming Languages
1996
Object-oriented programming languages oopl's provide important support for today's large-scale software development projects. Unfortunately, the typing issues arising from the object-oriented features that provide this support are substantially di erent from those that arise in typing procedural languages. Attempts to adapt procedural type systems to object-oriented languages have resulted in languages like Simula, C++, and Object Pascal, which h a v e o v erly restrictive t ype systems. Among other things, the rigidity of these systems frequently force programmers to use type casts, which are a notorious source of hard-to-nd bugs. These restrictive type systems also mean that many programming idioms common to untyped oopl's such as Smalltalk are not typeable. One source of this lack of exibility is the con ation of subtyping and inheritance. Brie y, inheritance is an implementation technique in which new object de nitions may be given as incremental modi cations to existing de nitions. Subtyping concerns substitutivity: when can one object safely replace another? By tying subtyping to inheritance, existing oopl's greatly reduce the number of legal substitutions in a system, and hence their degree of polymorphism. Attempts to x this rigidity h a v e resulted in unsound type systems, most notably Ei el's.
Types, Data Abstraction, and Polymorphism
Our objective is to understand the notion of type in programming languages, present a model of typed, polymorphic programming languages that reflects recent research in type theory, and examine the relevance of recent research to the design of practical programming languages. Object-oriented languages provide both a framework and a motivation for exploring the interaction among the concepts of type, data abstraction, and polymorphism, since they extend the notion of type to data abstraction and since type inheritance is an important form of polymorphism. We develop a X-calculus-based model for type systems that allows us to explore these interactions in a simple setting, unencumbered by complexities of production programming languages. The evolution of languages from untyped universes to monomorphic and then polymorphic type systems is reviewed. Mechanisms for polymorphism such as overloading, coercion, subtyping, and parameterization are examined. A unifying framework for polymorphic type systems is developed in terms of the typed A-calculus augmented to include binding of types by quantification as well as binding of values by abstraction. The typed X-calculus is augmented by universal quantification to model generic functions with type parameters, existential quantification and packaging (information hiding) to model abstract data types, and bounded quantification to model subtypes and type inheritance. In this way we obtain a simple and precise characterization of a powerful type system that includes abstract data types, parametric polymorphism, and multiple inheritance in a single consistent framework. The mechanisms for type checking for the augmented X-calculus are discussed. The augmented typed X-calculus is used as a programming language for a variety of illustrative examples. We christen this language Fun because fun instead of X is the functional abstraction keyword and because it is pleasant to deal with. Fun is mathematically simple and can serve as a basis for the design and implementation of real programming languages with type facilities that are more powerful and expressive than those of existing programming languages. In particular, it provides a basis for the design of strongly typed object-oriented languages.
Objects and polymorphism in system programming languages: a new approach
Periodica Polytechnica Electrical Engineering, 2007
A low-level data structure always has a predefined representation which does not fit into an object of traditional objectoriented languages, where explicit type tag denotes its dynamic type. This is the main reason why the advanced features of object-oriented programming cannot be fully used at the lowest level. On the other hand, the hierarchy of low-level data structures is very similar to class-trees, but instead of an explicit tag-field the value of the object determines its dynamic type. Another peculiar requirement in system programming is that some classes have to be polymorphic by-value with their ancestor: objects must fit into the space of a superclass instance. In our paper we show language constructs which enable the system programmer to handle all data structures as objects, and exploit the advantages of object-oriented programming even at the lowest level. Our solution is based on Predicate Dispatching, but adopted to the special needs of system programming. The techniques we show also allow for some classes to be polymorphic by-value with their super. We also describe how to implement these features without losing modularity.
Type Systems for the Object Oriented Paradigm
Citeseer, 1999
In this thesis we study some object-oriented mechanisms from the type system perspective. Our starting point is the axiomatic model of Fisher, Honsell and Mitchell, the Lambda Calculus of Objects. Following the path of recent researches on the topic, we show how some object-based language features can be happily modeled within some functional calculi, proved sound with respect to the message-not-understood error. Then, we approach the more complicated problem of modeling class constructs, presenting two proposals and discussing their respective qualities and drawbacks, together with some future directions we would like to follow to try to better understand classbased languages. precious comments and all of the discussions we had together on objects. A special thank goes to Betti Venneri (University of Firenze), for her encouragement since she has been the supervisor for my master thesis when she was still in Torino. My gratitude goes then to my external referees, Giuseppe Castagna (ENS, Paris) and Sophia Drossopoulou (Imperial College, London), for their kindness in accepting to read my manuscript and for their precious suggestions that helped me improving the presentation of my work. Last but not least, I would like to mention all the people I met during my academic path that made my life easier with their friendship and their support (following again the temporal order in which I met them for the rst time
A paradigmatic object-oriented programming language: Design, static typing and semantics
Journal of Functional Programming, 1994
To illuminate the fundamental concepts involved in object-oriented programming languages, we describe the design of TOOPL, a paradigmatic, statically-typed, functional, object-oriented programming language which supports classes, objects, methods, hidden instance variables, subtypes and inheritance.It has proven to be quite difficult to design such a language which has a secure type system. A particular problem with statically type checking object-oriented languages is designing typechecking rules which ensure that methods provided in a superclass will continue to be type correct when inherited in a subclass. The type-checking rules for TOOPL have this feature, enabling library suppliers to provide only the interfaces of classes with actual executable code, while still allowing users to safely create subclasses. To achieve greater expressibility while retaining type-safety, we choose to separate the inheritance and subtyping hierarchy in the language.The design of TOOPL has been gui...
Proceedings of the 8th ACM SIGPLAN workshop on Types in language design and implementation - TLDI '12, 2012
Static type systems strive to be richly expressive while still being simple enough for programmers to use. We describe an experiment that enriches Haskell's kind system with two features promoted from its type system: data types and polymorphism. The new system has a very good power-to-weight ratio: it offers a significant improvement in expressiveness, but, by re-using concepts that programmers are already familiar with, the system is easy to understand and implement.