Adjoint folds and unfolds - An extended study
نویسنده
چکیده
Folds and unfolds are at the heart of the algebra of programming. They allow the cognoscenti to derive andmanipulate programs rigorously and effectively. However, most, if not all, programs require some tweaking to be given the form of an (un)fold. In this article, we remedy the situation by introducing adjoint (un)folds. We demonstrate that most programs are already of the required form and thus are directly amenable to formal manipulation. Central to the development is the categorical notion of an adjunction, which links adjoint (un)folds to standard (un)folds. We discuss a multitude of basic adjunctions andways of combining adjunctions and show that they are directly relevant to programming. Furthermore, we develop the calculational properties of adjoint (un)folds, providing several fusion laws, which codify basic optimisation principles. We give a novel proof of type fusion based on adjoint folds and discuss several applications—type fusion states conditions for fusing a left adjoint with an initial algebra to form another initial algebra. The formal development is complemented by a series of examples in Haskell. © 2012 Elsevier B.V. All rights reserved.
منابع مشابه
A Duality of Sorts
Sorting algorithms are one of the key pedagogical foundations of computer science, and their properties have been studied heavily. Perhaps less well known, however, is the fact that many of the basic sorting algorithms exist as a pair, and that these pairs arise naturally out of the duality between folds and unfolds. In this paper, we make this duality explicit, by showing how to define common ...
متن کاملOrigami programming
3 origami (˛ orig¯ a·mi) The Japanese art of making elegant designs using folds in all kinds of paper. One style of functional programming is based purely on recursive equations. Such equations are easy to explain, and adequate for any computational purpose , but hard to use well as programs get bigger and more complicated. In a sense, recursive equations are the 'assembly language' of function...
متن کاملEngineering Mountain Folds in Cell Origami
We report a method to create mountain folds, protruding ridges, in cell origami, a polymer structure folding technique driven by cell traction force (CTF). Formerly, cell origami was based on valley folds, indented creases, only [2]. We created mountain folds adjacent with valley folds. We present designs for self-folding structures as well as for physically stimulated structures. The adhered c...
متن کاملStreaming Algorithms (extended Abstract)
Unfolds generate data structures, and folds consume them. A hylomorphism is a fold after an unfold, generating then consuming a virtual data structure. A metamorphism is the opposite composition, an unfold after a fold; typically, it will convert from one data representation to another. In general, metamorphisms are less interesting than hylomorphisms: there is no automatic fusion to deforest t...
متن کاملUnifying Recursion Schemes
Folds over inductive datatypes are well understood and widely used. In their plain form, they are quite restricted; but many disparate generalisations have been proposed that enjoy similar calculational benefits. There have also been attempts to unify the various generalisations: two prominent such unifications are the ‘recursion schemes from comonads’ of Uustalu, Vene and Pardo, and our own ‘a...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Sci. Comput. Program.
دوره 78 شماره
صفحات -
تاریخ انتشار 2013