compdata: Compositional Data Types

[ bsd3, generics, library ] [ Propose Tags ]

Based on Wouter Swierstra's Functional Pearl Data types à la carte (Journal of Functional Programming, 18(4):423-436, 2008), this package provides a framework for defining recursive data types in a compositional manner. The fundamental idea of compositional data types 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 makes 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 à la carte.

  • Modular definition of function 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. All of the above is also lifted to families of mutually recursive data types.

For examples illustrating the use of compositional data types, consult Data.Comp resp. Data.Comp.Multi for mutually recursive data types.

Flags

Automatic Flags
NameDescriptionDefault
test

Build test executable.

Disabled
benchmark

Build benchmark executable.

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 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, 0.7.0.2, 0.8, 0.8.0.1, 0.8.1.0, 0.8.1.1, 0.8.1.2, 0.8.1.3, 0.9, 0.10, 0.10.1, 0.11, 0.12, 0.12.1, 0.13.0, 0.13.1
Dependencies base (>=4 && <5), containers, criterion, deepseq, derive, mtl, QuickCheck (>=2), random, template-haskell, test-framework, test-framework-quickcheck2, th-expand-syns, uniplate [details]
License BSD-3-Clause
Author Patrick Bahr, Tom Hvitved
Maintainer paba@diku.dk
Category Generics
Uploaded by PatrickBahr at 2011-03-24T14:23:38Z
Distributions LTSHaskell:0.13.1, NixOS:0.13.1, Stackage:0.13.1
Reverse Dependencies 11 direct, 4 indirect [details]
Executables benchmark, test
Downloads 26359 total (126 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]