Abstract:
This paper describes a general framework for designing purely functional datatypes that automatically satisfy given size or structural constraints. Using the framework we develop implementations of different matrix types (eg square matrices) and implementations of several tree types (eg Braun trees, 2-3 trees). Consider, for instance, representing square n \Theta n matrices. The usual representation using lists of lists fails to meet the structural constraints: there is no way to ensure that the outer list and the inner lists have the same length. The main idea of our approach is to solve in a first step a related, but simpler problem, namely to generate the multiset of all square numbers. In order to describe this multiset we employ recursion equations involving finite multisets, multiset union, addition and multiplication lifted to multisets. In a second step we mechanically derive datatype definitions from these recursion equations which enforce the `squareness ' constraint. The transformation makes essential use of polymorphic types. Die ganze Zahl schuf der liebe Gott, alles Ubrige ist Menschenwerk.
Citations
|
5955
|
Introduction to algorithms
– Cormen, Leiserson, et al.
- 2001
|
|
604
|
Data Structures and Algorithms
– Aho, Hopcroft, et al.
- 1987
|
|
154
|
Purely functional data structures
– Okasaki
- 1521
|
|
96
|
98 - A non-strict, purely functional language. Available fromhttp://www.haskell.org/onlinereport
– Jones
- 1999
|
|
65
|
The algebra of programming
– Bird, Moor
- 1997
|
|
55
|
Functional Programming with Overloading and HigherOrder Polymorphism
– Jones
- 1995
|
|
26
|
An algorithm for the organization of information. Dokladi Akademia Nauk SSSR
– Adelson-Velskii, Landis
- 1962
|
|
26
|
From fast exponentiation to square matrices: An adventure in types
– Okasaki
- 1999
|
|
15
|
Polytypic functions over nested datatypes
– Hinze
- 1999
|
|
12
|
A logarithmic implementation of flexible arrays. Memorandum MR83/4
– Braun, Rem
- 1983
|
|
8
|
Nested datatypes. Pages 52--67
– Bird
- 1998
|
|
8
|
international conference on mathematics of program construction
– Fourth
|
|
8
|
A simple, efficient, and flexible implementation of flexible arrays. Pages 232--241 of: Third international conference on mathematics of program construction
– Dielissen
- 1995
|
|
7
|
Numerical Representations as Higher-Order Nested Datatypes
– Hinze
- 1998
|
|
3
|
Perfect trees and bit-reversal permutations
– Hinze
- 1999
|
|
2
|
A diochromatic framework for balanced trees. Pages 8--21 of
– Guibas
- 1978
|