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

Representing monads

Published: 01 February 1994 Publication History

Abstract

We show that any monad whose unit and extension operations are expressible as purely functional terms can be embedded in a call-by-value language with “composable continuations”. As part of the development, we extend Meyer and Wand's characterization of the relationship between continuation-passing and direct style to one for continuation-passing vs. general “monadic” style. We further show that the composable-continuations construct can itself be represented using ordinary, non-composable first-class continuations and a single piece of state. Thus, in the presence of two specific computational effects - storage and escapes - any expressible monadic structure (e.g., nondeterminism as represented by the list monad) can be added as a purely definitional extension, without requiring a reinterpretation of the whole language. The paper includes an implementation of the construction (in Standard ML with some New Jersey extensions) and several examples.

References

[1]
Andrew W. Appel and David B. MacQueen. Standard ML of New Jersey. in Third international Symposium on Programming Language implementation and Logic Programming, number 528 in Lecture Notes in Computer Science, pages 1-13, Passau, Germany, August 1991.
[2]
William Clinger and Jonathan Rees. Revised4 report on the algorithmic language Scheme. Lisp Pointers, 4(3):1-55, July 1991.
[3]
Olivier Danvy and Andrzej Filinski. Abstracting control. In Proceedings of the 1990 A CM Conference on Lisp and Functional Programming, pages 151-160, Nice, France, June 1990.
[4]
Olivier Danvy and Andrzej Filinski. Representing control: A study of the CPS transformation. Mathematical Structures in Computer Science, 2(4):361- 391, December 1992.
[5]
Bruce F. Duba, Robert Harper, and David Mac- Queen. Typing first-class continuations in ML. In Proceedings of the Eighteenth Annual A CM Symposium on Principles of Programming Languages, pages 163-173, Orlando, Florida, January 1991.
[6]
Matthias Felleisen. The theory and practice of firstclass prompts, in Proceedings of the Fifteenth Annual A CM Symposium on Principles of Programming Languages, pages 180-190, San Diego, California, January 1988.
[7]
Matthias Felleisen and Robert Hieb. The revised report on the syntactic theories of sequential control and state. Theoretical Computer Science, 103(2):235-271, September 1992.
[8]
Matthias Felleisen, Mitchell Wand, Daniel P. Friedman, and Bruce F. Duba. Abstract continuations: A mathematical semantics for handling full functional jumps. In Proceedings of the 1988 A CM Conference on Lisp and Functional Programming, pages 52-62, Snowbird, Utah, July 1988.
[9]
Robert Hieb, R. Kent Dybvig, and Carl Bruggeman. Representing control in the presence of firstclass continuations, in Proceedings of the A CM SIGPLAN '90 Conference on Programming Languages Design and Implementation, pages 66-77, White Plains, New York, June 1990.
[10]
Gregory F. Johnson and Dominic Duggan. Stores and partial continuations as first-class objects in a language and its environment. In Proceedings of the Fifteenth Annual A CM Symposium on Principles of Programming Languages, pages 158-168, San Diego, California, january 1988.
[11]
David J. King and Philip Wadler. Combining monads. In J. Launchbury and P. M. Sansom, editors, Functional Programming, Glasgow 1992, pages 134-143, Ayr, Scotland, 1993. Springer- Verlag.
[12]
Julia L. Lawall and Olivier Danvy. Continuationbased partial evaluation. Indiana University and Aarhus University. Personal communication, October 1993.
[13]
Albert R. Meyer and Mitchell Wand. Continuation semantics in typed lambda-calculi (summary). In Rohit Parikh, editor, Logics of Programs - Proceedings, number 193 in Lecture Notes in Computer Science, pages 219-224, Brooklyn, June 1985.
[14]
Eugenio Moggi. Computational lambda-calculus and monads, in Proceedings of ~he Fourth Annual Symposium on Logic in Computer Science, pages 14-23, Pacific Grove, California, June 1989. IEEE.
[15]
Eugenio Moggi. An abstract view of programming languages. Technical Report ECS-LFCS-90- 113, Laboratory for Foundations of Computer Science, University of Edinburgh, Edinburgh, Scotland, April 1990.
[16]
Eugenio Moggi. Notions of computation and monads. Information and Computation, 93(1):55-92, July 1991.
[17]
Chetan R. Murthy. Control operators, hierarchies, and pseudo-classical type systems" A-translation at work. In Proceedings of the A CM SIGPLAN Workshop on Continuations, pages 49-71, San Francisco, California, June 1992. (Technical Report No. STAN-CS-92-1426, Department of Computer Science, Stanford University).
[18]
Simon L. Peyton Jones and Philip Wadler. Imperative functional programming. In Proceedings of the Twentieth Annual A CM Symposium on Principles of Programming Languages, pages 71-84, Charleston, South Carolina, January 1993.
[19]
Gordon D. Plotkin. Call-by-name, call-by-value and the,~-calculus. Theoretical Computer Science, 1(2):125-159, December 1975.
[20]
Christian Queinnec and Bernard Serpette. A dynamic extent control operator for partial continuations. In Proceedings of the Eighteenth Annual A CM Symposium on Principles of Programming Languages, pages 174-184, Orlando, Florida, January 1991.
[21]
John H. Reppy. CML: A higher-order concurrent language. In Proceedings of the A CM SIGPLAN '91 Conference on Programming Language Design and Implementation, pages 293-305, Toronto, Canada, June 1991.
[22]
john C. Reynolds. On the relation between direct and continuation semantics. In Jacques Loeckx, editor, 2nd Colloquium on Automata, Languages and Programming, number 14 in Lecture Notes in Computer Science, pages 141-156, Saarbriicken, West Germany, July 1974.
[23]
:Ion G. Riecke. Delimiting the scope of effects. In Functional Programming Languages and Computer Architecture 1993, pages 146-155, Copenhagen, Denmark, June 1993. ACM Press.
[24]
Amr Sabry and Matthias Felleisen. Reasoning about programs in continuation-passing style, in Proceedings of the 1992 A CM Conference on Lisp and Functional Programming, pages 288-298, San Francisco, California, june 1992. Revised version to appear in Lisp and Symbolic Computation.
[25]
Ravi Sethi and Adrian Tang. Constructing call-byvalue continuation semantics. Journal of the A CM, 27(3):580-597, july 1980.
[26]
Dorai Sitaram and Matthias Felleisen. Control delimiters and their hierarchies. Lisp and Symbolic Computation, 3(1):67-99, January 1990.
[27]
Dorai Sitaram and Matthias Felleisen. Reasoning with continuations II: Full abstraction for models of control. In Proceedings of the 1990 A CM Conference on Lisp and Functional Programming, pages 161-175, Nice, France, June 1990.
[28]
Brian C. Smith. Reflection and Semantics in a Procedural Language. PhD thesis, Massachusetts Institute of Technology, Cambridge, Massachusetts, January 1982. MIT-LCS-TR-272.
[29]
Guy L. Steele, Jr. Building interpreters by composing monads. In Proceedings of the Twenty.First An. anal A CM Symposium on Principles of Programming Languages, Portland, Oregon, January 1994. (To appear).
[30]
Joseph E. Stoy. The congruence of two programming language definitions. Theoretical Computer Science, 13(2):151-174, February 1981.
[31]
Philip Wadler. Comprehending monads. Mathematical Structures in Computer Science, 2(4):461- 493, December 1992. (An earlier version appeared in Proceedings of the 1990 A CM Conference on Lisp and Functional Programming).
[32]
Philip Wadler. The essence of functional programming (invited talk). In Proceedings of the Nineteenth Annual A CM Symposium on Principles of Programming Languages, pages 1-14, Albuquerque, New Mexico, January 1992.
[33]
Philip Wadler. Monads and eomposable continuations. Lisp and Symbolic Computation, 1994. (To appear).
[34]
Mitchell Wand and Daniel P. Friedman. The mystery of the tower revealed: A non-reflective description of the reflective tower. Lisp and Symbolic Computation, 1(1), May 1988.

