Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/199448.199528acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article
Free access

Monad transformers and modular interpreters

Published: 25 January 1995 Publication History
  • Get Citation Alerts
  • Abstract

    We show how a set of building blocks can be used to construct programming language interpreters, and present implementations of such building blocks capable of supporting many commonly known features, including simple expressions, three different function call mechanisms (call-by-name, call-by-value and lazy evaluation), references and assignment, nondeterminism, first-class continuations, and program tracing.
    The underlying mechanism of our system is monad transformers, a simple form of abstraction for introducing a wide range of computational behaviors, such as state, I/O, continuations, and exceptions.
    Our work is significant in the following respects. First, we have succeeded in designing a fully modular interpreter based on monad transformers that incudes features missing from Steele's, Espinosa's, and Wadler's earlier efforts. Second, we have found new ways to lift monad operations through monad transformers, in particular difficult cases not achieved in Moggi's original work. Third, we have demonstrated that interactions between features are reflected in liftings and that semantics can be changed by reordering monad transformers. Finally, we have implemented our interpreter in Gofer, whose constructor classes provide just the added power over Haskell's type classes to allow precise and convenient expression of our ideas. This implementation includes a method for constructing extensible unions and a form of subtyping that is interesting in its own right.

    References

    [1]
    Andrew W. Appel and Trevor Jim. Continuationpassing, closure-passing style. In ACM Symposium on Principles of Programming Languages, pages 193-302, January 1989.
    [2]
    Adrienne Bloss, Paul HudaK and Jonathan Young. Code optimization for lazy evaluation. Lisp and Symbolic Computation, 1(1):147-164,1988.
    [3]
    Robert Cartwright and Matthias Felleisen. Extensible denotational semantics. In Proceedings of Symposium on Theoretical Aspects of Computer Software, pages 244-272, 1994.
    [4]
    David Espinosa. Modular denotational semantics. Unpublished manuscript, December 1993.
    [5]
    David Espinosa. Building interpreters by transforming stratified monads. Unpublished manuscript, ftp from altdorf.ai.mit.edu:pub/dae, June 1994.
    [6]
    Andrzej Filinski. Representing monads. In Conference Record of POPL "94: 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Portland, Oregon, pages 446-457, New York, January 1994. ACM Press.
    [7]
    Paul Hudak, Simon Peyton Jones, and Philip Wadler. Report on the programming language Haskell: a nonstrict, purely f#unctional language, version 1.2. Technical Report YALEU/DCS/RR-777, Yale University Department of Computer Science, March 1992. Also in ACM SIGPLAN Notices, Vol. 27(5), May 1992.
    [8]
    Mark P. Jones. Introduction to gofer 2.20. Ftp from nebula.cs.yale.e#lu in the directory pub/haskell/gofer, September 19911.
    [9]
    Mark P. Jones.# system of constructor classes: Overloading and implicit higher-order polymorphism. In FPCA "93: Conference on Functional Programming Languages and Computer Architecture, Copenhagen, Denmark, pages 52-61, N6w York June 1993. ACM Press. /
    [10]
    Mark P. Jones #nd Luc Duponcheel Composing monads. Research Report- YALEU/DCS/RR-1004, Yale University Departrhent of Computer Science, New Haven, Connecticut, December 1993.
    [11]
    Richard Kelseyland Paul Hudak. Realistic compilation by program transformation. In ACM Symposium on Principles of Programming Languages, pages 181-192, January 1989. i /
    [12]
    Amir Kishon, #aul Hudak, and Charles Consel. Monitoring semantics:" A formal framework for specifying, implementing alnd reasoning about execution monitors. In #Proceedings #f the ACM SIGPLAN "91 Conference on Programming L#nguage Design and Implementation, pages 338-352, June 1191.
    [13]
    Peter Lee. Realistic Compiler Generation. Foundations of Computing. MIT Press, 1989.
    [14]
    Robin Milner, Mads Torte, and Robert Harper. The Definition of Standard ML. MIT Press, 1990.
    [15]
    Eugenio Mogg#. An abstract view of programming languages. Techni/:al Report ECS-LFCS-90-113, Laboratory for Foundations of Computer Science, University of Edinburgh, Edinburgh, Scotland, 1990.
    [16]
    Peter D. Mosses. A basic abstract semantic algebra. In Gilles Kahn, David B. MacQueen, and Gordon D. Plotkin,I editors, Semantics of Data Types: International Symposium, Sophia-Antipolis, France, pages 87-107. Springer-Verlag', June 1984:. Lecture Notes in Computer Science 17:?.
    [17]
    Simon PeytonlJones and Philip Wadler. Imperative functional pro#.ramming. In Proceedings 20th Symposium on Principles d# Programming Languages, pages 71-84. ACM, January 1993.
    [18]
    Guy L. Steele Jr. Building interpreters by composing monads, in COnference Record of POPL "94: 21st ACM SIGPLAN-SIG,4CT Symposium on Principles of Programming Languages, Portland, Oregon, pages 472-492, New York January/1#994. ACM Press.
    [19]
    Joseph Stoy. l#,enotational Semantics: The Scott-Strachey Approach to Programming Language Theory. MIT Press, 1977.
    [20]
    Andrew P. Tolmach and Andrew W. Appel. Debugging standard ML #ithout reverse engineering. In Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, #ice, France, June 1990. /
    [21]
    Philip Wadler.I The essence of functional programming. In Conference Record of the Nineteenth Annual ACM Symposiu#n on Principles of Programming Languages, Albuquerque, N#w Mexico, pages 1-14, January 1992.
    [22]
    Philip L. Wadler. Comprehending monads. In Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, 1990.
    [23]
    Mitchell Wand. A semantic prototyping system. SIG- PLAN Notices, ACM Symposium on Compiler Construction, 19(6):213-221,1984.

    Cited By

    View all
    • (2024)Outcome Separation Logic: Local Reasoning for Correctness and Incorrectness with Computational EffectsProceedings of the ACM on Programming Languages10.1145/36498218:OOPSLA1(276-304)Online publication date: 29-Apr-2024
    • (2023)From Capabilities to Regions: Enabling Efficient Compilation of Lexical Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228317:OOPSLA2(941-970)Online publication date: 16-Oct-2023
    • (2023)Effect Handlers for Programmable InferenceProceedings of the 16th ACM SIGPLAN International Haskell Symposium10.1145/3609026.3609729(44-58)Online publication date: 30-Aug-2023
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    POPL '95: Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
    January 1995
    415 pages
    ISBN:0897916921
    DOI:10.1145/199448
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 25 January 1995

    Permissions

    Request permissions for this article.

    Check for updates

    Qualifiers

    • Article

    Conference

    POPL95
    POPL95: 22nd ACM Symposium on Principles of Programming Languages
    January 23 - 25, 1995
    California, San Francisco, USA

    Acceptance Rates

    Overall Acceptance Rate 824 of 4,130 submissions, 20%

    Upcoming Conference

    POPL '25

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)611
    • Downloads (Last 6 weeks)82

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Outcome Separation Logic: Local Reasoning for Correctness and Incorrectness with Computational EffectsProceedings of the ACM on Programming Languages10.1145/36498218:OOPSLA1(276-304)Online publication date: 29-Apr-2024
    • (2023)From Capabilities to Regions: Enabling Efficient Compilation of Lexical Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228317:OOPSLA2(941-970)Online publication date: 16-Oct-2023
    • (2023)Effect Handlers for Programmable InferenceProceedings of the 16th ACM SIGPLAN International Haskell Symposium10.1145/3609026.3609729(44-58)Online publication date: 30-Aug-2023
    • (2023)Types that Change: The Extensible Type Design PatternProceedings of the 1st ACM SIGPLAN International Workshop on Functional Software Architecture10.1145/3609025.3609475(49-62)Online publication date: 30-Aug-2023
    • (2023)Modular Models of Monoids with OperationsProceedings of the ACM on Programming Languages10.1145/36078507:ICFP(566-603)Online publication date: 31-Aug-2023
    • (2023)Scrambled Features for Breakfast: Concepts of Agile Language DevelopmentCommunications of the ACM10.1145/359621766:11(50-60)Online publication date: 20-Oct-2023
    • (2023)SSProve: A Foundational Framework for Modular Cryptographic Proofs in CoqACM Transactions on Programming Languages and Systems10.1145/359473545:3(1-61)Online publication date: 20-Jul-2023
    • (2023)Outcome Logic: A Unifying Foundation for Correctness and Incorrectness ReasoningProceedings of the ACM on Programming Languages10.1145/35860457:OOPSLA1(522-550)Online publication date: 6-Apr-2023
    • (2023)Hefty Algebras: Modular Elaboration of Higher-Order Algebraic EffectsProceedings of the ACM on Programming Languages10.1145/35712557:POPL(1801-1831)Online publication date: 11-Jan-2023
    • (2023)Towards a Language for Defining Reusable Programming Language ComponentsTrends in Functional Programming10.1007/978-3-031-21314-4_2(18-38)Online publication date: 1-Jan-2023
    • Show More Cited By

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media