Streams with a Bottom in Functional Languages
When an infinite sequence contains a bottom cell, we cannot access the rest of the sequence with the ordinary stream access. On the other hand, when we consider an extended stream access with two heads, we can read or write 1\(\bot\)-sequences, which are infinite sequences with at most one bottom cell. In this paper, we present a way of extending a lazy functional language with such an extended stream access in the realm of sequential computation. It has an application in real number computation in that the set of real numbers is topologically embedded in the set of 1 \(\bot\)-sequences , and therefore we can consider a program with such an extended stream access as directly manipulating real numbers. We implemented this mechanism by modifying the runtime of the Hugs system, which is a graph-reduction based implementation of the Haskell language. We present programming examples like addition and multiplication on real numbers in this extended Haskell.
For this implementation, we extended Haskell with the gamb operator, which works just as McCarthy’s bottom-avoiding nondeterministic choice operator “amb”. The difference is that it is realized in the realm of sequential computation, and that it is applicable only when the graph representations of the arguments share the same redex. In order to show that programs corresponding to two-head stream accesses satisfy this condition, we introduce a PCF-based calculus of term-graphs and define a data-type of 1 \(\bot\)-streams as a subtype of [Bool].
- 1.Ariola, Z., Felleisen, M., Maraist, J., Odersky, M., Wadler, P.: A Call-by-Need Lambda Calculus. In: Proc. POPL 1995, 22’nd Annual Symposium on Principles of Programming Languages, San Francisco, California, pp. 233–246 (1995)Google Scholar
- 2.Du Bois, A., Pointon, R., Loidl, H.-W., Trinder, P.: Implementing Declarative Parallel Bottom-Avoiding Choice. In: Proc. 14th Symposium on Computer Architecture and High Performance Computing (2002)Google Scholar
- 3.Escardó, M.H., Hofmann, M., Streicher, T.: On the non-sequential nature of the interval-domain model of exact real-number computation. Mathematical Structures in Computer Science (to appear)Google Scholar
- 5.Gray, F.: Pulse code communications. U. S. Patent 2632058 (March 1953)Google Scholar
- 6.Jones, M.P.: The implementation of the Gofer functional programming system. Research Report YALEU/DCS/RR-1030, Yale University, USA (1994)Google Scholar
- 8.Jones, S.P. (ed.): Haskell 98 Language and Libraries, The Revised Report. Cambridge University Press, Cambridge (2003)Google Scholar
- 9.Kennaway, J.R., Klop, J.W., Sleep, M.R., de Vries, F.J.: An Introduction to Term Graph Rewriting. In: Google Scholar
- 10.Raymundo Marcial-Romero, J., Escardó, M.H.: Semantics of a Sequential Language for Exact Real-Number Computation. In: Proceedings of the Annual IEEE Symbposium on Logic in Computer Science, pp. 426–435 (2004)Google Scholar
- 12.Hughes, J., Moran, A.: Making Choices Lazily. In: Conference Record of FPCA 1995, pp. 108–119. ACM Press, New York (1995)Google Scholar
- 13.Rose, K.H.: Graph-based Operational Semantics of a Lazy Functional Language. In: Google Scholar
- 17.Tsuiki, H.: Real Number Computation with Committed Choice Logic Programming. Journal of Logic and Algebraic Programming (2004) (to appear)Google Scholar