Exception Handlers as Extensible Cases

  • Authors:
  • Matthias Blume;Umut A. Acar;Wonseok Chae

  • Affiliations:
  • Toyota Technological Institute at Chicago,;Toyota Technological Institute at Chicago,;Toyota Technological Institute at Chicago,

  • Venue:
  • APLAS '08 Proceedings of the 6th Asian Symposium on Programming Languages and Systems
  • Year:
  • 2008

Quantified Score

Hi-index 0.00

Visualization

Abstract

Exceptions are an indispensable part of modern programming languages. They are, however, handled poorly, especially by higherorder languages such as Standard ML and Haskell: in both languages a well-typed program can unexpectedly fail due to an uncaught exception. In this paper, we propose a technique for type-safe exception handling. Our approach relies on representing exceptions as sums and assigning exception handlers polymorphic, extensible row types. Based on this representation, we describe an implicitly typed external language EL where well-typed programs do not raise any unhandled exceptions. EL relies on sums, extensible records, and polymorphism to represent exceptionhandling, and its type system is no more complicated than that for existing languages with polymorphic extensible records. EL is translated into an internal language IL that is a variant of System F extended with extensible records. The translation performs a CPS transformation to represent exception handlers as continuations. It also relies on duality to transform sums into records. (The details for this translation are given in an accompanying technical report.) We describe the implementation of a compiler for a concrete language based on EL . The compiler performs full type inference and translates EL -style source code to machine code. Type inference relieves the programmer from having to provide explicit exception annotations. We believe that this is the first practical proposal for integrating exceptions into the type system of a higher-order language.