14 research outputs found

    Strictification of circular programs

    Get PDF
    Circular functional programs (necessarily evaluated lazily) have been used as algorithmic tools, as attribute grammar implementations, and as target for program transformation techniques. Classically, Richard Bird [1984] showed how to transform certain multitraversal programs (which could be evaluated strictly or lazily) into one-traversal ones using circular bindings. Can we go the other way, even for programs that are not in the image of his technique? That is the question we pursue in this paper. We develop an approach that on the one hand lets us deal with typical examples corresponding to attribute grammars, but on the other hand also helps to derive new algorithms for problems not previously in reach.(undefined

    Zipper-based modular and deforested computations

    Get PDF
    In this paper we present a methodology to implement multiple traversal algorithms in a functional programming setting. The implementations we obtain s of highly modular and intermediate structure free programs, that rely on the concept of functional zippers to navigate on data structures.Even though our methodology is developed and presented under Haskell, a lazy functional language, we do not make essential use of laziness. This is an essential difference with respect to other attribute grammar embeddings. This also means that an approach similar to ours can be followed in a strict functional setting such as Ocaml, for example.In the paper, our technique is applied to a significant number of problems that are well-known to the functional programming community, demonstrating its practical interest.- (undefined

    String Diagrams for λ\lambda-calculi and Functional Computation

    Full text link
    This tutorial gives an advanced introduction to string diagrams and graph languages for higher-order computation. The subject matter develops in a principled way, starting from the two dimensional syntax of key categorical concepts such as functors, adjunctions, and strictification, and leading up to Cartesian Closed Categories, the core mathematical model of the lambda calculus and of functional programming languages. This methodology inverts the usual approach of proceeding from syntax to a categorical interpretation, by rationally reconstructing a syntax from the categorical model. The result is a graph syntax -- more precisely, a hierarchical hypergraph syntax -- which in many ways is shown to be an improvement over the conventional linear term syntax. The rest of the tutorial focuses on applications of interest to programming languages: operational semantics, general frameworks for type inference, and complex whole-program transformations such as closure conversion and automatic differentiation

    Multiple intermediate structure deforestation by shortcut fusion

    Get PDF
    Lecture Notes in Computer Science Volume 8129, 2013.Shortcut fusion is a well-known optimization technique for functional programs. Its aim is to transform multi-pass algorithms into single pass ones, achieving deforestation of the intermediate structures that multi-pass algorithms need to construct. Shortcut fusion has already been extended in several ways. It can be applied to monadic programs, maintaining the global effects, and also to obtain circular and higher-order programs. The techniques proposed so far, however, only consider programs defined as the composition of a single producer with a single consumer. In this paper, we analyse shortcut fusion laws to deal with programs consisting of an arbitrary number of function compositions.FCT -Fundação para a Ciência e a Tecnologia(FCOMP-01-0124-FEDER-022701

    Tools and libraries to model and manipulate circular programs

    Get PDF
    This paper presents techniques to model circular lazy programs in a strict, purely functional setting. Circular lazy programs model any algorithm based on multiple traversals over a recursive data structure as a single traversal function. Such elegant and concise circular programs are defined in a (strict or lazy) functional language and they are transformed into efficient strict and deforested, multiple traversal programs by using attribute grammars-based techniques. Moreover, we use standard slicing techniques to slice such circular lazy programs. We have expressed these transformations as an Haskell library and two tools have been constructed: the HaCirctool that refactors Haskell lazy circular programs into strict ones, and the OCirctool that extends Ocaml with circular definitions allowing programmers to write circular programs in Ocaml notation, which are transformed into strict Ocaml programs before they are executed. The first benchmarks of the different implementations are presented and show that for algorithms relying on a large number of traversals the resulting strict, deforested programs are more efficient than the lazy ones, both in terms of runtime and memory consumption.(undefined

    Multiple intermediate structure deforestation by shortcut fusion

    Get PDF
    Shortcut fusion is a well-known optimization technique for functional programs. Its aim is to transform multi-pass algorithms into single pass ones, achieving deforestation of the intermediate structures that multi-pass algorithms need to construct. Shortcut fusion has already been extended in several ways. It can be applied to monadic programs, maintaining the global effects, and also to obtain circular and higher-order programs. The techniques proposed so far, however, only consider programs defined as the composition of a single producer with a single consumer. In this paper, we analyse shortcut fusion laws to deal with programs consisting of an arbitrary number of function compositions. (C) 2016 Elsevier B.V. All rights reserved.We would like to thank the anonymous reviewers for their detailed and helpful comments. This work was partially funded by ERDF - European Regional Development Fund through the COMPETE Programme (operational programme for competitiveness) and by National Funds through the FCT - Fundacao para a Ciencia e a Tecnologia (Portuguese Foundation for Science and Technology) within projects FCOMP-01-0124-FEDER-020532 and FCOMP-01-0124-FEDER-022701

    Design, implementation and calculation of circular programs

    Get PDF
    Tese de doutoramento em Informática (ramo do Conhecimento Fundamentos da Computação)Circular programming is a powerful technique to express multiple traversal algorithms as a single traversal function in a lazy setting. Such a (virtual) circular program may contain circular definitions, that is, arguments of function calls that are also results of that same calls. Although circular definitions always induce non-termination under a strict evaluation mechanism, they can sometimes be immediately evaluated using a lazy evaluation strategy. The lazy engine is able to compute the right evaluation order, if that order exists. Indeed, using this style of circular programming, the programmer does not have to concern him/herself with the definition and the scheduling of the different traversal functions, since a single (traversal) function has to be defined. Moreover, because there is a single traversal function, the programmer does not have to define intermediate gluing data structures to convey values computed in one traversal and needed in following ones, either. In this Thesis, we present our studies on the design, implementation and calculation of circular programs. We start by developing techniques to transform circular programs into strict ones. Then, we introduce calculation rules to obtain circular programs from strict equivalents, both in the context of pure and monadic programming. Because we use calculation techniques we guarantee that the resulting circular programs are equivalent to the strict ones we start with. In this Thesis, we also perform a series of benchmarks comparing the running performances of circular programs and the programs we are able to derive from circular programs.A utilização de programas circulares na implementação de algoritmos de programação é uma técnica poderosa que permite, num paradigma lazy, implementar soluções que efectuam múltiplas travessias sobre uma ou mais estruturas de dados como um programa que efectua apenas uma travessia sobre uma única estrutura de dados. Num programa (virtualmente) circular podem ocorrer definições circulares, isto é, invocações de funções onde um argumento da invocação é, ao mesmo tempo, um resultado da mesma invocação. Embora este tipo de definições induza não terminação num paradigma estrito, a verdade é que, num paradigma lazy, elas podem ser desde logo executadas utilizando uma estratégia baseada em lazy evaluation: a máquina lazy é capaz de determinar o escalonamento correcto das computações, se ele existir. Na verdade, utilizando este método de programação, o(a) programador(a) não tem de definir nem de escalonar as diferentes travessias, uma vez que apenas uma função necessita de ser implementada. Para além disso, porque existe apenas função, e uma vez que essa função realiza apenas uma travessia, o(a) programador(a) também não é forçado a definir estruturas de dados intermédias para colar as diferentes travessias. Nesta Tese são apresentados os nossos estudos relativos ao desenho, implementação e cálculo de programas circulares. Começamos por desenvolver técnicas de transformação de programas circulares em programas estritos. Depois apresentamos regras de cálculo que permitem obter programas circulares a partir de estritos, equivalentes, tanto no contexto de funções puras como no contexto de funções monádicas. Uma vez que, neste trabalho, utilizamos técnicas de cálculo de programas, é possível garantir a correcção da transformação que propomos. Por fim, realizamos uma bateria de testes que permitem comparar a performance de programas circulares com a dos programas que derivamos a partir deles.Fundacão para a Ciência e Tecnologia (FCT)grant No. SFRH/BD/19186/200

    A purely functional combinator language for software quality assessment

    Get PDF
    Quality assessment of open source software is becoming an important and active research area. One of the reasons for this recent interest is the consequence of Internet popularity. Nowadays, programming also involves looking for the large set of open source libraries and tools that may be reused when developing our software applications. In order to reuse such open source software artifacts, programmers not only need the guarantee that the reused artifact is certified, but also that independently developed artifacts can be easily combined into a coherent piece of software. In this paper we describe a domain specific language that allows programmers to describe in an abstract level how software artifacts can be combined into powerful software certification processes. This domain specific language is the building block of a web-based, open-source software certification portal. This paper introduces the embedding of such domain specific language as combinator library written in the Haskell programming language. The semantics of this language is expressed via attribute grammars that are embedded in Haskell, which provide a modular and incremental setting to define the combination of software artifacts

    Graphical application and visualization of lazy functional computation.

    Get PDF
    Mere academic toys or the tools of the future? Lazy functional programming languages have undoubted attractive properties. This thesis explores their potential, from the programmer's point of view, for implementing interactive and graphical applications to which they do not seem immediately suited. The discussion is centred round two example applications. One is a graphical design program based on an idea of the artist M. C. Escher. The thesis argues that the graphical user interface may be encapsulated in an "interpret " function that when applied by a mouse click to an interface of appropriate type yields the required behaviour. The second example is a monitoring interpreter for a functional language. The idea is that if the mechanics of the reduction are presented at a suitable level of abstraction, this may be used to give insight into what is going on. On the basis of this the programmer might modify the code so that a program runs more efficiently in terms of speed and memory requirements. Problems of displaying the reduction are addressed, and solutions proposed for overcoming these: displaying the graph as a spanning tree, to ensure planarity, with extra leave
    corecore