Journal article
Turner‚ Bird‚ Eratosthenes: an eternal burning thread
- Abstract:
-
Functional programmers have many things for which to thank the late David Turner: design decisions he made in his languages SASL, KRC, and Miranda over the last 50 years are still influential and inspirational now. In particular, Turner was a strong advocate of lazy evaluation and of list comprehensions. As an illustration of these techniques, he popularized a one-line recursive “sieve” to generate the infinite list of prime numbers.
Turner called this algorithm The Sieve of Eratosthenes. In a lovely paper called “The Genuine Sieve of Eratosthenes”, Melissa O’Neill argued that Turner’s program is not in fact a faithful implementation of the algorithm, and gave a detailed presentation using priority queues of the real thing. She included a variation by Richard Bird, which uses only lists but makes clever use of circular programming. Bird describes his circular program again in his textbook “Thinking Functionally with Haskell”, and sets its proof of correctness as an exercise. In particular, why is this circular program productive? Unfortunately, Bird’s hint for a solution is incorrect. So what should a proof look like?
One of the last projects Turner worked on was the notion of “Total Functional Programming”. He observed that most programs are already structurally recursive or corecursive, therefore guaranteed respectively terminating or productive; he conjectured that “with more practice we will find this is always true”. We explore Bird’s circular Sieve of Eratosthenes as a challenge problem for Turner’s Total Functional Programming.
- Publication status:
- Published
- Peer review status:
- Peer reviewed
Actions
Access Document
- Files:
-
-
(Preview, Version of record, pdf, 177.8KB, Terms of use)
-
- Publisher copy:
- 10.1017/S0956796824000194
Authors
- Publisher:
- Cambridge University Press
- Journal:
- Journal of Functional Programming More from this journal
- Volume:
- 35
- Article number:
- E5
- Publication date:
- 2025-02-05
- Acceptance date:
- 2024-11-18
- DOI:
- EISSN:
-
1469-7653
- ISSN:
-
0956-7968
- Language:
-
English
- Pubs id:
-
2083021
- Local pid:
-
pubs:2083021
- Deposit date:
-
2025-02-03
Terms of use
- Copyright holder:
- Jeremy Gibbons
- Copyright date:
- 2025
- Rights statement:
- © The Author(s), 2025. Published by Cambridge University Press. This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by-nc-sa/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
If you are the owner of this record, you can report an update to it here: Report update to this record