40 research outputs found

    The generic HASKELL user's guide : version 0.99 - Amber release

    Get PDF
    Software development often consists of designing datatypes around which functionality is added. Some functionality is datatype specific, whereas other functionality is defined on almost all datatypes in such a way that it depends only on the structure of the datatype. A function that works on many datatypes in this way is called a generic (or polytypic) function. Examples of generic functionality include storing a value in a database, editing a value, comparing two values for equality, and pretty-printing a value. Since datatypes often change and new datatypes are introduced, we have developed Generic HASKELL which supports generic definitions to save the programmer from (re)writing instances of generic functions. Generic HASKELL extends the functional programming language Haskell [5] with, among other things, a construct for defining type-indexed values with kind-indexed types, based on recent work by Hinze [2]. These values can be specialised to all Haskell datatypes, facilitating wider application of generic programming than provided by earlier systems such as PolyP [4]

    The HERMIT in the machine: a plugin for the interactive transformation of GHC core language programs

    Get PDF
    The importance of reasoning about and refactoring programs is a central tenet of functional programming. Yet our compilers and development toolchains only provide rudimentary support for these tasks. This paper introduces a programmatic and compiler-centric interface that facilitates refactoring and equational reasoning. To develop our ideas, we have implemented HERMIT, a toolkit enabling informal but systematic transformation of Haskell programs from inside the Glasgow Haskell Compiler’s optimization pipeline. With HERMIT, users can experiment with optimizations and equational reasoning, while the tedious heavy lifting of performing the actual transformations is done for them. HERMIT provides a transformation API that can be used to build higher-level rewrite tools. One use-case is prototyping new optimizations as clients of this API before being committed to the GHC toolchain. We describe a HERMIT application - a read-eval-print shell for performing transformations using HERMIT. We also demonstrate using this shell to prototype an optimization on a specific example, and report our initial experiences and remaining challenges

    Liberal Typing for Functional Logic Programs

    Get PDF
    We propose a new type system for functional logic programming which is more liberal than the classical Damas-Milner usually adopted, but it is also restrictive enough to ensure type soundness. Starting from Damas-Milner typing of expressions we propose a new notion of well-typed program that adds support for type-indexed functions, existential types, opaque higher-order patterns and generic functions-as shown by an extensive collection of examples that illustrate the possibilities of our proposal. In the negative side, the types of functions must be declared, and therefore types are checked but not inferred. Another consequence is that parametricity is lost, although the impact of this flaw is limited as "free theorems" were already compromised in functional logic programming because of non-determinism

    Exploring Generic Haskell

    No full text
    This thesis is an exploration -- an exploration of a language extension of the functional programming language Haskell. The extension is called Generic Haskell, albeit the name has been used to refer to different objects over the last several years: Many papers have described different proposals, features, variations, and generations of the language. One purpose of this thesis is to do away with at least part of this fuzziness: everything is described in a common notation and from a single starting point. The other purpose is to simply give a complete overview of the language: we will systematically explain the core features of Generic Haskell, and several extensions, all with motivating examples and details on how the features can be implemented. Generic programming gives the user of the programming language the ability to define functions by analysis of the structure of datatypes. Such generic functions are statically checked for type correctness. They are reusable in many contexts, and can adapt easily to changed environments, because they work for all datatypes. The thesis starts with the presentation of a simple functional core language which is gradually extended with features that allow generic programming. We show how generic programming can benefit from the concept of dependencies, which are a result of the combination and generalization of two approaches to generic functions by Ralf Hinze. Whenever the language is extended, we first motivate the additions using examples, and subsequently discuss implications for the underlying theory. In the second half of the thesis, several concepts are described that make generic programming more powerful and easier to use: generic abstraction is a simple mechanism to form new generic functions out of existing ones; type inference can help to reduce the notational burden for the programmer quite significantly, default cases allow to define several variations of one generic behaviour quickly. We discuss type-indexed datatypes, which lift the concept of generic programming to the level of types and provide the possibility to define datatypes that have an implementation based on the structure of a type argument. Multiple views on datatypes allow the definition of generic functions which would otherwise be difficult to define. Finally, we discuss practical issues arising from the embedding into Haskell, such as dealing with type synonyms, or the module system and separate compilation. All in all, we present a complete and rich language for generic programming, which can, has been, and hopefully will be used for several interesting application

    Open data types and open functions

    No full text

    Generic Generic Programming

    No full text

    Abstract syntax graphs for domain specific languages

    No full text
    This paper presents a representation for embedded domain specific languages (EDSLs) using abstract syntax graphs (ASGs). The purpose of this representation is to deal with the important problem of defining operations that require observing or preserving sharing and recursion in EDSLs in an expressive, yet easy-to-use way. In contrast to more conventional representations based on abstract syntax trees, ASGs represent sharing and recursion explicitly as binder constructs. We use a functional representation of ASGs based on structured graphs, where binders are encoded with parametric higher-order abstract syntax. We show how adapt to this representation to well-typed ASGs. This is especially useful for EDSLs, which often reuse the type system of the host language. We also show an alternative class-based encoding of (well-typed) ASGs that enables extensible and modular well-typed EDSLs while allowing the manipulation of sharing and recursion. Copyright © 2013 ACM.link_to_subscribed_fulltex

    The Generic Haskell user's guide, Version 1.60 - Diamond release

    No full text
    Software development often consists of designing datatypes around which functionality is added. Some functionality is datatype specific, whereas other functionality is defined on almost all datatypes in a way that depends only on the structure of the datatype. A function that works on many datatypes in this manner is called a generic (or polytypic) function. Examples of generic functionality include editing, pretty-printing or storing a value in a database, and comparing two values for equality. Since datatypes often change and new datatypes are introduced, we have developed Generic H ASKELL, an extension of the functional programming language Haskell [11] that supports generic definitions, to save the programmer from (re)writing instances of generic functions. The original design of Generic H ASKELL is based on work by Ralf Hinze [3]. The current release is based on recent work by Dave Clarke, Johan Jeuring and Andres L¨oh [10, 9]. It extends Haskell with, among other things, a construct for defining type-indexed values. These values can be specialised to all Haskell datatypes, facilitating wider application of generic programming than provided by earlier systems such as PolyP [8]

    The Generic Haskell User's Guide. Version 1.23 - Beryl release

    No full text

    Generic Views on Data Types

    No full text
    corecore