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: mapping and accumulating. Various existing functional iterations model one or other of these, but not both simultaneously. We argue that McBride and Paterson's idioms, and in particular the corresponding traverse 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 repmin problem.

[1]  Philip Wadler Monads for Functional Programming , 1995, Advanced Functional Programming.

[2]  Brian W. Kernighan,et al.  The C Programming Language , 1978 .

[3]  Xavier Leroy,et al.  Applicative functors and fully transparent higher-order modules , 1995, POPL '95.

[4]  Philip Wadler,et al.  Once upon a type , 1995, FPCA '95.

[5]  Thomas Kühne,et al.  Internal Iteration Externalized , 1999, ECOOP.

[6]  José Nuno Oliveira,et al.  Reverse program calculation supported by code slicing , 2001, Proceedings Eighth Working Conference on Reverse Engineering.

[7]  Richard S. Bird,et al.  Nested Datatypes , 1998, MPC.

[8]  Johan Jeuring,et al.  PolyP—a polytypic programming language extension , 1997, POPL '97.

[9]  Norman Ramsey,et al.  Advanced Functional Programming , 2005 .

[10]  Paul Steckler,et al.  The Functional Imperative: Shape! , 1998, ESOP.

[11]  C. Barry Jay,et al.  Monads, shapely functors, and traversals , 1999, CTCS.

[12]  Keith Brian Gallagher,et al.  Using Program Slicing in Software Maintenance , 1991, IEEE Trans. Software Eng..

[13]  Jeremy Gibbons,et al.  Fission for Program Comprehension , 2006, MPC.

[14]  Philip Wadler,et al.  Combining Monads , 1992 .

[15]  Oege de Moor,et al.  The Fun of Programming , 2003 .

[16]  Valeri Kuznecov Merging Monads and Folds for Functional Programming , 2004 .

[17]  Daniel Fridlender,et al.  Do we need dependent types? , 2000, Journal of Functional Programming.

[18]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

[19]  Philip Wadler,et al.  Glasgow Workshop on Functional Programming , 1992 .

[20]  Simon L. Peyton Jones,et al.  Derivable Type Classes , 2001, Haskell.

[21]  Lambert G. L. T. Meertens Calculate Polytypically! , 1996, PLILP.

[22]  Simon L. Peyton Jones,et al.  Imperative functional programming , 1993, POPL '93.

[23]  Richard S. Bird Using circular programs to eliminate multiple traversals of data , 2004, Acta Informatica.

[24]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[25]  Ralf Lämmel,et al.  Haskell's overlooked object system , 2005, ArXiv.

[26]  C. Barry Jay,et al.  A Semantics for Shape , 1995, Sci. Comput. Program..

[27]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[28]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[29]  B. Eckmann,et al.  Seminar on triples and categorical homology theory : ETH, 1966-67 , 1969 .

[30]  Jeremy Gibbons Generic Programming , 2003, Lecture Notes in Computer Science.

[31]  GibbonsJeremy,et al.  The essence of the iterator pattern , 2009 .

[32]  John Hughes,et al.  Why Functional Programming Matters , 1989, Comput. J..

[33]  Jeremy Gibbons,et al.  Calculating Functional Programs , 2000, Algebraic and Coalgebraic Methods in the Mathematics of Program Construction.

[34]  Maarten M. Fokkinga Monadic Maps and Folds for Arbitrary Datatypes , 1994 .

[35]  Johan Jeuring,et al.  Polytypic data conversion programs , 2002, Sci. Comput. Program..

[36]  Maarten M. Fokkinga,et al.  Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire , 1991, FPCA.

[37]  Ralf Hinze,et al.  Generic Haskell: Practice and Theory , 2003, Generic Programming.

[38]  John Launchbury,et al.  Advanced Functional Programming , 1995, Lecture Notes in Computer Science.

[39]  Maarten M. Fokkinga Tupling and Mutumorphisms , 1989 .

[40]  Conor McBride,et al.  Applicative programming with effects , 2008, J. Funct. Program..

[41]  Mark P. Jones,et al.  Functional Programming with Overloading and Higher-Order Polymorphism , 1995, Advanced Functional Programming.

[42]  Alberto Pardo Combining Datatypes and Effects , 2004, Advanced Functional Programming.

[43]  Joyce L. Vedral,et al.  Functional Programming Languages and Computer Architecture , 1989, Lecture Notes in Computer Science.

[44]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[45]  Jeremy Gibbons,et al.  Design patterns as higher-order datatype-generic programs , 2006, WGP '06.

[46]  Graham Hutton,et al.  When is a function a fold or an unfold? , 2001, CMCS.

[47]  Roland Carl Backhouse,et al.  Algebraic and Coalgebraic Methods in the Mathematics of Program Construction , 2000, Lecture Notes in Computer Science.