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

  • Authors:
  • Daniel Lincke;Patrik Jansson;Marcin Zalewski;Cezar Ionescu

  • Affiliations:
  • Potsdam Institute for Climate Impact Research, Potsdam, Germany;Chalmers University of Technology & University of Gothenburg, Gothenburg, Sweden;Chalmers University of Technology & University of Gothenburg, Gothenburg, Sweden;Potsdam Institute for Climate Impact Research, Potsdam, Germany

  • Venue:
  • DSL '09 Proceedings of the IFIP TC 2 Working Conference on Domain-Specific Languages
  • Year:
  • 2009

Quantified Score

Hi-index 0.02

Visualization

Abstract

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