Cited By

View all
  • (2023)Typed Equivalence of Labeled Effect Handlers and Labeled Delimited Control OperatorsProceedings of the 25th International Symposium on Principles and Practice of Declarative Programming10.1145/3610612.3610616(1-13)Online publication date: 22-Oct-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)PureCake: A Verified Compiler for a Lazy Functional LanguageProceedings of the ACM on Programming Languages10.1145/35912597:PLDI(952-976)Online publication date: 6-Jun-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
POPL '94: Proceedings of the 21st ACM SIGPLAN-SIGACT symposium on Principles of programming languages
February 1994
492 pages
ISBN:0897916360
DOI:10.1145/174675
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: 01 February 1994

Permissions

Request permissions for this article.

Check for updates

Qualifiers

  • Article

Conference

POPL94

Acceptance Rates

POPL '94 Paper Acceptance Rate 39 of 173 submissions, 23%;
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)596
  • Downloads (Last 6 weeks)54
Reflects downloads up to 13 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (2023)Typed Equivalence of Labeled Effect Handlers and Labeled Delimited Control OperatorsProceedings of the 25th International Symposium on Principles and Practice of Declarative Programming10.1145/3610612.3610616(1-13)Online publication date: 22-Oct-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)PureCake: A Verified Compiler for a Lazy Functional LanguageProceedings of the ACM on Programming Languages10.1145/35912597:PLDI(952-976)Online publication date: 6-Jun-2023
  • (2023)Temporal Verification with Answer-Effect Modification: Dependent Temporal Type-and-Effect System with Delimited ContinuationsProceedings of the ACM on Programming Languages10.1145/35712647:POPL(2079-2110)Online publication date: 11-Jan-2023
  • (2022)Random testing of a higher-order blockchain language (experience report)Proceedings of the ACM on Programming Languages10.1145/35476536:ICFP(886-901)Online publication date: 31-Aug-2022
  • (2021)Reflecting Stacked Continuations in a Fine-Grained Direct-Style Reduction TheoryProceedings of the 23rd International Symposium on Principles and Practice of Declarative Programming10.1145/3479394.3479399(1-13)Online publication date: 6-Sep-2021
  • (2021)On continuation-passing transformations and expected cost analysisProceedings of the ACM on Programming Languages10.1145/34735925:ICFP(1-30)Online publication date: 19-Aug-2021
  • (2021)Deadlock-free session types in linear HaskellProceedings of the 14th ACM SIGPLAN International Symposium on Haskell10.1145/3471874.3472979(1-13)Online publication date: 18-Aug-2021
  • (2021)Smart choices and the selection monadProceedings of the 36th Annual ACM/IEEE Symposium on Logic in Computer Science10.1109/LICS52264.2021.9470641(1-14)Online publication date: 29-Jun-2021
  • (2021)GATE: Gradual Effect TypesLeveraging Applications of Formal Methods, Verification and Validation10.1007/978-3-030-89159-6_21(335-345)Online publication date: 12-Oct-2021
  • 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