7 research outputs found

    A framework for point-free program transformation

    Get PDF
    The subject of this paper is functional program transformation in the so-called point-free style. By this we mean first translating programs to a form consisting only of categorically-inspired combinators, algebraic data types defined as fixed points of functors, and implicit recursion through the use of type-parameterized recursion patterns. This form is appropriate for reasoning about programs equationally, but difficult to actually use in practice for programming. In this paper we present a collection of libraries and tools developed at Minho with the aim of supporting the automatic conversion of programs to point-free (embedded in Haskell), their manipulation and rule-driven simplification, and the (limited) automatic application of fusion for program transformation.Fundação para a Ciência e a Tecnologia (FCT

    Down with variables

    Get PDF
    Techn. Report DI-PURe-05.06.01The subject of this paper is point-free functional programming in Haskell. By this we mean writing programs using categorically-inspired combinators, algebraic data types defined as fixed points of functors, and impicit recursion through the use of type-parameterized recursion patterns. This style of programming is appropriate for program calculation (reasoning about programs equationally), but difficult to actually use in practice - most programmers use a mixture of the above elements with explicit recursion and manipulation of arguments. In this paper we present a mechanism that allows programmers to convert classic point-wise code into point-free style, and a Haskell library that enables the direct execution of the resulting code. Together, they make possible the use of point-free either as a direct programming style or as a domain into which programs can be transformed before being subject to further manipulation

    Point-free program calculation

    Get PDF
    Tese de doutoramento em Informática, ramo de Fundamentos da ComputaçãoDue to referential transparency, functional programming is particularly appropriate for equational reasoning. In this thesis we reason about functional programs by calculation, using a program calculus built upon two basic ingredients. The first is a set of recursion patterns that allow us to define recursive functions implicitly. These are encoded as higher-order operators that encapsulate typical forms of recursion, such as the well-known foldr operator on lists. The second is a point-free style of programming in which programs are expressed as combinations of simpler functions, without ever mentioning their arguments. The basic combinators are derived from standard categorical constructions, and are characterized by a rich set of equational laws. In order to be able to apply this calculational methodology to real lazy functional programming languages, a concrete category of partial functions and elements is used. While recursion patterns are already well accepted and a lot of research has been carried out on this topic, the same cannot be said about point-free programming. This thesis addresses precisely this component of the calculus. One of the contributions is a mechanism to translate classic pointwise code into the point-free style. This mechanism can be applied to a λ-calculus rich enough to represent the core functionality of a real functional programming language. A library that enables programming in a pure pointfree style within Haskell is also presented. This library is useful for understanding the expressions resulting from the above translation, since it allows their direct execution and, where applicable, the graphical visualization of recursion trees. Another contribution of the thesis is a framework for performing point-free calculations with higher-order functions. This framework is based on the internalization of some basic combinators, and considerably shortens calculations in this setting. In order to assess the viability of mechanizing calculations, several issues are discussed concerning the decidability of equality and the implementation of fusion laws.Devido à transparência referencial, o paradigma funcional é particularmente adequado ao raciocínio equacional. Nesta tese a manipulação de programas funcionais será feita por cálculo, sendo o cálculo de programas constituído por dois ingredientes fundamentais. O primeiro é um conjunto de padrões de recursividade que nos permite definir funções recursivas implicitamente. Estes padrões são codificados como operadores de ordem superior que ecapsulam formas de recursão típicas, tal como o bem conhecido operador foldr para listas. O segundo ingrediente é um estilo de programação “pointfree”, no qual os programas são definidos por combinação de funções mais simples sem nunca mencionar explicitamente os seus argumentos. Os combinadores fundamentais são derivados de construções categoriais padrão, e são caracterizados por um conjunto expressivo de leis equacionais. Para ser possível aplicar este método de cálculo a linguagens de programação funcional “lazy”, foi usada uma categoria concreta onde as funções e os elementos podem ser parciais. Ao contrário dos padrões de recursividade, que já são bem aceites e sobre os quais já se fez muita investigação, o mesmo não se pode dizer sobre a programação “point-free”. Esta tese aborda precisamente este componente do cálculo. Uma das contribuições é um mecanismo que permite traduzir código “pointwise” clássico para o estilo “point-free”. Este mecanismo pode ser aplicado a um λ-calculus suficientemente expressivo para representar a funcionalidade básica de uma linguagem de programação funcional real. Também se apresenta uma biblioteca que permite programar num estilo “point-free” puro dentro da linguagem Hankell. Esta biblioteca é útil para compreender as expressões que resultam da tradução acima referida, pois permite a sua execução directa e, quando aplicável, a visualização gráfica de árvores de recursividade. Outra contribuição da tese consiste numa metodologia para realizar cálculos “point-free” sobre funções de ordem superior. Esta metodologia é baseada na internalização de alguns combinadores fundamentais, e permite encurtar significativamente os cálculos. Para estabelecer a viabilidade de mecanização, também se discutem várias questões relacionadas com a decidibilidade da igualdade e a implementação de leis de fusão
    corecore