Advertisement

LISP and Symbolic Computation

, Volume 8, Issue 4, pp 293–341 | Cite as

State in Haskell

  • John Launchbury
  • Simon L Peyton Jones
Article

Abstract

Some algorithms make critical internal use of updatable state, even though their external specification is purely functional. Based on earlier work on monads, we present a way of securely encapsulating stateful computations that manipulate multiple, named, mutable objects, in the context of a non-strict, purely-functional language. The security of the encapsulation is assured by the type system, using parametricity. The same framework is also used to handle input/output operations (state changes on the external world) and calls to C.

Keywords

Functional programming side-effects types input-output 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Arvind, RS Nikhil & KK Pingali [Oct 1989], “I-structures — data structures for parallel computing,”TOPLAS 11, 598–632.Google Scholar
  2. L Augustsson, M Rittri & D Synek [Jan 1994], “On generating unique names,”Journal of Functional Programming 4, 117–123.Google Scholar
  3. E Barendsen & JEW Smetsers [Dec 1993], “Conventional and uniqueness typing in graph rewrite systems,” inProc 13th Conference on the Foundations of Software Technology and Theoretical Computer Science, Springer Verlag LNCS.Google Scholar
  4. PS Barth, RS Nikhil & Arvind [Sept 1991], “M-structures: extending a parallel, non-strict functional language with state,” inFunctional Programming Languages and Computer Architecture, Boston, Hughes, ed., LNCS 523, Springer Verlag, 538–568.Google Scholar
  5. RS Bird [1984], “Using circular programs to eliminate multiple traversals of data,”Acta Informatica 21, 239–250.Google Scholar
  6. WN Chin [March 1990], “Automatic methods for program transformation,” PhD thesis, Imperial College, London.Google Scholar
  7. DK Gifford & JM Lucassen [Aug 1986], “Integrating functional and imperative programming,” inACM Conference on Lisp and Functional Programming, MIT, ACM, 28–38.Google Scholar
  8. A Gill, J Launchbury & SL Peyton Jones [June 1993], “A short cut to deforestation,” inProc Functional Programming Languages and Computer Architecture, Copenhagen, ACM, 223–232.Google Scholar
  9. CV Hall [June 1994], “Using Hindley-Milner type inference to optimise list representation,” inACM Symposium on Lisp and Functional Programming, Orlando, ACM, 162–172.Google Scholar
  10. P Hancock [1987], “A type checker,” inThe implementation of functional programming languages, SL Peyton Jones, ed., Prentice Hall, 163–182.Google Scholar
  11. John Hughes [Apr 1989], “Why functional programming matters,”The Computer Journal 32, 98–107.Google Scholar
  12. AJ Kfoury [June 1992], “Type reconstruction in finite rank fragments of second-order lambda calculus,”Information and Computation 98, 228–257.Google Scholar
  13. AJ Kfoury & JB Wells [June 1994], “A direct algorithm for type inference in the rank-2 fragment of the second-order lambda calculus,” inACM Symposium on Lisp and Functional Programming, Orlando, ACM, 196–207.Google Scholar
  14. DJ King & J Launchbury [Jan 1995], “Structuring depth-first search algorithms in Haskell,” in21st ACM Symposium on Principles of Programming Languages, San Francisco, ACM.Google Scholar
  15. J Launchbury [June 1993], “Lazy imperative programming,” inProc ACM Sigplan Workshop on State in Programming Languages, Copenhagen (available as YALEU/DCS/RR-968, Yale University), pp46–56.Google Scholar
  16. J Launchbury & SL Peyton Jones [June 1994], “Lazy functional state threads,” inSIGPLAN Symposium on Programming Language Design and Implementation (PLDI'94), Orlando, ACM.Google Scholar
  17. S Marlow & PL Wadler [1993], “Deforestation for higher-order functions,” inFunctional Programming, Glasgow 1992, J Launchbury & PM Sansom, eds., Workshops in Computing, Springer Verlag, 154–165.Google Scholar
  18. NJ McCracken [June 1984], “The typechecking of programs with implicit type structure,” inSemantics of data types, Springer Verlag LNCS 173, 301–315.Google Scholar
  19. R Milner & M Tofte [1990],The definition of Standard ML, MIT Press.Google Scholar
  20. JC Mitchell & AR Meyer [1985], “Second-order logical relations,” inLogics of Programs, R Parikh, ed., Springer Verlag LNCS 193.Google Scholar
  21. E Moggi [June 1989], “Computational lambda calculus and monads,” inLogic in Computer Science, California, IEEE.Google Scholar
  22. Rishiyur Nikhil [March 1988], “Id Reference Manual,” Lab for Computer Science, MIT.Google Scholar
  23. PW O'Hearn & RD Tennent [Jan 1993], “Relational parametricity and local variables,” in20th ACM Symposium on Principles of Programming Languages, Charleston, ACM, 171–184.Google Scholar
  24. M Odersky, D Rabin & P Hudak [Jan 1993], “Call by name, assignment, and the lambda calculus,” in20th ACM Symposium on Principles of Programming Languages, Charleston, ACM, 43–56.Google Scholar
  25. SL Peyton Jones [1987],The Implementation of Functional Programming Languages, Prentice Hall.Google Scholar
  26. SL Peyton Jones [Apr 1992], “Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine,”Journal of Functional Programming 2, 127–202.Google Scholar
  27. SL Peyton Jones & J Launchbury [Sept 1991], “Unboxed values as first class citizens,” inFunctional Programming Languages and Computer Architecture, Boston, Hughes, ed., LNCS 523, Springer Verlag, 636–666.Google Scholar
  28. SL Peyton Jones & PL Wadler [Jan 1993], “Imperative functional programming,” in20th ACM Symposium on Principles of Programming Languages, Charleston, ACM, 71–84.Google Scholar
  29. CG Ponder, PC McGeer & A P-C Ng [June 1988], “Are applicative languages inefficient?,”SIGPLAN Notices 23, 135–139.Google Scholar
  30. JH Reppy [June 1991], “CML: a higher-order concurrent language,” inACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), ACM.Google Scholar
  31. DA Schmidt [Apr 1985], “Detecting global variables in denotational specifications,”TOPLAS 7, 299–310.Google Scholar
  32. V Swarup, US Reddy & E Ireland [Sept 1991], “Assignments for applicative languages,” inFunctional Programming Languages and Computer Architecture, Boston, Hughes, ed., LNCS 523, Springer Verlag, 192–214.Google Scholar
  33. P Thiemann [1993], “Safe Sequencing of Assignments in Purely Functional Programming Languages,” Tech. Report. Wilhelm-Schickard-Institut WSI-93-i6, Tübingen, Germany.Google Scholar
  34. M Tofte [Nov 1990], “Type inference for polymorphic references,”Information and Computation 89.Google Scholar
  35. PL Wadler [1990], “Deforestation: transforming programs to eliminate trees,”Theoretical Computer Science 73, 231–248.Google Scholar
  36. PL Wadler [1992a], “Comprehending monads,”Mathematical Structures in Computer Science 2, 461–493.Google Scholar
  37. PL Wadler [Jan 1992b], “The essence of functional programming,” inProc Principles of Programming Languages, ACM.Google Scholar
  38. PL Wadler [June 1990], “Comprehending monads,” inProc ACM Conference on Lisp and Functional Programming, Nice, ACM.Google Scholar

Copyright information

© Kluwer Academic Publishers 1995

Authors and Affiliations

  • John Launchbury
    • 1
  • Simon L Peyton Jones
    • 2
  1. 1.Oregon Graduate InstitutePortland
  2. 2.University of GlasgowScotland

Personalised recommendations