## Experiments With Destructive Updates in a Lazy Functional Language (1994)

Venue: | Computer languages |

Citations: | 3 - 2 self |

### BibTeX

@ARTICLE{Hartel94experimentswith,

author = {Pieter H. Hartel and Willem G. Vree},

title = {Experiments With Destructive Updates in a Lazy Functional Language},

journal = {Computer languages},

year = {1994},

volume = {20},

pages = {20--3}

}

### OpenURL

### Abstract

The aggregate update problem has received considerable attention since pure functional programming languages were recognised as an interesting research topic. There is extensive literature in this area, which proposes a wide variety of solutions. We have tried to apply some of the proposed solutions to our own applications to see how these solutions work in practice. We have been able to use destructive updates but are not convinced that this could have been achieved without application specific knowledge. In particular, no form of update analysis has been reported that is applicable to non-flat domains in polymorphic languages with higher order functions. It is our belief that a refinement of the monolithic approach towards constructing arrays may be a good alternative to using the incremental approach with destructive updates. Keywords: lazy functional languages, array updates, compilation, annotation, measurements. 1 Introduction In a pure functional language it is difficult to im...

### Citations

1313 | Monads for functional programming
- Wadler
- 1993
(Show Context)
Citation Context ... analyses, which all have to work together in harmony to achieve good results. The destructive update problem can be avoided in a number of ways. The two most promising approaches are based on monads =-=[8]-=- or on unique types [9]. Both approaches ultimately use the type system to guarantee that a data structure is single threaded, and that destructive updates are therefore safe. These approaches are int... |

664 |
An algorithm for the machine calculation of complex Fourier series
- Cooley, Tukey
- 1965
(Show Context)
Citation Context ... w = e 2��i=N The N input elements x j are transformed into N output values x 0 j . A straightforward algorithm to compute the discrete Fourier transform would require O(N 2 ) steps. Cooley and Tu=-=key [15]-=- published the fft algorithm, which completes the required calculation in O(N \Theta log N) steps, provided that N is a power of 2. Figure 1 illustrates the data flow when an array of 4 elements is pr... |

