The ExpLemmaLib

Status
The current release covers all aspects of the ExpLemma paper.

History

Authors
Ralf Lämmel and Ondrej Rypacek

Abstract
ExpLemmaLib is a Haskell library that supports dualizable programming in the sense that one can encode operations on data in a way that both a functional program and an OO program can be derived. The library and the accompanying samples are meant to illustrate the expression lemma. The main idea is to represent operations as distributive laws of a functor over a functor, where one of these functors models the data at hand, and the other functor models the types of the operations. In the general case, these functors also involve monadic capabilities based on the free monad or the cofree comonad. The library provides various combinators to construct distributive laws and to deploy them as functional or object-oriented programs. The namespace ExpSample develops an extended example which is structured as follows. The modules in the namespace ExpSample/Data define a type of arithmetic expressions. For illustrative purposes, different styles of type definition are exercised. The module ExpSample/Baseline defines a number of functions on arithmetic expressions in the style of general recursion. The functions are chosen to exercise the different idioms that can be encountered in dualizable programming. The modules in the namespace ExpSample/Catas encode some of the sample functions in terms of the normal fold operation for arithmetic expressions. The folds are worked out for the different styles of type definition. More importantly, classic fold-based programming is compared with programming based on distributive laws. The modules in the namespace ExpSample/Duality illustrate the dualization of a simple functional program to an OO program, or vice versa. Dualization is shown for different styles of type definition. The library support for dualizable programming based on distributive laws is also illustrated. Ultimately, the modules in the namespace ExpSample/Idioms discipline and generalize the freewheeling programming style with the normal fold operation such that all baseline functions can be encoded in a dualizable manner.

Download

Table of contents


Website maintained by Ralf Lämmel (Email: rlaemmel@gmail.com)