Multi-Language Library Development. From Haskell Type Classes to C++ Concepts.
Paper in proceedings, 2007
We define a mapping from generic Haskell specifications to C++ with concepts, a recent extension to C++, that can ultimately be automated. More specifically, we provide a translation from Haskell multi-parameter type classes with functional dependencies to ConceptC++. Our translation consists of three major parts: the division of Haskell class variables into ConceptC++ concept parameters and associated types, the corresponding division of superclasses in the context of a type class, and the linearization of Haskell ASTs to the concrete syntax of ConceptC++. We also discuss cases in which there is no single correct translation from classes with functional dependencies to concepts. Our translation handles these cases in a reasonable way and is well-defined for the cases most common in practice. The translation is motivated by an ongoing project for distributed adaptive finite volume methods, in which software components are modeled in Haskell and implemented in C++.