10 research outputs found

    Hierarchy in Generic Programming Libraries

    Full text link
    Generic programming (GP) is a form of abstraction in programming languages that serves to reduce code duplication by exploiting the regular structure of algebraic datatypes. Several different approaches to GP in Haskell have surfaced, giving rise to the problem of code duplication across GP libraries. Given the original goals of GP, the is a rather unfortunate turn of events. Fortunately, we can convert between the different representations of each approach, which allows us to “borrow” generic functions from different approaches, avoiding the need to reimplement every generic function in every single GP library. In previous work we have shown how existing GP libraries relate to each other. In this paper we go one step further and advocate “hierarchical GP”: through proper design of different GP approaches, each library can fit neatly in a hierarchy, greatly minimizing the amount of supporting infrastructure necessary for each approach, and allowing each library to be specific and concise, while eliminating code duplication overall. We introduce a new library for GP in Haskell intended to sit at the top of the “GP hierarchy”. This library contains a lot of structural information, and is not intended to be used directly. Instead, it is a good starting point for generating generic representations for other libraries. This approach is also suitable for being the only library with native compiler support; all other approaches can be obtained from this one by simple conversion of representations in plain Haskell code

    Multifocal: a strategic bidirectional transformation language for XML schemas

    Get PDF
    Lenses are one of the most popular approaches to define bidirectional transformations between data models. However, writing a lens transformation typically implies describing the concrete steps that convert values in a source schema to values in a target schema. In contrast, many XML-based languages allow writing structure-shy programs that manipulate only specific parts of XML documents without having to specify the behavior for the remaining structure. In this paper, we propose a structure-shy bidirectional two-level transformation language for XML Schemas, that describes generic type-level transformations over schema representations coupled with value-level bidirectional lenses for document migration. When applying these two-level programs to particular schemas, we employ an existing algebraic rewrite system to optimize the automatically-generated lens transformations, and compile them into Haskell bidirectional executables. We discuss particular examples involving the generic evolution of recursive XML Schemas, and compare their performance gains over non-optimized definitions.Fundação para a CiĂȘncia e a Tecnologi

    Generic Views

    No full text
    Structural polymorphism allows for generic functions to be defined by induction over the structure of types. In Generic Haskell, the structure of a type is perceived as a nested sum of products. Over the last few years it has been shown that a great amount of generic programs can be defined in terms of this perception. Still, there are applications for which viewing data types as sums of products limits the expressiveness of Generic Haskell. As it turns out, different perceptions of the structure of types enable the definition of generic programs that are more efficient, more elegant, and more expressive. We show how these different perceptions, which we call generic views, can be implemented and used in Generic Haskell

    Generic Views on Data Types

    No full text

    Generic Generic Programming

    No full text
    Generic programming (GP) is a form of abstraction in programming languages that serves to reduce code duplication by exploiting the regular structure of algebraic datatypes. Over the years, several different approaches to GP in Haskell have surfaced. These approaches are often very similar, but have minor variations that make them particularly well-suited for one particular domain or application. As such, there is a lot of code duplication across GP libraries, which is rather unfortunate, given the original goals of GP. To address this problem, we introduce yet another library for GP in Haskell... from which we can automatically derive representations for the most popular other GP libraries. Our work unifies many approaches to GP, and simplifies the life of both library writers and users. Library writers can define their approach as a conversion from our library, obviating the need for writing metaprogramming code for generation of conversions to and from the generic representation. Users of GP, who often struggle to find “the right approach ” to use, can now mix and match functionality from different libraries with ease, and need not worry about having multiple (potentially inefficient and large) code blocks for generic representations in different approaches

    A lightweight approach to datatype-generic rewriting

    Get PDF
    Contains fulltext : 84366.pdf (publisher's version ) (Open Access)40 p1 p

    Automatically Generating Counterexamples to Naive Free Theorems

    No full text
    Disproof can be as important as proof in studying programs and programming languages. In particular, a somehow conditioned statement about program behavior is sometimes best understood and explored by trying to exhibit a falsifying example in the absence of a condition in question. Automation is as desirable for such falsification as it is for verification tasks. We develop formal and implemented tools for counterexample generation in the context of free theorems, i.e., statements derived from polymorphic types Ă  la relational parametricity. The machinery we employ is rooted in constraining the type system and intuitionistic proof search

    Libraries for Generic Programming in Haskell

    No full text
    These lecture notes introduce libraries for datatype-generic programming in Haskell. We introduce three characteristic generic programming libraries: lightweight implementation of generics and dynamics, extensible and modular generics for the masses, and scrap your boilerplate. We show how to use them to use and write generic programs. In the case studies for the different libraries we introduce generic components of a medium-sized application which assists a student in solving mathematical exercises
    corecore