Abstract. Following the paradigm of encapsulation of side effects via monads, the Java execution mechanism has been described by the socalled Java monad, encorporating essentially stateful computation and exceptions, which are heavily used in Java control flow. A technical problem that appears in this model is the fact that the return exception in Java is parametrized by the return value, so that method calls actually move between slightly different monads, depending on the type of the return value. We provide a treatment of this problem in the general framework of exception monads as introduced in earlier work by some of the authors; this framework includes generic partial and total Hoare calculi for abrupt termination. Moreover, we illustrate this framework by means of a verification of a pattern match algorithm. Introduction Many imperative languages allow for manipulating the control flow by means of exceptions. Particularly extensive use of this possibility is made in Java, where abnormally terminating statements are used e.g. in order to exit from loops or method calls. Exceptions therefore also play a prominent role in the design of program logics for Java. Generally, imperative languages may be represented in standard higher order logic or in functional programming languages by encapsulating side effects as monads, a principle introduced by Moggi . The Java exception mechanism has been modelled by the so-called Java monad , an instance of Moggi's exception monad transformer . In previous work [16, 14, 15], we have developed monadic computational logics for generic side effects, and we have extended these logics with a generic treatment of exceptional termination that subsumes existing Hoare logics for abrupt termination [4, 5]
To submit an update or takedown request for this paper, please submit an Update/Correction/Removal Request.