The compdata package
Based on Wouter Swierstra's Functional Pearl Data types a la carte (Journal of Functional Programming, 18(4):423-436, 2008, http://dx.doi.org/10.1017/S0956796808006758), this package provides a framework for defining recursive data types in a compositional manner. The fundamental idea of compositional data types (Workshop on Generic Programming, 83-94, 2011, http://dx.doi.org/10.1145/2036918.2036930) is to separate the signature of a data type from the fixed point construction that produces its recursive structure. By allowing to compose and decompose signatures, compositional data types enable to combine data types in a flexible way. The key point of Wouter Swierstra's original work is to define functions on compositional data types in a compositional manner as well by leveraging Haskell's type class machinery.
Building on that foundation, this library provides additional extensions and (run-time) optimisations which make compositional data types usable for practical implementations. In particular, it provides an excellent framework for manipulating and analysing abstract syntax trees in a type-safe manner. Thus, it is perfectly suited for programming language implementations, especially, in an environment consisting of a family of tightly interwoven domain-specific languages.
In concrete terms, this package provides the following features:
Compositional data types in the style of Wouter Swierstra's Functional Pearl Data types a la carte.
Modular definition of functions on compositional data types through catamorphisms and anamorphisms as well as more structured recursion schemes such as primitive recursion and co-recursion, and course-of-value iteration and co-iteration.
Support for monadic computations via monadic variants of all recursion schemes.
Support of a succinct programming style over compositional data types via generic programming combinators that allow various forms of generic transformations and generic queries.
Generalisation of compositional data types (terms) to compositional data types "with holes" (contexts). This allows flexible reuse of a wide variety of catamorphisms (called term homomorphisms) as well as an efficient composition of them.
Operations on signatures, for example, to add and remove annotations of abstract syntax trees. This includes combinators to propagate annotations fully automatically through certain term homomorphisms.
Optimisation of the implementation of recursion schemes. This includes short-cut fusion style optimisation rules which yield a performance boost of up to factor six.
Automatic derivation of instances of all relevant type classes for using compositional data types via Template Haskell. This includes instances of Prelude.Eq, Prelude.Ord and Prelude.Show that are derived via instances for functorial variants of them. Additionally, also smart constructors, which allow to easily construct inhabitants of compositional data types, are automatically generated.
Mutually recursive data types and generalised algebraic data types (GADTs). All of the above is also lifted to families of mutually recursive data types and (more generally) GADTs. This extension resides in the module Data.Comp.Multi.
Parametric compositional data types (Workshop on Mathematically Structured Functional Programming, 3-24, 2012, http://dx.doi.org/10.4204/EPTCS.76.3). All of the above is also lifted to parametric data types, which enables support for parametric higher-order abstract syntax (PHOAS). This extension resides in the module Data.Comp.Param.
Generalised parametric compositional data types. All of the above is also lifted to generalised parametric data types, which enables support for typed parametric higher-order abstract syntax (PHOAS). This extension resides in the module Data.Comp.MultiParam.
Advanced recursion schemes derived from tree automata. These recursion schemes allow for a higher degree of modularity and make it possible to apply fusion. See Modular Tree Automata (Mathematics of Program Construction, 263-299, 2012, http://dx.doi.org/10.1007/978-3-642-31113-0_14).
Examples of using (generalised) (parametric) compositional data types are bundled with the package in the libray examples.
- No changelog available
|Versions||0.1, 0.2, 0.3, 0.4, 0.4.1, 0.5, 0.5.1, 0.5.2, 0.5.3, 0.6, 0.6.1, 0.6.1.1, 0.6.1.2, 0.6.1.3, 0.6.1.4, 0.7, 0.7.0.1|
|Dependencies||base (==4.*), containers, deepseq, derive, mtl, QuickCheck (>=2), template-haskell, th-expand-syns, transformers|
|Author||Patrick Bahr, Tom Hvitved|
|Source repository||head: hg clone https://bitbucket.org/paba/compdata|
|Upload date||Sun May 19 09:26:27 UTC 2013|
- compdata-0.6.1.3.tar.gz [browse] (Cabal source package)
- Package description (included in the package)
For package maintainers and hackage trustees