Object-Oriented Style Overloading for Haskell (Extended Abstract)
Mark Shields, Simon Jones · Electronic Notes in Theoretical Computer Science · 2001
Haskell has a sophisticated mechanism for overloading identifiers with multiple definitions at distinct types. Object-oriented programming has a similar notion of overriding and overloading for methods names. Unfortunately, it is not possible to encode object-oriented overloading directly using Haskell overloading. This deficiency becomes particularly tiresome when Haskell programs wish to call methods imported from an object-oriented library. We present two refinements of Haskell's type class system: Closed classes and overlapping instances. We demonstrate how we may exploit the refined system so as to be able to encode object-oriented classes within Haskell. This encoding allows us to mimic, within Haskell, the overloading resolution rules employed by object-oriented languages without the need for additional type annotations or name mangling. As a consequence, object-oriented class libraries are very convenient to import and use within Haskell. We thank Don Syme, Nick Benton, Andrew Kennedy, and the anonymous reviewers, for many helpful comments.
Cited by 18 works. doi:10.1016/s1571-0661(05)80455-4 Open-access PDF
Authors
References
- The Java Language Specification
- Imperative functional programming
- How to make ad-hoc polymorphism less ad hoc
- Foundations of programming languages
- The Common Lisp Object System: An Overview
- Qualified Types : Theory and Practice
- Implicit parameters
- Type Classes with Functional Dependencies
- Simplifying and improving qualified types
- Foundations for programming languages