Open data types and open functions

  • Authors:
  • Andres Löh;Ralf Hinze

  • Affiliations:
  • Universität Bonn, Bonn, Germany;Universität Bonn, Bonn, Germany

  • Venue:
  • Proceedings of the 8th ACM SIGPLAN international conference on Principles and practice of declarative programming
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

The problem of supporting the modular extensibility of both data and functions in one programming language at the same time is known as the expression problem. Functional languages traditionally make it easy to add new functions, but extending data (adding new data constructors) requires modifying existing code. We present a semantically and syntactically lightweight variant of open data types and open functions as a solution to the expression problem in the Haskell language. Constructors of open data types and equations of open functions may appear scattered throughout a program with several modules. The intended semantics is as follows: the program should behave as if the data types and functions were closed, defined in one place. The order of function equations is determined by best-fit pattern matching, where a specific pattern takes precedence over an unspecific one. We show that our solution is applicable to the expression problem, generic programming, and exceptions. We sketch two implementations: a direct implementation of the semantics, and a scheme based on mutually recursive modules that permits separate compilation