20,175 research outputs found

    Deforestation for higher-order functional programs

    Get PDF
    Functional programming languages are an ideal medium for program optimisations based on source-to-source transformation techniques. Referential transparency affords opportunities for a wide range of correctness-preserving transformations leading to potent optimisation strategies. This thesis builds on deforestation, a program transformation technique due to Wadler that removes intermediate data structures from first-order functional programs. Our contribution is to reformulate deforestation for higher-order functional programming languages, and to show that the resulting algorithm terminates given certain syntactic and typing constraints on the input. These constraints are entirely reasonable, indeed it is possible to translate any typed program into the required syntactic form. We show how this translation can be performed automatically and optimally. The higher-order deforestation algorithm is transparent. That is, it is possible to determine by examination of the source program where the optimisation will be applicable. We also investigate the relationship of deforestation to cut-elimination, the normalisation property for the logic of sequent calculus. By combining a cut-elimination algorithm and first-order deforestation, we derive an improved higher-order deforestation algorithm. The higher-order deforestation algorithm has been implemented in the Glasgow Haskell Compiler. We describe how deforestation fits into the framework of Haskell, and design a model for the implementation that allows automatic list removal, with additional deforestation being performed on the basis of programmer supplied annotations. Results from applying the deforestation implementation to several example Haskell programs are given

    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

    FliPpr: A Prettier Invertible Printing System

    Get PDF
    When implementing a programming language, we often write a parser and a pretty-printer. However, manually writing both programs is not only tedious but also error-prone; it may happen that a pretty-printed result is not correctly parsed. In this paper, we propose FliPpr, which is a program transformation system that uses program inversion to produce a CFG parser from a pretty-printer. This novel approach has the advantages of fine-grained control over pretty-printing, and easy reuse of existing efficient pretty-printer and parser implementations

    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

    Type-Inference Based Short Cut Deforestation (nearly) without Inlining

    Get PDF
    Deforestation optimises a functional program by transforming it into another one that does not create certain intermediate data structures. In [ICFP'99] we presented a type-inference based deforestation algorithm which performs extensive inlining. However, across module boundaries only limited inlining is practically feasible. Furthermore, inlining is a non-trivial transformation which is therefore best implemented as a separate optimisation pass. To perform short cut deforestation (nearly) without inlining, Gill suggested to split definitions into workers and wrappers and inline only the small wrappers, which transfer the information needed for deforestation. We show that Gill's use of a function build limits deforestation and note that his reasons for using build do not apply to our approach. Hence we develop a more general worker/wrapper scheme without build. We give a type-inference based algorithm which splits definitions into workers and wrappers. Finally, we show that we can deforest more expressions with the worker/wrapper scheme than the algorithm with inlining

    Liveness-Based Garbage Collection for Lazy Languages

    Full text link
    We consider the problem of reducing the memory required to run lazy first-order functional programs. Our approach is to analyze programs for liveness of heap-allocated data. The result of the analysis is used to preserve only live data---a subset of reachable data---during garbage collection. The result is an increase in the garbage reclaimed and a reduction in the peak memory requirement of programs. While this technique has already been shown to yield benefits for eager first-order languages, the lack of a statically determinable execution order and the presence of closures pose new challenges for lazy languages. These require changes both in the liveness analysis itself and in the design of the garbage collector. To show the effectiveness of our method, we implemented a copying collector that uses the results of the liveness analysis to preserve live objects, both evaluated (i.e., in WHNF) and closures. Our experiments confirm that for programs running with a liveness-based garbage collector, there is a significant decrease in peak memory requirements. In addition, a sizable reduction in the number of collections ensures that in spite of using a more complex garbage collector, the execution times of programs running with liveness and reachability-based collectors remain comparable

    A Re-examination of Causes of Deforestation and Environmental Kuznets Curve: Evidences from Latin America, Africa and Asia

    Get PDF
    Previous cross-country regression analyses on the causes of deforestation seem to have misspecified the regression models, in which the causes at different levels are mixed, leading to flawed cause-effect relationship between the rate of deforestation and its explanatory variables. The paper focuses explicitly on underlying/policy-oriented causes of deforestation and then examines their relationship with rate of deforestation across 43 countries of Latin America, Africa and Asia. An environmental Kuznets Curve (EKC) relationship between rate of deforestation and income is also tested. Results across all regions and based on panel data technique show that forest and allied (non-forest) sector policies and population density increase deforestation, while forest products export promotion policies, export prices and technological progress decrease deforestation. The effects of per capita income, economic growth and agricultural production are found to be varying in different region. An inverted U-shaped EKC empirically fits for Latin America and Africa while a U-shaped EKC does the same for Asia.Africa; Asia; environmental Kuznets Curve; cross-country analysis; Latin America; underling/policy-oriented causes of deforestation; deforesta tion

    Interactions of Reduced Deforestation and the Carbon Market: The Role of Market Regulations and Future Commitments

    Get PDF
    Reducing emissions from deforestation and degradation (REDD) has been proposed as a potentially inexpensive and plentiful source of emission abatement to supplement other longterm climate policies. However, critics doubt that REDD credits are environmentally equivalent to domestic emission reductions, and suggest an excess supply may disrupt carbon markets. In this context, we investigate the economic implications of emissions market regulations and future emissions reduction commitments, as well as uncertainties in REDD credit supply. Numerical simulations with a multi-country equilibrium model of the global emissions market show unrestricted exchange of REDD units reduces the international carbon price by half and cuts Annex I compliance costs by roughly one third. Restricting supply or demand of REDD credits reduces price impacts, but comes at the cost of economic efficiency. Alternatively, Annex I reduction commitments could be increased by almost two thirds at constant carbon prices. While REDD provides large economic benefits for tropical rainforest regions, any REDD policy scenario also reduces wealth transfers to traditional CDM host countries through increased competition on the supply-side of the carbon market. --Climate Change,Kyoto Protocol,Emissions Trading,Deforestation,REDD
    corecore