Generic Libraries in C++ with Concepts from High-Level Domain Descriptions in Haskell

A class of closely related problems, a problem domain, can often be described by a domain-specific language, which consists of algorithms and combinators useful for solving that particular class of problems. Such a language can be of two kinds: it can form a new language or it can be embedded as a sublanguage in an existing one. We describe an embedded DSL in the form of a library which extends a general purpose language. Our domain is that of vulnerability assessment in the context of climate change, formally described at the Potsdam Institute for Climate Impact Research. The domain is described using Haskell, yielding a domain specific sublanguage of Haskell that can be used for prototyping of implementations. In this paper we present a generic C++ library that implements a domain-specific language for vulnerability assessment, based on the formal Haskell description. The library rests upon and implements only a few notions, most importantly, that of a monadic system, a crucial part in the vulnerability assessment formalisation. We describe the Haskell description of monadic systems and we show our mapping of the description to generic C++ components. Our library heavily relies on concepts , a C++ feature supporting generic programming: a conceptual framework forms the domain-specific type system of our library. By using functions, parametrised types and concepts from our conceptual framework, we represent the combinators and algorithms of the domain. Furthermore, we discuss what makes our library a domain specific language and how our domain-specific library scheme can be used for other domains (concerning language design, software design, and implementation techniques).

[1]  Bjarne Stroustrup,et al.  Concepts: linguistic support for generic programming in C++ , 2006, OOPSLA '06.

[2]  Douglas Gregor,et al.  C++ Templates: The Complete Guide , 2002 .

[3]  C. Ionescu Vulnerability modeling and monadic dynamical systems , 2009 .

[4]  Jaakko Järvi,et al.  An extended comparative study of language support for generic programming , 2007, Journal of Functional Programming.

[5]  Bruno C. d. S. Oliveira,et al.  Extensible and modular generics for the masses , 2006, Trends in Functional Programming.

[6]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[7]  Katharina Thywissen Core terminology of disaster reduction : a comparative glossary , 2006 .

[8]  Simon L. Peyton Jones,et al.  Associated type synonyms , 2005, ICFP '05.

[9]  Jim Law,et al.  Review of "The boost graph library: user guide and reference manual by Jeremy G. Siek, Lie-Quan Lee, and Andrew Lumsdaine." Addison-Wesley 2002. , 2003, SOEN.

[10]  Alexander A. Stepanov,et al.  C++ Standard Template Library , 2000 .

[11]  Yannis Smaragdakis,et al.  Functional programming with the FC++ library , 2004, J. Funct. Program..

[12]  Paul Hudak,et al.  Building domain-specific embedded languages , 1996, CSUR.

[13]  Elinor Ostrom,et al.  Resilience, vulnerability, and adaptation: A cross-cutting theme of the International Human Dimensions Programme on Global Environmental Change , 2006, Global Environmental Change.

[14]  Koen Claessen,et al.  QuickCheck: a lightweight tool for random testing of Haskell programs , 2000, ICFP.

[15]  Matthew H. Austern Generic programming and the STL - using and extending the C++ standard template library , 1999, Addison-Wesley professional computing series.

[16]  N. Brooks Vulnerability, risk and adaptation: A conceptual framework , 2002 .

[17]  Judy Pearsall,et al.  Oxford Dictionary of English , 2010 .

[18]  Sibylle Schupp,et al.  The function concept in C++: an empirical study , 2009, WGP '09.

[19]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[20]  Johan Jeuring,et al.  Polytypic data conversion programs , 2002, Sci. Comput. Program..

[21]  Michael J. Vilot,et al.  Standard template library , 1996 .

[22]  Samuel N. Kamin,et al.  A Special-Purpose Language for Picture-Drawing , 1997, DSL.

[23]  Sibylle Schupp,et al.  A comparison of c++ concepts and haskell type classes , 2008, WGP '08.

[24]  Douglas Gregor,et al.  Proposed Wording for Concepts (Revision 3) , 2007 .

[25]  Jeremy G. Siek,et al.  The Boost Graph Library - User Guide and Reference Manual , 2001, C++ in-depth series.

[26]  Jaakko Järvi,et al.  The Lambda Library: unnamed functions in C++ , 2003, Softw. Pract. Exp..

[27]  Simon L. Peyton Jones,et al.  Type checking with open type functions , 2008, ICFP.

[28]  Sibylle Schupp,et al.  Multi-Language Library Development. From Haskell Type Classes to C++ Concepts. , 2007 .

[29]  Victor Brovkin,et al.  CLIMBER-2: a climate system model of intermediate complexity. Part I: model description and performance for present climate , 2000 .

[30]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[31]  Paul Hudak,et al.  Lambda in Motion: Controlling Robots with Haskell , 1999, PADL.