Summary: Exception Handlers as Extensible Cases
Matthias Blume Umut A. Acar Wonseok Chae
Toyota Technological Institute at Chicago
Abstract. Exceptions are an indispensable part of modern program-
ming languages. They are, however, handled poorly, especially by higher-
order 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 rep-
resentation, 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 exception-
handling, and its type system is no more complicated than that for ex-
isting languages with polymorphic extensible records.
EL is translated into an internal language IL that is a variant of Sys-
tem 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