Monadification of functional programs

  • Authors:
  • Martin Erwig;Deling Ren

  • Affiliations:
  • School of EECS, Oregon State University, Corvallis, OR;School of EECS, Oregon State University, Corvallis, OR

  • Venue:
  • Science of Computer Programming - Special issue on program transformation
  • Year:
  • 2004

Quantified Score

Hi-index 0.00

Visualization

Abstract

The structure of monadic functional programs allows the integration of many different features by just changing the definition of the monad and not the rest of the program, which is a desirable feature from a software engineering and software maintenance point of view. We describe an algorithm for the automatic transformation of a group of functions into such a monadic form. We identify two correctness criteria and argue that the proposed transformation is at least correct in the sense that transformed programs yield the same results as the original programs modulo monad constructors. The translation of a set of functions into monadic form is in most cases only a first step toward an extension of a program by adding new features. The extended behavior can be realized by choosing an appropriate monad type and by inserting monadic actions into the functions that have been transformed into monadic form. We demonstrate an approach to the integration of monadic actions that is based on the idea of specifying context-dependent rewritings.