MyNixOS website logo
Description

Compositional Data Types.

This library implements the ideas of Data types a la carte as outlined in the paper Compositional data types. The purpose of this library is to allow the programmer to construct data types -- as well as the functions defined on them -- in a modular fashion. The underlying idea is to separate the signature of a data type from the fixed point construction that produces its recursive structure. Signatures can then be composed and decomposed freely.

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 library provides the following features:

  • Compositional data types in the style of Wouter Swierstra's Functional Pearl Data types a la carte. The implementation of signature subsumption is based on the paper Composing and Decomposing Data Types (Workshop on Generic Programming, 2014, to appear), which makes signature composition more flexible.

  • 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.

Examples of using (generalised) compositional data types are bundled with the package in the folder examples.

There are some supplementary packages, some of which were included in previous versions of this package:

  • compdata-param: a parametric variant of compositional data types to deal with variable binders in a systematic way.

  • compdata-automata: advanced recursion schemes derived from tree automata that allow for a higher degree of modularity and make it possible to apply fusion.

  • compdata-dags: recursion schemes on directed acyclic graphs.

Metadata

Version

0.13.1

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows