Shortcut fusion rules for the derivation of circular and higher-order monadic programs

  • Authors:
  • Alberto Pardo;João Paulo Fernandes;João Saraiva

  • Affiliations:
  • Universidad de la Republica, Montevideu, Uruguay;Universidade do Minho & Universidade Atlâântica, Braga, Portugal;Universidade do Minho, Braga, Portugal

  • Venue:
  • Proceedings of the 2009 ACM SIGPLAN workshop on Partial evaluation and program manipulation
  • Year:
  • 2009

Quantified Score

Hi-index 0.00

Visualization

Abstract

Functional programs often combine separate parts using intermediate data structures for communicating results. These programs are modular, easier to understand and maintain, but suffer from inefficiencies due to the generation of those gluing data structures. To eliminate such redundant data structures, some program transformation techniques have been proposed. One such technique is shortcut fusion, and has been studied in the context of both pure and monadic functional programs. Recently, we have extended standard shortcut fusion: in addition to intermediate structures, the program parts may now communicate context information, and it still is possible to eliminate those structures. This is achieved by transforming the original function composition into a circular program. This new technique, however, has been studied in the context of purely functional programs only. In this paper, we propose an extension to this new form of fusion, but in the context of monadic programming: we derive monadic circular programs from strict ones, maintaining the global effects. Later, the circularities in the derived programs are traded by high-order definitions, using a well-known program transformation technique. We finally obtain very efficient deforested programs. An important feature of our extensions is that they can be uniformly defined for a wide class of data types and monads, using generic calculation rules.