Abstract
The use of monads to structure functional programs is described. Monads provide a convenient framework for simulating effects found in other languages, such as global state, exception handling, output, or non-determinism. Three case studies are looked at in detail: how monads ease the modification of a simple evaluator; how monads act as the basis of a datatype of arrays subject to in-place update; and how monads can be used to build parsers.
A previous version of this note appeared in: M. Broy, editor, Program Design Calculi, Proceedings of the Marktoberdorf Summer School, 30 July–8 August 1992.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
S. Abramsky and C. Hankin, Abstract Interpretation of Declarative Languages, Ellis Horwood, 1987.
A. Bloss, Update analysis and the efficient implementation of functional aggregates. In 4 th Symposium on Functional Programming Languages and Computer Architecture, ACM, London, September 1989.
R. Bird and P. Wadler, Introduction to Functional Programming. Prentice Hall, 1987.
P. Hudak, S. Peyton Jones and P. Wadler, editors, Report on the Programming Language Haskell: Version 1.1. Technical report, Yale University and Glasgow University, August 1991.
J.-Y. Girard, Linear logic. Theoretical Computer Science, 50:1–102, 1987.
J. Guzmán and P. Hudak, Single-threaded polymorphic lambda calculus. In IEEE Symposium on Logic in Computer Science, Philadelphia, June 1990.
P. Hudak, A semantic model of reference counting and its abstraction (detailed summary). In ACM Conference on Lisp and Functional Programming, pp. 351–363, Cambridge, Massachusetts, August 1986.
P. Hudak, Continuation-based mutable abstract data types, or how to have your state and munge it too. Technical report YALEU/DCS/RR-914, Department of Computer Science, Yale University, July 1992.
D. King and P. Wadler, Combining monads. In Glasgow Workshop on Functional Programming, Ayr, July 1992. Workshops in Computing Series, Springer Verlag, to appear.
S. Mac Lane, Categories for the Working Mathematician, Springer-Verlag, 1971.
R. Milner, M. Tofte, and R. Harper, The definition of Standard ML. MIT Press, 1990.
E. Moggi, Computational lambda-calculus and monads. In Symposium on Logic in Computer Science, Asilomar, California; IEEE, June 1989. (A longer version is available as a technical report from the University of Edinburgh.)
E. Moggi, An abstract view of programming languges. Course notes, University of Edinburgh.
L. C. Paulson, ML for the Working Programmer. Cambridge University Press, 1991.
S. L. Peyton Jones and P. Wadler, Imperative functional programming. In 20'th Symposium on Principles of Programming Languages, Charleston, South Carolina; ACM, January 1993.
G. Plotkin, Call-by-name, call-by-value, and the λ-calculus. Theoretical Computer Science, 1:125–159, 1975.
J. Rees and W. Clinger (eds.), The revised 3 report on the algorithmic language Scheme. ACM SIGPLAN Notices, 21(12):37–79, 1986.
D. Schmidt, Detecting global variables in denotational specifications. ACM Trans. on Programming Languages and Systems, 7:299–310, 1985.
V. Swarup, U. S. Reddy, and E. Ireland, Assignments for applicative languages. In Conference on Functional Programming Languages and Computer Architecture, Cambridge, Massachusetts; LNCS 523, Springer Verlag, August 1991.
D. A. Turner, An overview of Miranda. In D. A. Turner, editor, Research Topics in Functional Programming. Addison Wesley, 1990.
P. Wadler, Comprehending monads. In Conference on Lisp and Functional Programming, Nice, France; ACM, June 1990.
P.Wadler, Is there a use for linear logic? Conference on Partial Evaluation and Semantics-Based Program Manipulation (PEPM), New Haven, Connecticut; ACM, June 1991.
P. Wadler, The essence of functional programming (invited talk). In 19'th Symposium on Principles of Programming Languages, Albuquerque, New Mexico; ACM, January 1992.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1995 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Wadler, P. (1995). Monads for functional programming. In: Jeuring, J., Meijer, E. (eds) Advanced Functional Programming. AFP 1995. Lecture Notes in Computer Science, vol 925. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-59451-5_2
Download citation
DOI: https://doi.org/10.1007/3-540-59451-5_2
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-59451-2
Online ISBN: 978-3-540-49270-2
eBook Packages: Springer Book Archive