Monadic Encapsulation of E ects : A Revised Approach ( Extended
نویسنده
چکیده
Launchbury and Peyton Jones came up with an ingenious idea for embedding regions of imperative programming in a pure functional language like Haskell. The key idea was based on a simple modiication of Hindley-Milner's type system. Our rst contribution is to propose a more natural encapsulation construct exploiting higher-order kinds, which achieves the same encapsulation eeect, but avoids the ad hoc type parameter of the original proposal. The second contribution is a type safety result for encapsulation of strict state using both the original encapsulation construct and the newly introduced one. We establish this result in a more expressive context than the original proposal, namely in the context of the higher-order lambda-calculus. The third contribution is a type safety result for encapsulation of lazy state in the higher-order lambda-calculus. This result resolves an outstanding open problem on which previous proof attempts failed. In all cases, we formalize the intended implementations as simple big-step operational semantics on untyped terms, which capture interesting implementation details not captured by the reduction semantics proposed previously.
منابع مشابه
Taming E ects with Monadic Typing 1
The familiar Hindley-Milner type system of the ML language family is extended with monad annotations to account for possible side e ects of expression evaluation. This also allows e ects to be e ectively encapsulated by lexical scopes, with enforcement provided by type checking. A type-and-e ects analysis supports type inference. Type soundness and completeness theorems establish the coherence ...
متن کاملMonadic encapsulation of effects: a revised approach (extended version)
Launchbury and Peyton Jones came up with an ingenious idea for embedding regions of imperative programming in a pure functional language like Haskell. The key idea was based on a simple modification of Hindley-Milner’s type system. Our first contribution is to propose a more natural encapsulation construct exploiting higher-order kinds, which achieves the same encapsulation effect, but avoids t...
متن کاملOn the Expressive Power of User - Defined E ects
We compare the expressive power of three programming abstractions for user-de ned computational e ects: Bauer and Pretnar’s e ect handlers, Filinski’s monadic re ection, and delimited control without answer-type-modi cation. This comparison allows a precise discussion about the relative expressiveness of each programming abstraction. It also demonstrates the sensitivity of the relative expressi...
متن کاملControlling E ects
Many computational e ects, such as exceptions, state, or nondeterminism, can be conveniently speci ed in terms of monads. We investigate a technique for uniformly adding arbitrary such e ects to ML-like languages, without requiring any structural changes to the programs themselves. Instead, we use monadic re ection, a new language construct for explicitly converting back and forth between repre...
متن کاملMonadic Encapsulation of Effects: a Revised Approach
Launchbury and Peyton-Jones came up with an ingenious idea for embedding regions of imperative programming in a pure functional language like Haskell. The key idea was based on a simple modification of Hindley-Milner’s type system. Our first contribution is to propose a more natural encapsulation construct exploiting higher-order kinds, which achieves the same encapsulation effect, but avoids t...
متن کامل