Skip to main content
Article thumbnail
Location of Repository

Object-oriented style overloading for Haskell

By Mark Shields and Simon Peyton Jones

Abstract

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. 1 The problem The purpose of this paper is to make it easy to import libraries from Java[9] or.NET[18], into a Haskell program. By “easy ” we mean that it should be as easy to use the library from Haskell than from its native language. Indeed, Haskell’s higher order features and first-class monadic values make it a powerful glue language, so if we succeed it might even be easier to use the library from Haskell than from its native language. However, these advantages will not be persuasive if things that are easy in the native language are clumsy in Haskell. That is the challenge we address here

Year: 2001
OAI identifier: oai:CiteSeerX.psu:10.1.1.362.6326
Provided by: CiteSeerX
Download PDF:
Sorry, we are unable to provide the full text but you may find it at the following location(s):
  • http://citeseerx.ist.psu.edu/v... (external link)
  • http://research.microsoft.com/... (external link)
  • Suggested articles


    To submit an update or takedown request for this paper, please submit an Update/Correction/Removal Request.