Modeling Objects with Internal and Mutable States in Purely Functional Programming Languages,
Koji Kagawa


The notion of monads has been found to be useful in order to model side-effects such as input/output, mutable states and first-class continuations in purely functional languages. In this paper, monad morphisms, as well as monads, are used in order to model concepts of object-oriented programming languages in purely functional languages. In object-oriented languages, {\it objects} have their own local states, and {\it methods} are defined with respect to these local states. More complex objects can be constructed out of several simpler objects (which are visible as {\it instance variables}). Monads are used in order to model objects which have local and mutable states in functional languages. In this setting, for each {\it class} there is a corresponding monad, and {\it methods} in one class are represented as operators in the corresponding monad. Monad morphisms are used in order to invoke methods of component objects from those of composite objects. There monad morphisms can be regarded as identifiers of component objects. In this way, methods written for commonly-used classes can be reused.