Streams with a bottom in functional languages

  • Authors:
  • Hideki Tsuiki;Keiji Sugihara

  • Affiliations:
  • Graduate School of Human and Environmental Studies, Kyoto University, Kyoto, Japan;Graduate School of Human and Environmental Studies, Kyoto University, Kyoto, Japan

  • Venue:
  • ESOP'05 Proceedings of the 14th European conference on Programming Languages and Systems
  • Year:
  • 2005

Quantified Score

Hi-index 0.00

Visualization

Abstract

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 [16], 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].