Representing Cyclic Structures as Nested Datatypes

We show that cyclic structures, i.e., finite or possibly infinite structures with backpointers, unwindable into possibly infinite structures, can be elegantly represented as nested datatypes. This representation is free of the various deficiencies characterizing the more naive representation as mixed-variant datatypes. It is inspired by the representation of lambda-terms as a nested datatype via the de Bruijn notation.

[1]  Peter J. Freyd,et al.  Recursive types reduced to inductive types , 1990, [1990] Proceedings. Fifth Annual IEEE Symposium on Logic in Computer Science.

[2]  Graham Hutton,et al.  Bananas in space: extending fold and unfold to exponential types , 1995, FPCA '95.

[3]  Tim Sheard,et al.  Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space) , 1996, POPL '96.

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

[5]  Richard S. Bird,et al.  de Bruijn notation as a nested datatype , 1999, Journal of Functional Programming.

[6]  Thorsten Altenkirch,et al.  Monadic Presentations of Lambda Terms Using Generalized Inductive Types , 1999, CSL.

[7]  Gordon D. Plotkin,et al.  Abstract syntax and variable binding , 1999, Proceedings. 14th Symposium on Logic in Computer Science (Cat. No. PR00158).

[8]  Richard S. Bird,et al.  Generalised folds for nested datatypes , 1999, Formal Aspects of Computing.

[9]  Joe B. Wells,et al.  Cycle therapy: a prescription for fold and unfold on regular trees , 2001, PPDP '01.

[10]  Clare E. Martin,et al.  Disciplined, efficient, generalised folds for nested datatypes , 2004, Formal Aspects of Computing.

[11]  Christoph Lüth,et al.  Monads of coalgebras: rational terms and term graphs , 2005, Math. Struct. Comput. Sci..

[12]  Thorsten Altenkirch,et al.  for Data: Differentiating Data Structures , 2005, Fundam. Informaticae.

[13]  Ralph Matthes,et al.  Iteration and coiteration schemes for higher-order and nested datatypes , 2005, Theor. Comput. Sci..