Warm fusion in Stratego - A case study in the generation of program transformation systems
Publication date
2000
Authors
Johann, P.
Visser, Eelco
Editors
Advisors
Supervisors
DOI
Document Type
Preprint
Metadata
Show full item recordCollections
License
Abstract
Stratego is a domain-specific language for the specification of program transfor-
mation systems. The design of Stratego is based on the paradigm of rewriting
strategies: user-definable programs in a little language of strategy operators
determine where and in what order transformation rules are (automatically)
applied to a program. The separation of rules and strategies supports modular-
ity of specifications. Stratego also provides generic features for specification of
program traversals.
In this paper we present a case study of Stratego as applied to a non-trivial
problem in program transformation. We demonstrate the use of Stratego in
eliminating intermediate data structures from (also known as deforesting) func-
tional programs via the warm fusion algorithm of Launchbury and Sheard.
This algorithm has been specified in Stratego and embedded in a fully auto-
matic transformation system for kernel Haskell. The entire system consists of
about 2600 lines of specification code, which breaks down into 1850 lines for a
general framework for Haskell transformation and 750 lines devoted to a highly
modular, easily extensible specification of the warm fusion transformer itself.
Its successful design and construction provides further evidence that programs
generated from Stratego specifications are suitable for integration into real sys-
tems, and that rewriting strategies are a good paradigm for the implementation
of such systems.
1.1 Introduction
Automatic program transformation is applied in many branches of software
engineering | including application generation and compiler construction | to
translate high-level, but inefficient, specification code to lower-level and more
eÆcient implementation code. It plays a particularly important role in compilers
for functional programming languages [9, 3, 10, 25, 28].
1.1.1 Transforming Programs with Rewriting Strategies
An important paradigm for the description of program transformation systems
is that of rewrite rules. Ad-hoc implementation of transformation systems based
on rewrite rules can be difficult, however, because the rules must be embedded in
7.