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).
Chapter PDF
References
C++ Standard, ISO/IEC 14882:2003(E). ANSI-ISO-IEC, ANSI standards for information technology edition (2003)
Austern, M.H.: Generic Programming and the STL: Using and Extending the C++ Standard Template Library. Addison-Wesley, Reading (1998)
Bernardy, J.-P., Jansson, P., Zalewski, M., Schupp, S., Priesnitz, A.: A comparison of C++ concepts and Haskell type classes. In: Proc. ACM SIGPLAN Workshop on Generic Programming, pp. 37–48. ACM, New York (2008)
Brooks, N.: Vulnerability, risk and adaptation: A conceptual framework. Tyndall Center Working Paper 38 (2003)
Chakravarty, M.M.T., Keller, G., Jones, S.P.: Associated type synonyms. In: ICFP 2005: Proceedings of the tenth ACM SIGPLAN international conference on Functional programming, pp. 241–253. ACM, New York (2005)
Claessen, K., Hughes, J.: QuickCheck: A lightweight tool for random testing of Haskell programs. In: ICFP 2000: International Conference on Functional Programming, pp. 268–279. ACM, New York (2000)
Garcia, R., Jarvi, J., Lumsdaine, A., Siek, J., Willcock, J.: An extended comparative study of language support for generic programming. J. Funct. Program 17(2), 145–205 (2007)
Gregor, D., Järvi, J., Siek, J., Stroustrup, B., Dos Reis, G., Lumsdaine, A.: Concepts: Linguistic support for generic programming in C++. In: Proc. ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), pp. 291–310. ACM Press, New York (2006)
Gregor, D., Marcus, M., Witt, T., Lumsdaine, A.: Foundational concepts for the C++ox standard library (revision 4). Technical Report N2737=08-0247, ISO/IEC JTC 1, Information Technology, Subcommittee SC 22, Programming Language C++ (August 2008a)
Gregor, D., Siek, J., Lumsdaine, A.: Iterator concepts for the C++ox standard library (revision 4). Technical Report N2739=08-0249, ISO/IEC JTC 1, Information Technology, Subcommittee SC 22, Programming Language C++ (August 2008b)
Gregor, D., Stroustrup, B., Widman, J., Siek, J.: Proposed wording for concepts (revision 8). Technical Report N2741=08-0251, ISO/IEC JTC1/SC22/WG21 - C++ (August 2008c)
de Guzman, J., Marsden, D.: Fusion library homepage (March 2009), http://www.boost.org/libs/fusion
Halpern, P.: Defects and proposed resolutions for allocator concepts. Technical Report N2810=08-0320, ISO/IEC JTC1/SC22/WG21 - C++ (December 2008)
Hudak, P.: Building domain-specific embedded languages. ACM Comput. Surv., 196 (1996)
Ionescu, C.: Vulnerability Modelling and Monadic Dynamical Systems. PhD thesis, Freie Universität Berlin (2009)
Janssen, M.A., Ostrom, E.: Resilience, vulnerability and adaptation: A cross-cutting theme of the international human dimensions programme on global environmental change. Global Environmental Change 16(3), 237–239 (2006) (Editorial)
Jansson, P., Jeuring, J.: Polytypic data conversion programs. Science of Computer Programming 43(1), 35–75 (2002)
Järvi, J., Powell, G., Lumsdaine, A.: The lambda library: Unnamed functions in C++. Software: Practice and Experience 33(3), 259–291 (2003)
Kamin, S.N., Hyatt, D.: A special-purpose language for picture-drawing. In: Proc. Conference on Domain-Specific Languages (DSL), pp. 297–310. USENIX Association (1997)
McNamara, B., Smaragdakis, Y.: Functional programming with the FC++ library. J. of Functional Programming 14(4), 429–472 (2004)
Oliveira, B.C.d.S., Hinze, R., Löh, A.: Extensible and modular generics for the masses. In: Nilsson, H. (ed.) Trends in Functional Programming, pp. 199–216 (2006)
Peterson, J., Hudak, P., Elliott, C.: Lambda in motion: Controlling robots with haskell. In: Gupta, G. (ed.) PADL 1999. LNCS, vol. 1551, pp. 91–105. Springer, Heidelberg (1999)
Petoukhov, V., Ganopolski, A., Brovkin, V., Claussen, M., Eliseev, A., Kubatzki, C., Rahmstorf, S.: CLIMBER-2: a climate system model of intermediate complexity. Part I: model description and performance for present climate. Climate dynamics 16, 1–17 (2000)
Peyton Jones, S. (ed.): Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)
Schrijvers, T., Peyton Jones, S., Chakravarty, M., Sulzmann, M.: Type checking with open type functions. In: ICFP 2008: Proceeding of the 13th ACM SIGPLAN international conference on Functional programming, pp. 51–62. ACM, New York (2008)
Siek, J.G., Lee, L.Q., Lumsdaine, A.: The Boost Graph Library: User Guide and Reference Manual. Addison-Wesley, Reading (2002)
Stepanov, A.A., Lee, M.: The Standard Template Library. Technical Report HPL-94-34, Hewlett-Packard Laboratories, Revised in, as tech. rep. HPL-95-11 (May 1994)
Stroustrup, B.: The C++ Programming Language, 3rd edn. Addison-Wesley, Reading (1997)
Vandervoorde, D., Josuttis, N.M.: C++ Templates: The Complete Guide. Addison-Wesley, Amsterdam (2002)
Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad hoc. In: Proc. 16th ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages (POPL), pp. 60–76. ACM Press, New York (1989)
Wolf, S., Lincke, D., Hinkel, J., Ionescu, C., Bisaro, S.: A formal framework of vulnerability. Final deliverable to the ADAM project. FAVAIA working paper 8, Potsdam Institute for Climate Impact Research, Potsdam, Germany (2008), http://www.pik-potsdam.de/favaia/pubs/favaiaworkingpaper8.pdf
Zalewski, M., Priesnitz, A.P., Ionescu, C., Botta, N., Schupp, S.: Multi-language library development: From Haskell type classes to C++ concepts. In: Striegnitz, J. (ed.) Proc. 6th Int. Workshop on Multiparadigm Programming With Object-Oriented Languages (MPOOL) (July 2007)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2009 IFIP International Federation for Information Processing
About this paper
Cite this paper
Lincke, D., Jansson, P., Zalewski, M., Ionescu, C. (2009). Generic Libraries in C++ with Concepts from High-Level Domain Descriptions in Haskell. In: Taha, W.M. (eds) Domain-Specific Languages. DSL 2009. Lecture Notes in Computer Science, vol 5658. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-03034-5_12
Download citation
DOI: https://doi.org/10.1007/978-3-642-03034-5_12
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-03033-8
Online ISBN: 978-3-642-03034-5
eBook Packages: Computer ScienceComputer Science (R0)