You are here: Home PIK Members Daniel Lincke HaskC++ - Generic C++ programming from Haskell specification

HaskC++ - Generic C++ programming from Haskell specification

What is it about?

The type declaration of a static typed computer-program provides a kind of specification. Haskell, a functional programming language with an expressive type system is an appropriate candidate for prototype development of highly generic programs. We use Haskell to design executable specifications of generic libraries which are implemented in C++ with concepts. The type-specification of the Haskell-program is translated into a type-specification of the C++ library. As this transformation follows a well-defined scheme, it is supported by a type compiler.


How does it work?

We provide a algorithmic method which transforms type-specification from a Haskell program into a system of C++ classes and concepts. As the type-system of C++ does not provide the same features as the Haskell type system, we use concepts to simulate higher order functions and kinds. Such core concepts and associated operations are predefined and bundled in a library for concept-based functional C++ programming. The translation uses concepts from this libraries to encode type classes, type signature and function types.



There are several applications for the HaskC++. Historically, an early application was in the S-project, where a Haskell modell served as a executable specification of a generic C++ library for distributed adaptive finite volume methods. In the S-Project we did not rely on a systematic translation of types, but we  already reimplemented generic Haskell data structures in C++.  In the follow-up project FAVAIA the method of mathematical formalization using Haskell was refined and applied to develop a formal model of vulnerability in the context of climate change.  An executable description in Haskell introduced the notion of a monadic dynamical system to describe the various systems involved in vulnerability assessments. From this description a concept-based generic C++ library was implemented.
Recently the type compiler was used to reimplement datatype-generic libraries in C++: Origami++ provides a generic C++ library for Origami programming, and Scrap++ a library of generic functions that can traverse arbitrary data structures, and yet have type-specific cases.



Functional_C++_Concepts library
Haskell Type-Specification Compiler
Type-specification of the Origami library



  • D. Lincke, P. Jansson, M. Zalewski, C. Ionescu : Generic Libraries in C++ with Concepts from High-Level Domain Descriptions in Haskell. A Domain-Specific Library for Computational Vulnerability Assessment. In: Taha, Walid Mohamed (Ed.), Domain-Specific Languages, Proceedings of the IFIP TC 2 Working Conference, DSL 2009, Oxford, UK, July 15-17 2009.
  • D. Lincke, S. Schupp: The Function Concept in C++ - An Empirical Study. In: J. Gibbons, R. Paterson (Ed.), WGP'09: Proceedings of the 2009 ACM SIGPLAN workshop on Generic programming, Edinburgh, August 28-30 2009
  • D. Lincke, P. Jansson, M. Zalewski, C. Ionescu : Monadic Dynamical Systems in C++ with Concepts and in Haskell, submitted to Science of Computer Programming



Daniel Lincke


Document Actions