## Deriving animations from recursive definitions (2002)

Venue: | In Draft Proceedings of the 14th International Workshop on the Implementation of Functional Languages (IFL’02 |

Citations: | 2 - 1 self |

### BibTeX

@INPROCEEDINGS{Cunha02derivinganimations,

author = {Alcino Cunha and José Barros and João Saraiva},

title = {Deriving animations from recursive definitions},

booktitle = {In Draft Proceedings of the 14th International Workshop on the Implementation of Functional Languages (IFL’02},

year = {2002}

}

### OpenURL

### Abstract

Abstract. This paper describes a generic method to derive an animation from a recursive definition, with the objective of debugging and understanding this definition by expliciting its control structure. This method is based on a well known algorithm of factorizing a recursive function into the composition of the producer and the consumer of its call tree. We developed a systematic method to transform both the resulting functions in order to draw the tree step by step. The theory of data types as fixed points of functors, generic recursion patterns, and monads, are fundamental to our work and are briefly presented. Using polytypic implementations of monadic recursion patterns and an application to manipulate and generate graph layouts we developed a prototype that, given a recursive function written in a subset of Haskell, returns a function whose execution yields the desired animation. 1

### Citations

742 | Notions of Computation and Monads
- Moggi
(Show Context)
Citation Context ... is the existence of two kinds of leaves in the intermediate shape tree due to the existence of two base cases in the recursive definition.s4 Monadic recursion operators After being proposed by Moggi =-=[15]-=-, monads were introduced in functional programming by Wadler [22] as a means to structure programs that produce effects. In this context a monad is usually defined by a so-called Kleisli triple (M, un... |

465 | Comprehending Monads
- Wadler
- 1990
(Show Context)
Citation Context ...e tree due to the existence of two base cases in the recursive definition.s4 Monadic recursion operators After being proposed by Moggi [15], monads were introduced in functional programming by Wadler =-=[22]-=- as a means to structure programs that produce effects. In this context a monad is usually defined by a so-called Kleisli triple (M, unit, − ⋆ ) over a category C, where M : Obj(C) → Obj(C) is the res... |

410 | Deforestation: Transforming programs to eliminate trees
- Wadler
- 1990
(Show Context)
Citation Context ... legacy software. Refinement techniques usually start from a clear and inefficient specification to reach an obscure and (hopefully) efficient program. One of these techniques is called deforestation =-=[21]-=-, for it avoids the construction of intermediate tree-like structures. This is usually achieved by coding these structures in the control flow of the program. The reverse abstraction process tries to ... |

328 | An open graph visualization system and its applications to software engineering. Softw Pract
- Gansner, North
- 2000
(Show Context)
Citation Context ...ate monad M and lifting functions α : (F A → A) → (F A → MA) and β : (A → F A) → (A → M(F A)) that will encode the desired effects of animation. In particular we developed an animation using Graphviz =-=[6]-=-, a collection of tools for manipulating graph structures and generating graph layouts. – Finally, the derived hylo will be transformed into the monadic hylo [|α(g), β(h)|] M F whose execution yields ... |

111 | A fold for all seasons
- Sheard, Fegaras
- 1993
(Show Context)
Citation Context ...our work makes intensive use of generic functions that capture typical patterns of recursion (such as the foldr). The use of these generic control structures is becoming important for several reasons =-=[19]-=-: – Abstraction. They allow the specification of algorithms independently of the types of the data structures they should operate on. – Genericity. They allow the statement, proof and use of generic t... |

107 | Polytypic values possess polykinded types
- Hinze
- 2002
(Show Context)
Citation Context ...rogramming. In section 2 we will briefly review the theory behind this approach. These presentation will be accompanied by examples and polytypic implementations using Haskell [1] and Generic Haskell =-=[7]-=-. 4 3 2 1sIn section 3 we will present a forestation algorithm previously developed by Hu el al [8], and give examples on how it can be used to decompose a recursive function into the composition of a... |

105 |
Data structures and program transformation
- Malcolm
- 1990
(Show Context)
Citation Context ... by (F + G) h = F h + G h (F × G) h = F h × G h – the composition of other polynomial functors.sGiven a polynomial functor F , the initial object in the category of F -algebras is guaranteed to exist =-=[12]-=- (more precisely, the category must have colimits and countable chains, which is the case of CPO). The most common data types can be expressed as fixed points of polynomial functors, as can be seen in... |

98 |
and Oege de Moor. Algebra of Programming
- Bird
- 1997
(Show Context)
Citation Context ...oted by µF , is called the data type defined by the endofunctor F . The initial algebra is denoted by inF : F (µF ) → µF and the final coalgebra by outF : µF → F (µF ). A polynomial functor is either =-=[2]-=-: – the identity functor I; – a constant functor A for a given type A; – the pointwise product or coproduct of other polynomial functors, defined by (F + G) h = F h + G h (F × G) h = F h × G h – the c... |

96 | Bananas in space: extending fold and unfold to exponential types
- Meijer, Hutton
- 1995
(Show Context)
Citation Context ...ty lists of type A A + A × I Binary shape trees 1 + I × I Binary leaf trees of type A A + I × I Binary trees of type A 1 + A × I × I Fig. 2. Some functors of common data types As shown for example in =-=[14, 9]-=-, with Haskell, we can implement data types explicitly as fixed points of functors quite straightforwardly. For example, for the case of lists and binary shape trees we have newtype Mu f = In {out :: ... |

92 | Shortcut to Deforestation in Calculational Form
- Takano, Meijer
- 1995
(Show Context)
Citation Context ... . . . , f til . This algorithm is the main step of an automatic transformation system named HYLO [16], which performs fusion transformation in a calculational approach based on the acid rain theorem =-=[20]-=-. The polytypic versions of the recursion patterns are very well suited to be used in conjunction with this algorithm, because it also derives the functor that generates the data type of the call tree... |

74 | Warm fusion: deriving build-catas from recursive definitions
- Launchbury, Sheard
- 1995
(Show Context)
Citation Context ...resentation, the authors restricted themselves to single-recursive datatypes and functions without mutual recursion. A work with similar objectives had already been developed by Launchbury and Sheard =-=[11]-=-, but only for recursive definitions that can be specified in build-cata forms. decl ::= v = b function definition b ::= λvs. case t0 of r definition body vs ::= v|(v1, . . . , vn) argument r ::= p1 →... |

71 | Functional programming with overloading and higherorder polymorphism
- Jones
- 1995
(Show Context)
Citation Context ...ty lists of type A A + A × I Binary shape trees 1 + I × I Binary leaf trees of type A A + I × I Binary trees of type A 1 + A × I × I Fig. 2. Some functors of common data types As shown for example in =-=[14, 9]-=-, with Haskell, we can implement data types explicitly as fixed points of functors quite straightforwardly. For example, for the case of lists and binary shape trees we have newtype Mu f = In {out :: ... |

49 | Merging monads and folds for functional programming
- Meijer, Jeuring
- 1995
(Show Context)
Citation Context ...ctions as morphisms, unit as identity, and − • − as composition. Monadic catas where introduced by Fokkinga [5] after lifting most of the concepts presented in section 2 for the Kleisli category (see =-=[13]-=- for a more practical approach). First, we need to define the lifting of a function f : A → B as � f = unit◦f. Then, we also need to define how to lift a functor F to the Kleisli category. This liftin... |

47 | Deriving structural hylomorphisms from recursive definitions
- Hu, Iwasaki, et al.
- 1996
(Show Context)
Citation Context ... will be accompanied by examples and polytypic implementations using Haskell [1] and Generic Haskell [7]. 4 3 2 1sIn section 3 we will present a forestation algorithm previously developed by Hu el al =-=[8]-=-, and give examples on how it can be used to decompose a recursive function into the composition of a function that builds the call tree and another one that “consumes” it, in order to achieve the des... |

30 | Freja, Hat and Hood — a comparative evaluation of three systems for tracing and debugging lazy functional programs
- Chitil, Runciman, et al.
- 2001
(Show Context)
Citation Context ...trategy where a single node of the call trace is inspected at a time, forgetting the whole of its context in the graph (for a survey of debugging and tracing systems for lazy functional languages see =-=[3]-=-). For example, GHood [18] is a graphical visualization tool for tracing Haskell programs, that uses a simple tree layout algorithm to draw step by step the data structures being produced. In our appr... |

26 |
Monadic Maps and Folds for Arbitrary Datatypes. Memoranda Informatica 94-28
- Fokkinga
- 1994
(Show Context)
Citation Context ...ioned laws allow one to form a Kleisli category CM , with the same objects as C, monadic functions as morphisms, unit as identity, and − • − as composition. Monadic catas where introduced by Fokkinga =-=[5]-=- after lifting most of the concepts presented in section 2 for the Kleisli category (see [13] for a more practical approach). First, we need to define the lifting of a function f : A → B as � f = unit... |

14 | Fusion of Recursive Programs with Computational Effects
- Pardo
(Show Context)
Citation Context ...g @@ (mapMl {| f |} (mcata {| f |} g)) @@ (return . out) where @@ is an infix operator that implements the Kleisli composition − • −. Monadic anas and monadic hylos where extensively studied by Pardo =-=[17]-=-. The main problem with monadic anas is that the lifting of normal anas to the Kleisli category does not yield unique solutions, and thus, given a monadic F - coalgebra g : A → M(F A), the monadic ana... |

8 |
Masato Takeichi. A calculational fusion system HYLO
- Onoue, Hu, et al.
- 1997
(Show Context)
Citation Context ...il ] where v ′ i1 , . . . , v′ are fresh variables introduced to replace the occurrences il of f ti1 , . . . , f til . This algorithm is the main step of an automatic transformation system named HYLO =-=[16]-=-, which performs fusion transformation in a calculational approach based on the acid rain theorem [20]. The polytypic versions of the recursion patterns are very well suited to be used in conjunction ... |

8 | Ghood — graphical visualisation and animation of haskell object observations
- Reinke
- 2001
(Show Context)
Citation Context ...de of the call trace is inspected at a time, forgetting the whole of its context in the graph (for a survey of debugging and tracing systems for lazy functional languages see [3]). For example, GHood =-=[18]-=- is a graphical visualization tool for tracing Haskell programs, that uses a simple tree layout algorithm to draw step by step the data structures being produced. In our approach we focus on the contr... |

3 |
98: A non-strict, purely functional language
- Augustsson, Barton, et al.
- 1998
(Show Context)
Citation Context ...approach to functional programming. In section 2 we will briefly review the theory behind this approach. These presentation will be accompanied by examples and polytypic implementations using Haskell =-=[1]-=- and Generic Haskell [7]. 4 3 2 1sIn section 3 we will present a forestation algorithm previously developed by Hu el al [8], and give examples on how it can be used to decompose a recursive function i... |

1 | Out-of-core functional programming with type-based primitives
- Chuang, Mu
- 2000
(Show Context)
Citation Context ...g : F A → MA and a monadic coalgebra h : B → M(F B), is equal to the least fixed point of λf . g • � F f • h This definition for monadic hylo has been already used by other authors, as for example in =-=[4]-=-. Its definition in Generic Haskell is mhylo {| f :: * -> * |} :: (Functor m, Monad m) => (f b -> m b) -> (a -> m (f a)) -> (a -> m b) mhylo {| f |} g h = g @@ (mapMl {| f |} (mhylo {| f |} g h)) @@ h... |

1 |
Editing Pictures with lefty
- Koutsofios
- 1996
(Show Context)
Citation Context ...β(h)|] M F whose execution yields the animation of the calculation process for a given parameter. The animation in Graphviz is implemented by a script that we developed in its internal language lefty =-=[10]-=-. This script needs two files with the following information:s– The first file has all the information needed in order to draw, step by step, the intermediate data structure produced by the anamorphis... |