Abstract
We describe a metalanguage MMML, which makes explicit the order of evaluation (in the spirit of monadic metalanguages) and the staging of computations (as in languages for multi-level bindingtime analysis). The main contribution of the paper is an operational semantics which is sufficiently detailed for analyzing subtle aspects of multi-stage programming, but also intuitive enough to serve as a reference semantics. For instance, the separation of computational types from code types, makes clear the distinction between a computation for generating code and the generated code, and provides a basis for multi-lingual extensions, where a variety of programming languages (aka monads) coexist. The operational semantics consists of two parts: local (semantics preserving) simpli.cation rules, and computation steps executed in a deterministic order (because they may have side-effects). We focus on the computational aspects, thus we adopt a simple type system, that can detect usual type errors, but not the unresolved link errors. Because of its explicit annotations, MMML is suitable as an intermediate language.
Supported by MIUR project NAPOLI and EU project DART IST-2001-33477.
Chapter PDF
Similar content being viewed by others
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
References
N. Benton and A. Kennedy. Monads, effects and transformations. In Proceedings of the Third International Workshop on Higher Order Operational Techniques in Semantics (HOOTS-99), volume 26 of Electronic Notes in Theoretical Computer Science, Paris, September 1999. Elsevier.
G. Berry and G. Boudol. The chemical abstract machine. In Conf. Record 17th ACM Symp. on Principles of Programmming Languages, POPL’90, San Francisco, CA, USA, 17–19 Jan. 1990, pages 81–94. ACM Press, New York, 1990.
C. Calcagno, E. Moggi, and T. Sheard. Closed types for a safe imperativeMetaML. Journal of Functional Programming, to appear.
R. Davies. A temporal-logic approach to binding-time analysis. In the Symposium on Logic in Computer Science (LICS’ 96), pages 184–195, New Brunswick, 1996. IEEE Computer Society Press.
R. Davies and F. Pfenning. A modal analysis of staged computation. In the Symposium on Principles of Programming Languages (POPL’ 96), pages 258–270, St. Petersburg Beach, 1996.
A. Filinski. Normalization by evaluation for the computational lambda-calculus.In Samson Abramsky, editor, Proc. of 5th Int. Conf. on Typed Lambda Calculi and Applications, TLCA’01, Krakow, Poland, 2–5 May 2001, volume 2044 of Lecture Notes in Computer Science, pages 151–165. Springer-Verlag, Berlin, 2001.
R. Glück and J. Jørgensen. Efficient multi-level generating extensions for program specialization. In S. D. Swierstra and M. Hermenegildo, editors, Programming Languages: Implementations, Logics and Programs (PLILP’95), volume 982 of Lecture Notes in Computer Science, pages 259–278. Springer-Verlag, 1995.
J. W. Klop. Combinatory Reduction Systems. PhD thesis, University of Utrecht, 1980. Published as Mathematical Center Tract 129.
The MetaML Home Page, 2000. Provides source code and documentation online at http://www.cse.ogi.edu/PacSoft/projects/metaml/index.html.
A. Nanevski. Meta-programming with names and necessity. In Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming (ICFP-02), ACM SIGPLAN notices, New York, October 2002. ACM Press.
M. F. Nielsen and W. Taha. Environment classifiers. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL), N.Y., January 15–17 2003. ACM Press.
S. P. Jones, J. Hughes, L. Augustsson, D. Barton, and et. al. Haskell 1.4: A non-strict, purely functional language. Technical Report YALEU/DCS/RR-1106, Department of Computer Science, Yale University, Mar 1997. World Wide Web version at http://haskell.cs.yale.edu/haskell-report.
A. M. Pitts and M. J. Gabbay. A metalanguage for programming with bound names modulo renaming. In Mathematics of Programme Construction, volume 1837 of Lecture Notes in Computer Science, pages 230–255. Springer-Verlag, 2000.
T. Sheard. Accomplishments and research challenges in meta-programming. In W. Taha, editor, Proc. of the Int. Work. on Semantics, Applications, and Implementations of Program Generation (SAIG), volume 2196 of LNCS, pages 2–46. Springer-Verlag, 2001.
W. Taha. Multi-Stage Programming: Its Theory and Applications. PhD thesis, Oregon Graduate Institute of Science and Technology, 1999. Available from ftp://cse.ogi.edu/pub/tech-reports/README.html.
W. Taha and T. Sheard.MetaML: Multi-stage programming with explicit annotations. Theoretical Computer Science, 248(1–2), 2000.
P. Thiemann and D. Dussart. Partial evaluation for higher-order languages with state, 1999. Available from http://www.informatik.uni-freiburg.de/~thiemann/papers/index.html
P. Wadler. The marriage of effects and monads. In the International Conference on Functional Programming (ICFP’ 98), volume 34(1) of ACM SIGPLAN Notices, pages 63–74. ACM, June 1999.
A. K. Wright and M. Felleisen. A syntactic approach to type soundness. Information and Computation, 115(1):38–94, 1994.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2003 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Moggi, E., Fagorzi, S. (2003). A Monadic Multi-stage Metalanguage. In: Gordon, A.D. (eds) Foundations of Software Science and Computation Structures. FoSSaCS 2003. Lecture Notes in Computer Science, vol 2620. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-36576-1_23
Download citation
DOI: https://doi.org/10.1007/3-540-36576-1_23
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-00897-2
Online ISBN: 978-3-540-36576-1
eBook Packages: Springer Book Archive