ABSTRACT
This paper presents a monadic approach to incremental computation, suitable for purely functional languages such as Haskell. A program that uses incremental computation is able to perform an incremental amount of computation to accommodate for changes in input data. Recently, Acar, Blelloch and Harper presented a small Standard ML library that supports efficient, high-level incremental computations [1]. Here, we present a monadic variant of that library, written in Haskell extended with first-class references. By using monads, not only are we able to provide a purely functional interface to the library, the types also enforce "correct usage" without having to resort to any type-system extension. We also find optimization opportunities based on standard monadic combinators.This is an exercise in putting to work monad transformers with environments, references, and continuations.
- U. Acar, G. Blelloch, and R. Harper. Adaptive functional programming. In Principles of Programming Languages (POPL02), Portland, Oregon, January 2002. ACM.]] Google ScholarDigital Library
- L. Augustsson. Cayenne --- a language with dependent types. In Proc. of the International Conference on Functional Programming (ICFP'98). ACM Press, September 1998.]] Google ScholarDigital Library
- M. Carlsson. Adaptive --- incremental computations in Haskell. www.cse.ogi.edu/~magnus/Adaptive/, 2002.]]Google Scholar
- P. F. Dietz and D. D. Sleator. Two algorithms for mainitaining order in a list. In Proceedings. 19th ACM Symposium. Theory of Computing, 1987.]] Google ScholarDigital Library
- The Glasgow Haskell compiler. www.haskell.org/ghc/.]]Google Scholar
- The Hugs 98 interpreter. www.haskell.org/hugs/.]]Google Scholar
- M. P. Jones. Type Classes with Functional Dependencies. In Proceedings of the 9th European Symposiumon Programming, ESOP 2000, number 1782 in LNCS, Berlin, Germany, March 2000. Springer-Verlag.]] Google ScholarDigital Library
- S. P. Jones, M. P. Jones, and E. Meijer. Type classes: exploring the design space. In Haskell Workshop, 1997.]]Google Scholar
- J. Launchbury and S. Peyton Jones. Lazy functional state threads. In ACM Programming Languages Design and Implementation, Orlando, 1994.]] Google ScholarDigital Library
- S. Liang, P. Hudak, and M. P. Jones. Monad transformers and modular interpreters. In Conference Record of POPL'95: 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 333--343, San Francisco, California, Jan. 1995.]] Google ScholarDigital Library
- R. Milner, M. Tofte, R. Harper, and D. MacQueen. The Definition of Standard ML (Revised). MIT Press, 1997.]] Google ScholarDigital Library
- S. Peyton~Jones et al. The Haskell 98 libraries. haskell.org/onlinelibrary/, 1999.]]Google Scholar
- S. Peyton~Jones et al. Report on the programming language Haskell 98, a non-strict, purely functional language. Available from http://haskell.org, February 1999.]]Google Scholar
- T. Sheard. Generic unification via two-level types and parameterized modules. In International Conference on Functional Programming, Florence, Italy, 2001. ACM.]] Google ScholarDigital Library
- M. Shields and S. P. Jones. First class modules for Haskell. In 9th International Conference on Foundations of Object-Oriented Languages (FOOL 9), Portland, Oregon, pages 28--40, Jan. 2002.]]Google Scholar
- P. Wadler. The essence of functional programming. In Proceedings 1992 Symposium on Principles of Programming Languages, pages 1--14, Albuquerque, New Mexico, 1992.]] Google ScholarDigital Library
Index Terms
- Monads for incremental computing
Recommendations
Monads for incremental computing
This paper presents a monadic approach to incremental computation, suitable for purely functional languages such as Haskell. A program that uses incremental computation is able to perform an incremental amount of computation to accommodate for changes ...
DSL implementation using staging and monads
DSL '99: Proceedings of the 2nd conference on Domain-specific languagesThe impact of Domain Specific Languages (DSLs) on software design is considerable. They allow programs to be more concise than equivalent programs written in a high-level programming languages. They relieve programmers from making decisions about data-...
Modeling with monads: extensible modeling semantics as syntactic sugar
EOOLT '16: Proceedings of the 7th International Workshop on Equation-Based Object-Oriented Modeling Languages and ToolsWe present an extensible implementation of Modelica-style modeling semantics. Modeling features are implemented using an intuitive encoding as an extensible state monad. Monadic computation naturally yields model composition and interpretation. This in ...
Comments