87 research outputs found
Fold and Unfold for Program Semantics
In this paper we explain how recursion operators can be used to structure and reason about program semantics within a functional language. In particular, we show how the recursion operator fold can be used to structure denotational semantics, how the dual recursion operator unfold can be used to structure operational semantics, and how algebraic properties of these operators can be used to reason about program semantics. The techniques are explained with the aid of two main examples, the first concerning arithmetic expressions, and the second concerning Milner's concurrent language CCS. The aim of the paper is to give functional programmers new insights into recursion operators, program semantics, and the relationships between them
A Tutorial on the Universality and Expressiveness of Fold
In functional programming, fold is a standard operator that encapsulates a simple pattern of recursion for processing lists. This article is a tutorial on two key aspects of the fold operator for lists. First of all, we emphasize the use of the universal property of fold both as a proof principle that avoids the need for inductive proofs, and as a definition principle that guides the transformation of recursive functions into definitions using fold. Secondly, we show that even though the pattern of recursion encapsulated by fold is simple, in a language with tuples and functions as first-class values the fold operator has greater expressive power than might first be expected
Transformation of structure-shy programs : applied to XPath queries and strategic functions
Various programming languages allow the construction of structure-shy programs. Such programs are defined generically for many different datatypes and only specify specific behavior for a few relevant subtypes. Typical examples are XML query languages that allow selection of subdocuments without exhaustively specifying intermediate element tags. Other examples are languages and libraries for polytypic or strategic functional programming and for adaptive object-oriented programming. In this paper, we present an algebraic approach to transformation of declarative structure-shy programs, in particular for strategic functions and XML queries. We formulate a rich set of algebraic laws, not just for transformation of structure-shy programs, but also for their conversion into structure-sensitive programs and vice versa. We show how subsets of these laws can be used to construct effective rewrite systems for specialization, generalization, and optimization of structure-shy programs. We present a type-safe encoding of these rewrite systems in Haskell which itself uses strategic functional programming techniques.(undefined
Coinductive interpreters for process calculi
This paper suggests functional programming languages with coinductive types as suitable devices for prototyping process calculi. The proposed approach is independent of any particular process calculus and makes explicit the different ingredients present in the design of any such calculi. In particular structural aspects of the underlying behaviour model (e.g. the dichotomies such as active vs reactive, deterministic vs nondeterministic) become clearly separated from the interaction structure which defines the synchronisation discipline. The approach is illustrated by the detailed development in Charity of an interpreter for a family of process languages.(undefined
Transformation of structure-shy programs with application to XPath queries and strategic functions
Various programming languages allow the construction of structure-shy programs. Such programs are defined generically for many different datatypes and only specify specific behavior for a few relevant subtypes. Typical examples are XML query languages that allow selection of subdocuments without exhaustively specifying intermediate element tags. Other examples are languages and libraries for polytypic or strategic functional programming and for adaptive object-oriented programming.
In this paper, we present an algebraic approach to transformation of declarative structure-shy programs, in particular for strategic functions and XML queries. We formulate a rich set of algebraic laws, not just for transformation of structure-shy programs, but also for their conversion into structure-sensitive programs and vice versa. We show how subsets of these laws can be used to construct effective rewrite systems for specialization, generalization, and optimization of structure-shy programs. We present a type-safe encoding of these rewrite systems in Haskell which itself uses strategic functional programming techniques. We discuss the application of these rewrite systems for XPath query optimization and for query migration in the context of schema evolution
Typed Generic Traversal With Term Rewriting Strategies
A typed model of strategic term rewriting is developed. The key innovation is
that generic traversal is covered. To this end, we define a typed rewriting
calculus S'_{gamma}. The calculus employs a many-sorted type system extended by
designated generic strategy types gamma. We consider two generic strategy
types, namely the types of type-preserving and type-unifying strategies.
S'_{gamma} offers traversal combinators to construct traversals or schemes
thereof from many-sorted and generic strategies. The traversal combinators
model different forms of one-step traversal, that is, they process the
immediate subterms of a given term without anticipating any scheme of recursion
into terms. To inhabit generic types, we need to add a fundamental combinator
to lift a many-sorted strategy to a generic type gamma. This step is called
strategy extension. The semantics of the corresponding combinator states that s
is only applied if the type of the term at hand fits, otherwise the extended
strategy fails. This approach dictates that the semantics of strategy
application must be type-dependent to a certain extent. Typed strategic term
rewriting with coverage of generic term traversal is a simple but expressive
model of generic programming. It has applications in program transformation and
program analysis.Comment: 85 pages, submitted for publication to the Journal of Logic and
Algebraic Programmin
Efficient and Type-Safe Generic Data Storage
AbstractIn this paper we present an elegant method for sequentializing arbitrary data using the generic language extension of the functional programming language Clean. We show how the proposed operations can be used to store values of any concrete data type in several kinds of IO containers (such as files or arrays of characters), and how to manipulate stored data efficiently. Moreover, by extending stored data with encoded type information, data manipulation will be type-safe. Defining these operations generically has the advantage that specific instances for user defined data types can be generated fully automatically. Compared to traditional sequentialization methods (or to common data manipulation, using relational data bases) our operations are an order of magnitude faster
- …