261 |
Numerical Recipes: the art of scientific computing (Cambridge Univ
- Press, Flannery, et al.
- 1986
(Show Context)
Citation Context ...the size of the three matrices involved. The destructively updating version of fft uses 977K=8192 �� 119 times more cells than we would like. It should come as no surprise that an implementation i=-=n C [28]-=- is about 100 times faster than our best implementation. To solve this problem, it will be necessary to treat unboxed data, such as complex numbers, as first class citizens. This means that an array o... |

195 | A short cut to deforestation
- Gill, Launchbury, et al.
- 1993
(Show Context)
Citation Context ...en possible to use the monolithic approach at all. The monolithic implementation creates a considerable amount of intermediate list structure, which a good compiler should be able to avoid completely =-=[4, 16]-=-. Unfortunately, the compiler that we have been using (FAST [17]) does not have this capability. The definition of the function reorder has been omitted from the program of Figure 2 as it does not pla... |

102 | Unboxed Values as First Class Citizens in a Non-Strict Functional Language
- Jones, Simon, et al.
- 1991
(Show Context)
Citation Context ..., and so it may generate code that avoids testing at runtime whether the expression has or has not been evaluated. The expressions that are known to be evaluated may be represented as unboxed objects =-=[7]-=-. Expressions that are not known to be evaluated must be represented by boxed objects. An important disadvantage of boxed objects is that they require some extra information, which takes up space. Box... |

79 |
evolution, and application of functional programming languages
- Conception
- 1989
(Show Context)
Citation Context ...al programs using arrays should aim for using monolithic array operations. This is consistent with a commonly accepted preference for the use of higher order functions rather than explicit recursions =-=[6]-=-. Having said this, is the aggregate update problem still a major issue? Unfortunately, the answer is yes. Consider a monolithic array operation that transforms an old array into a new one, for instan... |

67 | A semantic model of reference counting and its abstraction
- Hudak
- 1987
(Show Context)
Citation Context ...mulates the behaviour of an estuary of the North Sea over a number of time steps. The monolithic version of qs is taken from Wadler's paper [11], the incremental version originates from Hudak's paper =-=[12]-=-. The fft and wv programs will be described in the following sections. The array primitives being used are borrowed from the languages Tale [13] and Haskell [14]. Angular brackets are used here to den... |

63 |
editors. Report on the programming language Haskell (Version 1.2
- Hudak, Jones, et al.
- 1992
(Show Context)
Citation Context ... version originates from Hudak's paper [12]. The fft and wv programs will be described in the following sections. The array primitives being used are borrowed from the languages Tale [13] and Haskell =-=[14]-=-. Angular brackets are used here to denote an array thus: ha l : : : a u i. All arrays are accompanied by a descriptor pair (l; u), which holds the lower bound l and the upper bound u of the array. He... |

56 |
Detecting global variables in denotational specifications. ACM transactions on programming languages and systems
- Schmidt
- 1985
(Show Context)
Citation Context ...uction In a pure functional language it is difficult to implement an update on an aggregate data structure in an efficient way. The problem is that unless the aggregate is known to be single threaded =-=[1]-=-, a copy must be made of the entire aggregate, which may then be destructively updated. Otherwise the vitally important referential transparency property is lost. For the sake of definiteness we will ... |

32 | Guaranteeing Safe Destructive Updates through a Type System with Uniqueness Information for Graphs
- Smetsers, Barendsen, et al.
- 1993
(Show Context)
Citation Context ...ve to work together in harmony to achieve good results. The destructive update problem can be avoided in a number of ways. The two most promising approaches are based on monads [8] or on unique types =-=[9]-=-. Both approaches ultimately use the type system to guarantee that a data structure is single threaded, and that destructive updates are therefore safe. These approaches are interesting because no cle... |

31 |
Update analysis and the efficient implementation of functional aggregates
- Bloss
- 1989
(Show Context)
Citation Context ...t, showing on the left the code before and on the right the code after the cheap eagerness optimisation. 2.3 Possible solutions to the suspended subscript problem The update function as used by Bloss =-=[19]-=- is strict in all three arguments, rather than in just the first two as is the case here. Depending on the sophistication of the strictness analyser, this may or may not avoid the problem we are prese... |

23 |
Compilation of Haskell Array Comprehensions for Scientific Computing
- Anderson, Hudak
- 1990
(Show Context)
Citation Context ...tes are impossible with the monolithic approach. Monolithic array operations can be expressed in terms of incremental operations and vice versa, so the expressive power of both approaches is the same =-=[4]-=-. Depending on the implementation, there may be large differences in space and time complexity. The incremental approach is of a lower level whereas the monolithic approach is of a higher level of abs... |

21 |
Design considerations for a parallel reduction machine
- Vree
- 1989
(Show Context)
Citation Context ...a problem such that it can be recognised. These are both hard to achieve. 2.4 Tidal prediction The second example that we will study is a tidal prediction. This program is also based on previous work =-=[22, 23]-=-, which explains in some detail the physical background of the application. To make the present paper reasonably self contained,we discuss the essential aspects of the application domain,which leads t... |

17 | Compilation of functional languages using flow graph analysis. Software—practice and experience
- Hartel, Glaser, et al.
- 1994
(Show Context)
Citation Context ...mplementation creates a considerable amount of intermediate list structure, which a good compiler should be able to avoid completely [4, 16]. Unfortunately, the compiler that we have been using (FAST =-=[17]-=-) does not have this capability. The definition of the function reorder has been omitted from the program of Figure 2 as it does not play a role in the discussion on updating. The interested reader is... |

16 | A New Array Operation
- Wadler
- 1986
(Show Context)
Citation Context ... size N permits O(1) subscript time, and O(N) creation time. The problem is to also implement O(1) update time. There are two basically different ways of using arrays: incrementally or monolithically =-=[3]-=-. When the calculations involved in creating an array follow some kind of regular pattern, a monolithic operation should be appropriate: this creates an entire array in one single operation. When no s... |

11 | Spiking your caches
- Hammond, Burn, et al.
- 1993
(Show Context)
Citation Context ...lemented with destructive updates are always the fastest. There is a relatively large error, of perhaps 50% in time measurements on a complex architecture, such as the SUN SPARC processor with caches =-=[27]-=-. Such large errors arise because small variations in heap size or code size may cause large variations in the effectiveness of the cache and thus in the execution time. Therefore it is safe only to c... |

10 |
The Chalmers Lazy-ML compiler. The computer journal
- Augustsson, Johnsson
- 1989
(Show Context)
Citation Context ...spension of the subscript function and b points at the item to be selected. The arguments of subscript are an array x and an index i. The cheap eagerness optimisation is also used in the LML compiler =-=[21]-=-. Assume that both the array and the index are head normal forms, that is, the index is an integer and the array is a block of memory containing pointers to the actual elements. Whether the array elem... |

9 | Arrays in a lazy functional language – a case study: the fast Fourier transform
- Hartel, Vree
- 1992
(Show Context)
Citation Context ...ram is in updating a large data base. We are well aware of the fact that for many algorithms efficient functional implementations exists that work on lists, as opposed to arrays. In our earlier paper =-=[10]-=- we have investigated a number of different versions of the fast Fourier transform. We found that list based implementations can be efficient, but they are beyond the scope of our present focus on arr... |

9 |
On the benefits of different analyses in the compilation of functional languages
- Hartel, Glaser, et al.
- 1991
(Show Context)
Citation Context ... a sufficiently sophisticated strictness analyser to prove the neededness of x j and x k , but the FAST compiler does not offer this. An alternative approach has been implemented in the FAST compiler =-=[20]-=-. Even with a fairly simple strictness analyser, and when using a version of update that is non-strict in its third argument, it is still possible to use a destructive update. To achieve this, an opti... |

8 |
The grain size of parallel computations in a functional program
- Vree
- 1987
(Show Context)
Citation Context ...a problem such that it can be recognised. These are both hard to achieve. 2.4 Tidal prediction The second example that we will study is a tidal prediction. This program is also based on previous work =-=[22, 23]-=-, which explains in some detail the physical background of the application. To make the present paper reasonably self contained,we discuss the essential aspects of the application domain,which leads t... |

7 |
Arrays in Sisal
- Feo
- 1991
(Show Context)
Citation Context ... construction. A function such as tabulate2 should be capable of applying different functions to different areas of the matrix. This problem is addressed to some extent by the work of the Sisal group =-=[26]-=-, and we think that the monolithic array primitives from Haskell are not adequate. The incremental version transform i uses aimap2 to generate three new matrices u 0 , v 0 and h 0 . Because of the inc... |

6 |
Functional programming and the language Tale
- Barendregt, Leeuwen
- 1985
(Show Context)
Citation Context ..., the incremental version originates from Hudak's paper [12]. The fft and wv programs will be described in the following sections. The array primitives being used are borrowed from the languages Tale =-=[13]-=- and Haskell [14]. Angular brackets are used here to denote an array thus: ha l : : : a u i. All arrays are accompanied by a descriptor pair (l; u), which holds the lower bound l and the upper bound u... |

5 | non-determinism, side-effects, and parallelism: A functional perspective - Arrays - 1986 |

5 |
Storm surge prediction using Kalman filtering
- Heemink
- 1986
(Show Context)
Citation Context ...of the application domain,which leads to a formulation of an almost single threaded implementation. For a comprehensive treatment of the application domain, the reader is referred to Heemink's thesis =-=[24]-=-. The prediction of the tides in the North Sea and its estuaries are based on the shallow water equations. The linearised and slightly simplified versions of these equations [24] are shown below: @u @... |

4 |
der Houwen. Finite difference methods for solving partial differential equations
- van
- 1968
(Show Context)
Citation Context ...is relatively small. A numerical approximation for the partial differential Equations 1--3 is given in the finite difference scheme of Equations 4--6 below. For a formal derivation see van der Houwen =-=[25]-=-. The variables u, v and h in Equations 1--3 are approximated in Equations 4--6 by values u k i;j , v k i;j and h k i;j on a spatial grid at discrete points in time. The grid coordinates are i and j a... |

2 |
Falafel: Arrays in a functional language
- McCrosky, Roy, et al.
- 1990
(Show Context)
Citation Context ... implementations. There are three basic operations to be implemented on arrays: create, subscript and update. An array can be implemented in many ways, but our preferred implementation is a container =-=[2]-=-, which is just a contiguous block of memory. The container holds either the actual array elements, or pointers to the array elements. This depends on the implementation of the functional language. Th... |

2 |
The concatenate vanishes. Internal report, Dept
- Wadler
- 1987
(Show Context)
Citation Context ...ransform (fft) and a tidal prediction program (wv), which simulates the behaviour of an estuary of the North Sea over a number of time steps. The monolithic version of qs is taken from Wadler's paper =-=[11]-=-, the incremental version originates from Hudak's paper [12]. The fft and wv programs will be described in the following sections. The array primitives being used are borrowed from the languages Tale ... |

2 |
The implementation of functional programming languages using custom hardware
- Stoye
- 1985
(Show Context)
Citation Context ...of level i . These two suspensions make it impossible to use destructive updates, because pointers emanating from these suspensions will refer to the array x. This problem has been described by Stoye =-=[18]-=- and some others. We will present a solution that works for the fft program, but unfortunately this solution does not always apply. 1: level i (j; m; n; x) 2: f 3: if (j = N) f 4: return x; 5: g else ... |