Lazy functional state threads

J Launchbury, SL Peyton Jones, Simon Peyton Jones

ACM Conference on Programming Languages Design and Implementation, Orlando (PLDI'94) |

Published by ACM Press

Some algorithms make critical internal use of updatable state, even though their external specification is purely functional. Based on earlier work on monads, we present a way of securely encapsulating stateful computations that manipulate multiple, named, mutable objects, in the context of a non-strict, purely-functional language.

The security of the encapsulation is assured by the type system, using parametricity. Intriguingly, this parametricity requires the provision of a (single) constant with a rank-2 polymorphic type.