Handling Exceptions in Haskell
نویسنده
چکیده
Using a language without exception handling is like driving a car with no brakes and no seatbelt | things work ne until something goes wrong. You also learn to drive rather carefully. This paper describes an exception handling extension to the Haskell lazy functional language. The implementation turned out to be very easy but we had problems nding a viable semantics for our system. The resulting semantics is a compromise between theoretical beauty and practical utility.
منابع مشابه
Certified Proofs in Programs Involving Exceptions
Exception handling is provided by most modern programming languages. It allows to deal with anomalous or exceptional events which require special processing. In computer algebra, exception handling is an efficient way to implement the dynamic evaluation paradigm: for instance, in linear algebra, dynamic evaluation can be used for applying programs which have been written for matrices with coeff...
متن کاملModular Executable Language Specifications in Haskell
We propose a framework for specification of programming language semantics, abstract and concrete syntax, and lexical structure. The framework is based on Modular Monadic Semantics and allows independent specification of various language features. Features such as arithmetics, conditionals, exceptions, state and nondeterminism can be freely combined into working interpreters, facilitating exper...
متن کاملParallel and Concurrent Programming in Haskell
ions like timeout are certainly difficult to get right, but fortunately they only have to be written once. We find that in practice dealing with asynchronous exceptions is fairly straightforward, following a few simple rules: • Use bracket when acquiring resources that need to be released again. • Rather than takeMVar and putMVar, use modifyMVar_ (and friends) which have built-in asynchronous e...
متن کاملException Handlers as Extensible Cases
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 a...
متن کاملImprecise Exceptions, Co-Inductively
In a recent paper, Peyton Jones et al. proposed a design for imprecise exceptions in the lazy functional programming language Haskell PJRH + 99]. The main contribution of the design was that it allowed the language to continue to enjoy its current rich algebra of transformations. However, it does not combine easily with other extensions, most notably that of concurrency. We present an alternati...
متن کامل