The Essence of the Iterator Pattern
The Iterator pattern gives a clean interface for element-by-element access to a collection. Imperative iterations using the pattern have two simultaneous aspects: <em>mapping</em> and <em>accumulating</em>. Various existing functional iterations model one or other of these, b...
Main Authors: | , |
---|---|
Format: | Journal article |
Published: |
2009
|
_version_ | 1826283163206287360 |
---|---|
author | Gibbons, J Oliveira, B |
author_facet | Gibbons, J Oliveira, B |
author_sort | Gibbons, J |
collection | OXFORD |
description | The Iterator pattern gives a clean interface for element-by-element access to a collection. Imperative iterations using the pattern have two simultaneous aspects: <em>mapping</em> and <em>accumulating</em>. Various existing functional iterations model one or other of these, but not both simultaneously. We argue that McBride and Paterson's <em>applicative functors</em>, and in particular the corresponding <em>traverse</em> operator, do exactly this, and therefore capture the essence of the Iterator pattern. We present some axioms for traversal, and illustrate with a simple example, the <em>wordcount</em> problem. |
first_indexed | 2024-03-07T00:54:46Z |
format | Journal article |
id | oxford-uuid:87a8d92c-017c-4b3f-89a1-ac3056ad51d7 |
institution | University of Oxford |
last_indexed | 2024-03-07T00:54:46Z |
publishDate | 2009 |
record_format | dspace |
spelling | oxford-uuid:87a8d92c-017c-4b3f-89a1-ac3056ad51d72022-03-26T22:12:08ZThe Essence of the Iterator PatternJournal articlehttp://purl.org/coar/resource_type/c_dcae04bcuuid:87a8d92c-017c-4b3f-89a1-ac3056ad51d7Department of Computer Science2009Gibbons, JOliveira, BThe Iterator pattern gives a clean interface for element-by-element access to a collection. Imperative iterations using the pattern have two simultaneous aspects: <em>mapping</em> and <em>accumulating</em>. Various existing functional iterations model one or other of these, but not both simultaneously. We argue that McBride and Paterson's <em>applicative functors</em>, and in particular the corresponding <em>traverse</em> operator, do exactly this, and therefore capture the essence of the Iterator pattern. We present some axioms for traversal, and illustrate with a simple example, the <em>wordcount</em> problem. |
spellingShingle | Gibbons, J Oliveira, B The Essence of the Iterator Pattern |
title | The Essence of the Iterator Pattern |
title_full | The Essence of the Iterator Pattern |
title_fullStr | The Essence of the Iterator Pattern |
title_full_unstemmed | The Essence of the Iterator Pattern |
title_short | The Essence of the Iterator Pattern |
title_sort | essence of the iterator pattern |
work_keys_str_mv | AT gibbonsj theessenceoftheiteratorpattern AT oliveirab theessenceoftheiteratorpattern AT gibbonsj essenceoftheiteratorpattern AT oliveirab essenceoftheiteratorpattern |