Results 1 - 10
of
12
Introduction to functional programming
, 1995
"... The use of monads to structure functional programs is described. Monads provide a convenient framework for simulating e ects 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 modi cation of ..."
Abstract
-
Cited by 1224 (37 self)
- Add to MetaCart
The use of monads to structure functional programs is described. Monads provide a convenient framework for simulating e ects 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 modi cation 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.
Implicit and Explicit Parallel Programming in Haskell
, 1993
"... Abstract It has often been suggested that functional languages provide an excellent basis for programming parallel computer systems. This is largely a result of the lack of side effects which makes it possible to evaluate the subexpressions of a given term without any risk of interference. On the ot ..."
Abstract
-
Cited by 29 (1 self)
- Add to MetaCart
Abstract It has often been suggested that functional languages provide an excellent basis for programming parallel computer systems. This is largely a result of the lack of side effects which makes it possible to evaluate the subexpressions of a given term without any risk of interference. On the other hand, the lack of side-effects has also been seen as a weakness of functional languages since it rules out many features of traditional imperative languages such as state, I/O and exceptions. These ideas can be simulated in a functional language but the resulting programs are sometimes unnatural and inefficient. On the bright side, recent work has shown how many of these features can be naturally incorporated into a functional language without compromising efficiency by expressing computations in terms of monads or continuations. Unfortunately, the "single-threading " implied by these techniques often destroys many opportunities for parallelism. In this paper, we describe a simple extension to the Haskell I/O monad that allows a form of explicit high-level concurrency. It is a simple matter to incorporate these features in a sequential implementation, and genuine parallelism can be obtained on a parallel machine. In addition, the inclusion of constructs for explicit concurrency enhances the use of Haskell as an executable specification language, since some programs are most naturally described as a composition of parallel processes. \Lambda This research was supported by ARPA via a subcontract to Intermetrics, Inc. 1
A Functional Theory of Local Names
, 1994
"... ## is an extension of the #-calculus with a binding construct for local names. The extension has properties analogous to classical #-calculus and preserves all observational equivalences of #. It is useful as a basis for modeling wide-spectrum languages that build on a functional core. 1 Introducti ..."
Abstract
-
Cited by 27 (2 self)
- Add to MetaCart
## is an extension of the #-calculus with a binding construct for local names. The extension has properties analogous to classical #-calculus and preserves all observational equivalences of #. It is useful as a basis for modeling wide-spectrum languages that build on a functional core. 1 Introduction Recentyears have given us a good deal of theoretical research on the interaction of imperative programming #exempli#ed byvariable assignment# and functional programming #exempli#ed by higher order functions# #3,6,19,21, 24#. The common method of all these works is to propose a #-calculus extended with imperative features and to carry out an exploration of the operational semantics of the new calculus. Based on our own experience in devising such an extended #- calculus #13#, the presentwork singles out the name, whose only observational property is its identity, as an essential componentofany such extension. We present a simple extension of the pure #-calculus with names; we showby ex...
Correctness of Monadic State: An Imperative Call-by-Need Calculus
- In Proc. 25th ACM Symposium on Principles of Programming Languages
, 1998
"... The extension of Haskell with a built-in state monad combines mathematical elegance with operational efficiency: ffl Semantically, at the source language level, constructs that act on the state are viewed as functions that pass an explicit store data structure around. ffl Operationally, at the imp ..."
Abstract
-
Cited by 20 (2 self)
- Add to MetaCart
The extension of Haskell with a built-in state monad combines mathematical elegance with operational efficiency: ffl Semantically, at the source language level, constructs that act on the state are viewed as functions that pass an explicit store data structure around. ffl Operationally, at the implementation level, constructs that act on the state are viewed as statements whose evaluation has the side-effect of updating the implicit global store in place. There are several unproven conjectures that the two views are consistent. Recently, we have noted that the consistency of the two views is far from obvious: all it takes for the implementation to become unsound is one judiciously-placed beta-step in the optimization phase of the compiler. This discovery motivates the current paper in which we formalize and show the correctness of the implementation of monadic state. For the proof, we first design a typed call-by-need language that models the intermediate language of the compiler, to...
Isolating Side Effects in Sequential Languages
- In Proceedings of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’95
, 1995
"... It is well known that adding side effects to functional languages changes the operational equivalences of the language. We develop a new language construct, encap, that forces imperative pieces of code to behave purely functionally, i.e., without any visible side effects. The coercion operator enca ..."
Abstract
-
Cited by 17 (2 self)
- Add to MetaCart
It is well known that adding side effects to functional languages changes the operational equivalences of the language. We develop a new language construct, encap, that forces imperative pieces of code to behave purely functionally, i.e., without any visible side effects. The coercion operator encap provides a means of extending the simple reasoning principles for equivalences of code in a functional language to a language with side effects. In earlier work [36], similar coercion operators were developed, but their correctness required the underlying functional language to include parallel operations. The coercion operators developed here are simpler and are proven correct for purely sequential languages. The sequential setting requires the construction of fully abstract models for sequential call-by-value languages and the formulation of a weak form of "monad" suitable for expressing the semantics of call-by-value languages with side effects. 1 Introduction Two pieces of code are...
Efficient Distributed Memory Implementation of a Data Parallel Functional Language
- in Proceedings of PARLE '94, LNCS 817
, 1994
"... . We discuss why existing implementations of functional languages on MIMD-machines with distributed memory are slow. This is done by comparing the behavior of a functional program with a corresponding Occam program. The main reason is that functional languages give insufficient means to control para ..."
Abstract
-
Cited by 13 (11 self)
- Add to MetaCart
. We discuss why existing implementations of functional languages on MIMD-machines with distributed memory are slow. This is done by comparing the behavior of a functional program with a corresponding Occam program. The main reason is that functional languages give insufficient means to control parallelism and communication. Our approach is to support data parallelism by providing a set of primitives on arrays which allow the user to control the parallelism and communication on a high level, disabling problems like deadlocks. Only one unique version of an array may be referenced at a time. This restriction allows arrays to be updated in place and enables the user to control the space requirements of the program. The uniqueness of arrays is checked by the compiler. Experimental results demonstrate the efficiency of our data parallel functional language. 1 Introduction MIMD machines with distributed memory offer high computation power at relatively low costs. On the other hand, the corr...
Rolling Your Own Mutable ADT --- A Connection between Linear Types and Monads ---
- In Proc. Symp. POPL '97, ACM
, 1997
"... A methodology is described whereby a linear ADT may be rigorously encapsulated within a state monad. A CPS-like translation from the original ADT axioms into monadic ones is also described and proven correct, so that reasoning can be accomplished at the monadic level without exposing the state. The ..."
Abstract
-
Cited by 13 (0 self)
- Add to MetaCart
A methodology is described whereby a linear ADT may be rigorously encapsulated within a state monad. A CPS-like translation from the original ADT axioms into monadic ones is also described and proven correct, so that reasoning can be accomplished at the monadic level without exposing the state. The ADT axioms are suitably constrained by a linear type system to make this translation possible. This constraint also allows the state to be "updated in place," a notion made precise via a graph-rewrite operational semantics. 1 Introduction In recent years, numerous proposals for I/O, destructive updates to data structures, mutable variables, nondeterminism, and concurrency have been put forth, all using monads to structure programs in such a way that details of the computation are effectively hidden and encapsulated [18, 20]. One of the most important uses of monads is in dealing with state, resulting in a style of programming referred to appropriately by Peyton Jones and Wadler as imperativ...
Single-Threaded Objects in ACL2
- Practical Aspects of Declarative Languages (PADL), volume 2257 of LNCS
, 1999
"... ACL2 is a first-order applicative programming language based on Common Lisp. It is also a mathematical logic for which a mechanical theoremprover has been implemented in the style of the Boyer-Moore theorem prover. The ACL2 system is used primarily in the modeling and verification of computer hardwa ..."
Abstract
-
Cited by 9 (2 self)
- Add to MetaCart
ACL2 is a first-order applicative programming language based on Common Lisp. It is also a mathematical logic for which a mechanical theoremprover has been implemented in the style of the Boyer-Moore theorem prover. The ACL2 system is used primarily in the modeling and verification of computer hardware and software, where the executability of the language allows models to be used as prototype designs or "simulators." To support efficient execution of certain kinds of models, especially models of microprocessors, ACL2 provides "single-threaded objects," structures with the usual "copy on write" applicative semantics but for which writes are implemented destructively. Syntactic restrictions insure consistency between the formal semantics and the implementation. The design of single-threaded objects has been influenced both by the need to make execution efficient and the need to make proofs about them simple. We discuss the issues. 1 Background "ACL2" stands for "A Computational Logic for...
Call byName, Assignment and the Lambda Calculus
- In Proc. ACM Symposium on Principles of Programming Languages
, 1992
"... We define an extension of the call-by-name lambda calculus with additional constructs and reduction rules that represent mutable variables and assignments. The extended calculus has neither a concept of an explicit store nor a concept of evaluation order; nevertheless, we show that programs in the c ..."
Abstract
-
Cited by 7 (5 self)
- Add to MetaCart
We define an extension of the call-by-name lambda calculus with additional constructs and reduction rules that represent mutable variables and assignments. The extended calculus has neither a concept of an explicit store nor a concept of evaluation order; nevertheless, we show that programs in the calculus can be implemented using a single-threaded store. We also show that the new calculus has the Church-Rosser property and that it is a conservative extension of classical lambda calculus with respect to operational equivalence; that is, all algebraic laws of the functional subset are preserved. 1 Introduction Are assignments harmful? Common wisdom in the functional programming community has it that they are: seemingly, they destroy referential transparency, they require a determinate evaluation order, and they weaken otherwise powerful type systems such as ML's. Consequently, programming languages with a strong functional orientation often forbid or at least discourage the use of assi...
A Second Year Course on Data Structures Based on Functional Programming
- Nijmegen (The Netherlands
, 1995
"... . In this paper, we make a proposal for a second year course on advanced programming, based on the functional paradigm. It assumes the existence of a first course on programming, also based on functional languages. Its main subject is data structures. We claim that advanced data structures and algo ..."
Abstract
-
Cited by 3 (1 self)
- Add to MetaCart
. In this paper, we make a proposal for a second year course on advanced programming, based on the functional paradigm. It assumes the existence of a first course on programming, also based on functional languages. Its main subject is data structures. We claim that advanced data structures and algorithms can be better taught at the functional paradigm than at the imperative one, and that this can be done without losing efficiency. We also claim that, as a consequence of the higher level of abstraction of functional languages, more subjects can be covered in the given amount of time. In the paper, numerous examples of unusual data structures and algorithms are presented illustrating the contents and the philosophy of the proposed course. 1 Introduction The controversy about the use of a functional language as the first programming language is still alive. Several proposals have been made on a first programming course based on the functional paradigm or on a mixture of the functional a...

