## Representing Cyclic Structures as Nested Datatypes

Citations: | 5 - 0 self |

### BibTeX

@MISC{Ghani_representingcyclic,

author = {Neil Ghani and Makoto Hamana and Tarmo Uustalu and Varmo Vene},

title = {Representing Cyclic Structures as Nested Datatypes},

year = {}

}

### OpenURL

### Abstract

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

### Citations

142 |
Abstract syntax and variable binding
- Fiore, Plotkin, et al.
- 1999
(Show Context)
Citation Context ...mbda-terms can be represented as a nested datatype was observed by Bird and Paterson [7] and Altenkirch and Reus [3]; the mathematical account in terms of presheaves is due to Fiore, Plotkin and Turi =-=[9]-=-. Structured recursion/corecursion for nested datatypes has been investigated by Bird, Meertens and Paterson [5, 6], Martin, Gibbons and Bayley [4], and Abel, Matthes and Uustalu [2]. Organization In ... |

95 | Bananas in Space: Extending Fold and Unfold to Exponential Types
- Meijer, Hutton
- 1995
(Show Context)
Citation Context ...Nil cmap g (Cons x xs) = Cons (g x) (cmap g xs) cmap g (Rec f) = cmap g (f (Rec f)) (These function definitions can be justified in terms of structured recursion for mixed-variant datatypes, see e.g. =-=[13, 8]-=-, but we will not so here.) In addition to this drawback, the approach has further shortcomings. First, the use of mixed-variant datatypes means that the semantic category has to be algebraically comp... |

79 | Nested datatypes
- BIRD, MEERTENS
- 1998
(Show Context)
Citation Context ... [3]; the mathematical account in terms of presheaves is due to Fiore, Plotkin and Turi [9]. Structured recursion/corecursion for nested datatypes has been investigated by Bird, Meertens and Paterson =-=[5, 6]-=-, Martin, Gibbons and Bayley [4], and Abel, Matthes and Uustalu [2]. Organization In Sec. 2, we discuss cyclic lists. We begin by outlining Fegaras and Sheard’s representation and highlighting its sho... |

77 | Monadic presentations of lambda terms using generalized inductive types
- Altenkirch, Reus
- 1999
(Show Context)
Citation Context ...d some combinators for working with that representation. That de Bruijn notations of lambda-terms can be represented as a nested datatype was observed by Bird and Paterson [7] and Altenkirch and Reus =-=[3]-=-; the mathematical account in terms of presheaves is due to Fiore, Plotkin and Turi [9]. Structured recursion/corecursion for nested datatypes has been investigated by Bird, Meertens and Paterson [5, ... |

68 | R.: De Bruijn notation as a nested datatype
- Bird, Paterson
- 1999
(Show Context)
Citation Context ...ger identifier, and developed some combinators for working with that representation. That de Bruijn notations of lambda-terms can be represented as a nested datatype was observed by Bird and Paterson =-=[7]-=- and Altenkirch and Reus [3]; the mathematical account in terms of presheaves is due to Fiore, Plotkin and Turi [9]. Structured recursion/corecursion for nested datatypes has been investigated by Bird... |

68 |
Recursive types reduced to induct,ive types
- Freyd
- 1990
(Show Context)
Citation Context ...t we will not so here.) In addition to this drawback, the approach has further shortcomings. First, the use of mixed-variant datatypes means that the semantic category has to be algebraically compact =-=[10]-=-, i.e., a category where inductive and coinductive types coincide. Categories like Set are ruled out immediately and one needs something like CPO. This makes the reasoning more complex. Second, and mo... |

54 | Revisiting catamorphism over datatypes with embedded functions
- Fegaras, Sheard
- 1996
(Show Context)
Citation Context ...it representation and manipulation of cyclic datastructures in a systematic fashion. The central for us idea of pointers as variables bound at the pointed position was pioneered by Fegaras and Sheard =-=[8]-=-. But they chose to represent variable binding via higher-type dataconstructors as in higher-order abstract syntax, relying on mixed-variant datatypes. This representation suffers from multiple drawba... |

