6,416 research outputs found
Generic programming using Higher Kinded Data
This thesis describes datatype-generic programming, what it is, and how it is done in Scala. The thesis covers ways of thinking about datatype-generic programming and today's tools and libraries for datatype-generic programming in Scala and summarize how to use them. A new library called perspective for datatype-generic programming with higher kinded data is presented. How these libraries, including perspective, work together with sum types is be covered. Benchmarks are presented on both runtime and compile time performance of perspective and other libraries. perspective manages to keep up in performance with other libraries while offering faster code at the expense of longer compile time if a developer opts into this. Finally, an example language-integrated query library built on perspective is described.Masteroppgave i informatikkINF399MAMN-INFMAMN-PRO
Recommended from our members
The Kansas University rewrite engine: a Haskell-embedded strategic programming language with custom closed universes
When writing transformation systems, a significant amount of engineering effort goes into setting up the infrastructure needed to direct individual transformations to specific targets in the data being
transformed. Strategic programming languages provide general-purpose infrastructure for this task, which the author of a transformation system can use for any algebraic data structure.
The Kansas University Rewrite Engine (KURE) is a typed strategic programming language, implemented as a Haskell-embedded domain-specific language. KURE is designed to support typed transformations over typed data, and the main challenge is how to make such transformations compatible with generic traversal strategies that should operate over any type.
Strategic programming in a typed setting has much in common with datatype-generic programming. Compared to other approaches to datatype-generic programming, the distinguishing feature of KURE’s solution is that the user can configure the behaviour of traversals based on the location of each datum in the tree, beyond their behaviour being determined by the type of each datum.
This article describes KURE’s approach to assigning types to generic traversals, and the implementation of that approach. We also compare KURE, its design choices, and their consequences, with other approaches to strategic and datatype-generic programming
The generic HASKELL user's guide : version 0.99 - Amber release
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]
A Framework for Datatype Transformation
We study one dimension in program evolution, namely the evolution of the
datatype declarations in a program. To this end, a suite of basic
transformation operators is designed. We cover structure-preserving
refactorings, but also structure-extending and -reducing adaptations. Both the
object programs that are subject to datatype transformations, and the meta
programs that encode datatype transformations are functional programs.Comment: Minor revision; now accepted at LDTA 200
The Sketch of a Polymorphic Symphony
In previous work, we have introduced functional strategies, that is,
first-class generic functions that can traverse into terms of any type while
mixing uniform and type-specific behaviour. In the present paper, we give a
detailed description of one particular Haskell-based model of functional
strategies. This model is characterised as follows. Firstly, we employ
first-class polymorphism as a form of second-order polymorphism as for the mere
types of functional strategies. Secondly, we use an encoding scheme of run-time
type case for mixing uniform and type-specific behaviour. Thirdly, we base all
traversal on a fundamental combinator for folding over constructor
applications.
Using this model, we capture common strategic traversal schemes in a highly
parameterised style. We study two original forms of parameterisation. Firstly,
we design parameters for the specific control-flow, data-flow and traversal
characteristics of more concrete traversal schemes. Secondly, we use
overloading to postpone commitment to a specific type scheme of traversal. The
resulting portfolio of traversal schemes can be regarded as a challenging
benchmark for setups for typed generic programming.
The way we develop the model and the suite of traversal schemes, it becomes
clear that parameterised + typed strategic programming is best viewed as a
potent combination of certain bits of parametric, intensional, polytypic, and
ad-hoc polymorphism
- …