The Futamura Projections are a series of program signatures reported by [Fut99] (a reprinting of [Fut71]) designed to create a program that generates compilers by repeated applications of a partial evaluator that iteratively abstracts away aspects of the program execution process. A partial evaluator transforms a program given any subset of its input to produce a version of the program that has been specialized to that input. We use the symbol mix from [Jon96] to denote the partial evaluation operation because partial evaluation involves a mixture of interpretation and code generation.
In this article, we introduce a model for staging human-computer dialogs based on The Futamura Projections. In other words, the Futamura Projections provide a way to generate programs that stage interactions between two participants engaged in a human-computer dialog for a variety of dialog representations. Table 1 is a legend mapping terms and symbols used in this article to their description. For a general introduction to the Futamura Projections, using the same diagramming conventions as this article, we refer the reader to [WP16].
2 Staging Human-computer Dialogs
|A dialog between two parties.|
|A prompt for some input.|
|A response to a prompt.|
|The result of a successful dialog.|
|A domain-specific language designed for representing human-computer-dialogs.|
|A dialog facilitating a coffee order.|
|Coffee made according to the dialog prompts and responses.|
|A program that generates stagers when given a dialog specification.|
|An instance of a dialog specification ddsl.|
|A program that stages a dialog.|
|A stager for the coffee dialog.|
|A program that stages a dialog given its specification and responses.|
|A program that creates ddsl compilers when given a ddsl interpreter.|
A dialog, for the purposes of this paper, is a series of interactions between a user and a computer system, which do not necessarily occur through a verbal modality. For instance, a user of an installation wizard for an application program participates in a human-computer dialog [DFAB10]. Additionally, dialogs in this paper are not specific to their responses, but represent an ordering of prompts and set of appropriate responses for a particular purpose of interaction. In this way, a dialog is analogous to a program: a definition of behavior with results that differ based on variable information provided as input. We can represent dialogs diagrammatically as seen in Fig. 0(a) or equationally as . For example, a dialog for ordering coffee may prompt a customer for the size and bean blend of the coffee, as well as whether or not to leave room for cream. Such an example instance is depicted in Fig. 0(b) and described equationally as .
Although dialogs are analogous to programs, a dialog is not a program and cannot execute on a computer. Instead, it must be staged111We are not referring to staging as the ‘language construct that allows a program at one stage of evaluation to manipulate and specialize a program to be executed at a later stage’ [LSS12]. Rather, we are using the term to refer to ‘providing a platform for the progressive interaction of a human-computer dialog.’ with the assistance of a special program. A program that structures the interaction of a particular dialog is called a stager for that dialog. If a dialog is analogous to a program, a stager is analogous to a second program, semantically equivalent to the first, that has been implemented in a natively executable language. In other words, a stager is analogous to a compiled dialog. The details of staging human-computer dialogs, and particularly mixed-initiative dialogs [NS97], are given in [PB16].
2.1 Dialog DSL Interpretation
Just as high-level programming languages are suited to describing programs to humans, we can design a special domain-specific language (dsl) suited to describing dialogs to humans. As with programming languages, we can then write a dialog dsl (ddsl) interpreter that accepts a dialog specification in that language and stages it, a process detailed in Fig. 1(a). Fig. 1(b) illustrates ddsl interpretation with our diagram conventions while the equational representation is . Fig. 1(c) and the expression show the ddsl interpreter staging the coffee dialog from Fig. 0(b).
2.2 Dialog DSL Compilation
Compilers translate programs in a source language to equivalent programs in a target language. Analogously, we have created a program that takes dialog specifications in a ddsl and generates a stager for that dialog. We call this stager generator program a ddsl compiler. A ddsl compiler program is depicted in Fig. 2(a) and expressed equationally as . Although a dialog specification is not executable, Fig. 2(c) demonstrates the behavioral equivalence of the stager and the specification. The generation of a stager for the coffee dialog is shown in Fig. 2(b) and expressed equationally as , and its input and output are compared in Fig. 2(d).
3 A Programming Model for Staging Dialogs
The Third Futamura Projection produces a program that, given an interpreter for any source programming language, can generate a compiler for that language. Furthermore, this interpreter need not be thought of exclusively in the traditional sense as a program interpreter. In particular, it can be any program that conforms to the interpretation signature by accepting two inputs, namely some source that describes a behavior and the input to that source, and enacting the behavior. Providing with a ddsl interpreter and dialog specifications yields programs meaningful to staging. Therefore, the Futamura Projections can be applied to the staging of human-computer dialogs in addition to the execution of programs, and this is the primary contribution of this paper. To facilitate the staging of dialogs, we provide staging analogs to the classical Futamura Projections.
3.1 First Futamura Staging Projection:
Dialog DSL Compilation
Let us first look at the partial evaluation of a ddsl interpreter with a dialog specification as static input, as shown in Fig. 3(a) and expressed equationally as . Here specializes the ddsl interpreter to the dialog, leaving the responses as dynamic input. The resulting program, shown in Fig. 3(c) and represented equationally as , accepts the responses and completes the staging of the dialog. In other words, the specialized program is a stager for the input dialog. The partial evaluator has effectively generated a stager from a ddsl dialog specification. This transformation is analogous to the compilation of a source program into a target program in the First Futamura Projection pattern. Applying the pattern to the coffee dialog instance, Fig. 3(b) depicts the partial evaluation of a ddsl interpreter with the coffee specification as input. This process can be expressed equationally as . The resulting program, examined in Fig. 3(d) and expressed equationally as , stages the coffee dialog with any responses to produce the result (i.e., the ordered coffee).
First Futamura Staging Projection: A partial evaluator, with the aid of a ddsl interpreter, can generate stagers.
3.2 Second Futamura Staging Projection:
DDSL Compiler Generation
We have applied the pattern of the First Futamura Projection to dialog staging to produce the First Futamura Staging Projection. Because the Second Futamura Projection is just a partial evaluation of the first, we can apply the pattern of the Second Futamura Projection to staging by partially evaluating the First Futamura Staging Projection. This Projection is shown in Fig. 4(a) and expressed as , where itself is being partially evaluated with the ddsl interpreter as static input. The resulting program, as with the result of the Second Futamura Projection, captures the behavior of the previous Projection. Fig. 4(b) (represented equationally as ) demonstrates this by accepting a dialog specification and producing a stager for it. Notice that it has the same shape and labels as Fig. 3(a). The diagrams are the same as those for the classical Futamura Projections, but with the source language interpreter replaced with a ddsl interpreter and the source and target programs replaced with a dialog specification and stager, respectively. Instead of abstracting the source program away from a -based program compilation process, we are abstracting the dialog specification away from a -based ddsl compilation process.
The Second Futamura Staging Projection is applied to the coffee dialog in Figs. 4(c) and 4(d). In the first, is specialized to the ddsl interpreter for the dialog. In the second, the output program completes the partial evaluation of the ddsl interpreter and produces a stager for the coffee dialog. These figures are represented equationally as and , respectively.
Second Futamura Staging Projection: A partial evaluator, by making use of another instance of itself and a ddsl interpreter, can generate ddsl compilers.
3.3 Third Futamura Staging Projection:
Generation of DDSL Compiler Generators
Now we abstract the staging process one final degree by partially performing the Second Futamura Staging Projection while leaving the ddsl interpreter as dynamic input. Fig. 5(a) shows this third Projection, which is expressed equationally as . Aside from the label that the result is a generator of ddsl compilers, there is nothing specific to dialogs or staging in this projection. Because there is no mention of a generic input program, a dialog specification, or either variety of interpreter (i.e., program or staging), the Third Futamura Staging Projection is the same as the Third Futamura Projection. However, when given different varieties of interpreter as input, the generator program serves different roles. The result of the Third Futamura Projection generates a traditional compiler when given a programming language interpreter, but in the context of the Futamura Staging Projections, it generates a ddsl compiler from a ddsl interpreter. The latter is depicted in Fig. 5(b) and expressed equationally as .
Third Futamura Staging Projection: A partial evaluator, by making use of two additional instances of itself, can generate a program that generates ddsl compilers.
3.4 Summary: Futamura Staging Projections
Each human-computer dialog Staging Projection, akin to each Futamura Projection, abstracts away a previous process by partial evaluation. The First Futamura Staging Projection treats the dialog responses as dynamic input. The Second Staging Projection furthers the abstraction, this time with the dialog specification. The Third Staging Projection allows the dsl used for expressing the dialog to vary by treating the ddsl interpreter as dynamic input. The Futamura Staging Projections extend the program-to-dialog analogy when each source-program-specific element is replaced by its dialog staging analog. In other words, replacing the source program with a dialog specification and the interpreter with a ddsl interpreter in turn replaces the target program with a stager and the compiler with a ddsl compiler. As mentioned earlier, the program compiler generator and the ddsl compiler generator (i.e., the results of third of each series of projections) are not just analogous, but identical. Table 3 juxtaposes the related equations and diagrams from both 2 and 3 in each row to make their relationships more explicit. Each row of Table 3 succinctly summarizes each Staging Projection by associating each side of its equational representation with the corresponding figure from 3.
|Fig.||Equational Notation||Input Description||Output Description||Similar Fig.||Output Fig.|
|0(a)||A list of responses for the dialog.||The results of a successfully completed dialog.||N/A||N/A|
|1(b)||A dialog specification in the ddsl along with its responses.||The results of a successfully completed dialog.||N/A||N/A|
|2(a)||A dialog specification in the ddsl.||A program that stages the dialog.||N/A||2(c)|
|3(a)||An interpreter for the ddsl and a dialog specification in the ddsl.||A program that stages the dialog.||N/A||3(c)|
|3(c)||A list of responses for the dialog.||The results of a successfully completed dialog.||1(b)||N/A|
|4(a)||and an interpreter for the ddsl.||A ddsl compiler.||N/A||4(b)|
|4(b)||A dialog specification in the ddsl.||A program that stages the dialog.||3(a)||3(c)|
|5(a)||Two instances of .||A program that generates ddsl compiler||N/A||5(b)|
|5(b)||An interpreter for the ddsl.||A ddsl compiler.||4(a)||4(b)|
|Projection||Description||Equational Notation||Fig.||Output Fig.|
|1||can generate stagers.||3(a)||3(c)|
|2||can generate ddsl compilers.||4(a)||4(b)|
|3||can generate a program that generates ddsl compilers.||5(a)||5(b)|
We applied the Futamura Projections to the staging of human-computer dialogs. Partial evaluation, through the Futamura Staging Projections, can be used to generate stagers, ddsl compilers, and programs that themselves generate ddsl compilers. Although the scope of the Futamura Projections has been largely limited to the programming languages research community, we are optimistic that this article has provided a programming model for using the Projections in staging and made a case for their role in building powerful programming abstractions in human-computer interaction.
- [DFAB10] A. Dix, J. Finlay, G.D. Abowd, and R. Beale. Human-Computer Interaction, chapter 16: Dialog Notations and Design. Prentice Hall, Harlow, England, third edition, 2010.
- [Fut71] Y. Futamura. Partial evaluation of computation process: An approach to a compiler-compiler. Systems Computers Controls, 2(5):54–50, 1971.
- [Fut99] Y. Futamura. Partial evaluation of computation process: An approach to a compiler-compiler. Higher-Order and Symbolic Computation, 12(4):381–391, 1999.
- [Jon96] N.D. Jones. An introduction to partial evaluation. ACM Computing Surveys, 28(3):480–503, 1996.
- [LSS12] Y.D. Liu, C. Skalka, and S.F. Smith. Type-specialized staged programming with process separation. Higher-Order and Symbolic Computation, pages 1–45, September 2012.
- [NS97] D.G. Novick and S. Sutton. What is mixed-initiative interaction? In S. Haller and S. McRoy, editors, AAAI Spring Symposium on Computational Models for Mixed Initiative Interaction, number SS-97-04, pages 114–116. AAAI Press, Menlo Park, CA, 1997.
- [PB16] S. Perugini and J.W. Buck. A language-based model for specifying and staging mixed-initiative dialogs. In José Creissac Campos and A. Schmidt, editors, Proceedings of the Eighth International ACM SIGCHI Symposium on Engineering Interactive Computing Systems (EICS), pages 204–216, New York, NY, 2016. ACM Press.
- [WP16] B.M. Williams and S. Perugini. Revisiting the Futamura projections: A diagrammatic approach. Theoretical and Applied Informatics, 28(4):15–32, 2016. DOI: 10.20904/284015.