36 | The derivative of a regular type is its type of one-hole contexts. Unpublished manuscript (2001
- McBride
- 2012
(Show Context)
Citation Context ...t They also have a coalgebra structure, but to describe this, we need to be able to work with contexts of positions in a depth-one structure in a general manner. This is achieved by using derivatives =-=[12, 1]-=-. In Generic Haskell, it would be possible to define the derivative of a regular functor by structural recursion over the expression for that functor. Here we take a simpler and more manual approach. ... |

34 | Generalised folds for nested datatypes
- Bird, Paterson
- 1999
(Show Context)
Citation Context ... [3]; the mathematical account in terms of presheaves is due to Fiore, Plotkin and Turi [9]. Structured recursion/corecursion for nested datatypes has been investigated by Bird, Meertens and Paterson =-=[5, 6]-=-, Martin, Gibbons and Bayley [4], and Abel, Matthes and Uustalu [2]. Organization In Sec. 2, we discuss cyclic lists. We begin by outlining Fegaras and Sheard’s representation and highlighting its sho... |

12 | Iteration and coiteration schemes for higher-order and nested datatypes
- Abel, Matthes, et al.
- 2005
(Show Context)
Citation Context ... Plotkin and Turi [9]. Structured recursion/corecursion for nested datatypes has been investigated by Bird, Meertens and Paterson [5, 6], Martin, Gibbons and Bayley [4], and Abel, Matthes and Uustalu =-=[2]-=-. Organization In Sec. 2, we discuss cyclic lists. We begin by outlining Fegaras and Sheard’s representation and highlighting its shortcomings. Then we proceed to our own proposal, deriving it by smal... |

7 | D for data: Differentiating data structures
- Abbott, Altenkirch, et al.
- 2004
(Show Context)
Citation Context ...t They also have a coalgebra structure, but to describe this, we need to be able to work with contexts of positions in a depth-one structure in a general manner. This is achieved by using derivatives =-=[12, 1]-=-. In Generic Haskell, it would be possible to define the derivative of a regular functor by structural recursion over the expression for that functor. Here we take a simpler and more manual approach. ... |

4 | I.: Disciplined, efficient, generalised folds for nested datatypes
- Martin, Gibbons, et al.
- 2004
(Show Context)
Citation Context ...erms of presheaves is due to Fiore, Plotkin and Turi [9]. Structured recursion/corecursion for nested datatypes has been investigated by Bird, Meertens and Paterson [5, 6], Martin, Gibbons and Bayley =-=[4]-=-, and Abel, Matthes and Uustalu [2]. Organization In Sec. 2, we discuss cyclic lists. We begin by outlining Fegaras and Sheard’s representation and highlighting its shortcomings. Then we proceed to ou... |

1 |
de Marchi, F.: Monads of coalgebras: rational terms and term graphs
- Ghani, Lüth
- 2005
(Show Context)
Citation Context ...from the path from the root. And we also want to develop a categorical account of the cyclic representations of rational and coinductive types, building on the groundwork by Ghani, Lüth and de Marchi =-=[11]-=-.sAcknowledgements We are grateful to Zhenjiang Hu for motivating this work. Makoto Hamana was partially supported by the JSPS Grant-in-Aid for Scientific Research No. 16700005. Tarmo Uustalu and Varm... |

1 |
Cycletherapy: A prescription of fold and unfold on regular trees
- Turbak, Wells
- 2001
(Show Context)
Citation Context ...ntation suffers from multiple drawbacks, the most serious being that almost all useful functions manipulating cyclic lists must unwind them anyway, despite the cycles being explicit. Turbak and Wells =-=[14]-=- have defined a rather low-level representation, where every node in a structure gets a unique integer identifier, and developed some combinators for working with that representation. That de Bruijn n... |