skip to main content
10.1145/2847538.2847541acmconferencesArticle/Chapter ViewAbstractPublication PagespepmConference Proceedingsconference-collections
research-article

Everything old is new again: quoted domain-specific languages

Published:11 January 2016Publication History

ABSTRACT

We describe a new approach to implementing Domain-Specific Languages(DSLs), called Quoted DSLs (QDSLs), that is inspired by two old ideas:quasi-quotation, from McCarthy's Lisp of 1960, and the subformula principle of normal proofs, from Gentzen's natural deduction of 1935. QDSLs reuse facilities provided for the host language, since host and quoted terms share the same syntax, type system, and normalisation rules. QDSL terms are normalised to a canonical form, inspired by the subformula principle, which guarantees that one can use higher-order types in the source while guaranteeing first-order types in the target, and enables using types to guide fusion. We test our ideas by re-implementing Feldspar, which was originally implemented as an Embedded DSL (EDSL), as a QDSL; and we compare the QDSL and EDSL variants. The two variants produce identical code.

References

  1. J. Ankner and J. Svenningsson. An EDSL approach to high performance Haskell programming. In Haskell. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Z. Ariola and M. Felleisen. The call-by-need lambda calculus. JFP, 7(03), 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. E. Axelsson, K. Claessen, G. Dévai, Z. Horváth, K. Keijzer, B. Lyckeg˚ard, A. Persson, M. Sheeran, J. Svenningsson, and A. Vajda. Feldspar: A domain specific language for digital signal processing algorithms. In MEMOCODE. IEEE, 2010.Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J. Bentley. Programming pearls: Little languages. CACM, 29(8), 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. A. Bondorf and O. Danvy. Automatic autoprojection of recursive equations with global variables and abstract data types. SCP, 16(2), 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. M. M. T. Chakravarty, G. Keller, S. L. P. Jones, and S. Marlow. Associated types with class. In POPL. ACM, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. J. Cheney, S. Lindley, and P. Wadler. A practical theory of languageintegrated query. In ICFP. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. J. Cheney, S. Lindley, G. Radanne, and P. Wadler. Effective quotation: relating approaches to language-integrated query. In PEPM. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. J. Cheney, S. Lindley, and P. Wadler. Query shredding: efficient relational evaluation of queries over nested multisets. In SIGMOD, pages 1027– 1038. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. K. Claessen and D. Sands. Observable sharing for functional circuit description. In ASIAN. Springer, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. K. Claessen, M. Sheeran, and B. Svensson. Expressive array constructs in an embedded GPU kernel programming language. In DAMP. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. E. Cooper. The script-writer’s dream. In DBPL. ACM, 2009.Google ScholarGoogle Scholar
  13. O. Danvy. Type-directed partial evaluation. In POPL. ACM, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. R. Davies and F. Pfenning. A modal analysis of staged computation. JACM, 48(3), 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. P. Dybjer and A. Filinski. Normalization and partial evaluation. In APPSEM. Springer, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Eckhardt, R. Kaiabachev, E. Paˇsali´c, K. Swadi, and W. Taha. Implicitly heterogeneous multi-stage programming. New Generation Computing, 25(3), 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The essence of compiling with continuations. In PLDI. ACM, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. M. Flatt. Reference: Racket. Technical Report PLT-TR-2010-1, PLT Inc., 2010.Google ScholarGoogle Scholar
  19. G. Gentzen. Untersuchungen über das logische schließen. i. Mathematische zeitschrift, 39(1), 1935.Google ScholarGoogle Scholar
  20. A. Gill. Type-safe observable sharing in Haskell. In Haskell. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. A. Gill. Domain-specific languages and code synthesis using Haskell. CACM, 57(6), 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. G. Giorgidze and H. Nilsson. Embedding a functional hybrid modelling language in Haskell. In IFL. Springer, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. T. Hart. MACRO definitions for LISP. Technical Report AIM-057, MIT, 1963. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. W. Howard. The formulae-as-types notion of construction. In To H. B. Curry. Academic Press, 1980.Google ScholarGoogle Scholar
  25. P. Hudak. Domain-specific languages. In Handbook of Programming Languages. MacMillan, 1997.Google ScholarGoogle Scholar
  26. J. Hughes. Restricted data types in Haskell. In Haskell. ACM, 1999.Google ScholarGoogle Scholar
  27. N. Jones, C. Gomard, and P. Sestoft. Partial evaluation and automatic program generation. Prentice Hall, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. L. Kats and E. Visser. The spoofax language workbench. In OOPSLA. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. S. Lindley and J. Cheney. Row-based effect types for database integration. In TLDI. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. S. Lindley. Normalisation by Evaluation in the Compilation of Typed Functional Programming Languages. PhD thesis, University of Edinburgh, 2005.Google ScholarGoogle Scholar
  31. S. Lindley. Extensional rewriting with sums. In TLCA. Springer, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. G. Mainland and G. Morrisett. Nikola: embedding compiled GPU functions in Haskell. In Haskell. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. G. Mainland. Explicitly heterogeneous metaprogramming with Meta-Haskell. In ICFP. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. J. Maraist, M. Odersky, and P. Wadler. The call-by-need lambda calculus. JFP, 8(03), 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. J. McCarthy. Recursive functions of symbolic expressions and their computation by machine, Part I. CACM, 3(4), 1960. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. E. Meijer, B. Beckman, and G. Bierman. LINQ: reconciling object, relations and XML in the .NET framework. In SIGMOD. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. E. Moggi. Notions of computation and monads. Inf. Comput., 93(1), 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. F. Nielson and H. Nielson. Two-level functional languages. Cambridge University Press, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. J. O’Donnell. Generating netlists from executable circuit specifications in a pure functional language. In Functional Programming, Glasgow. Springer, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. A. Persson, E. Axelsson, and J. Svenningsson. Generic monadic constructs for embedded languages. In IFL. Springer, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. S. Peyton Jones, S. Marlow, and C. Elliott. Stretching the storage manager: Weak pointers and stable names in Haskell. In IFL. Springer, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. F. Pfenning and C. Elliott. Higher-order abstract syntax. In PLDI. ACM, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. D. Prawitz. Natural Deduction: A Proof-Theoretical Study. Almqvist and Wiksell, 1965.Google ScholarGoogle Scholar
  44. T. Rompf and M. Odersky. Lightweight modular staging: a pragmatic approach to runtime code generation and compiled DSLs. In GPCE. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. T. Rompf, N. Amin, A. Moors, P. Haller, and M. Odersky. Scala-Virtualized: linguistic reuse for deep embeddings. In HOSC. Springer, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. T. Rompf. Lightweight Modular Staging and Embedded Compilers: Abstraction without Regret for High-Level High-Performance Programming. PhD thesis, EPFL, 2012.Google ScholarGoogle Scholar
  47. D. Schoepe, D. Hedin, and A. Sabelfeld. SeLINQ: tracking information across application-database boundaries. In J. Jeuring and M. M. T. Chakravarty, editors, ICFP. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. N. Sculthorpe, J. Bracker, G. Giorgidze, and A. Gill. The constrainedmonad problem. In ICFP. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. A. K. Sujeeth, T. Rompf, K. J. Brown, H. Lee, H. Chafi, V. Popic, M. Wu, A. Prokopec, V. Jovanovic, M. Odersky, and K. Olukotun. Composition and reuse with compiled domain-specific languages. In ECOOP. Springer, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. A. K. Sujeeth, K. J. Brown, H. Lee, T. Rompf, H. Chafi, M. Odersky, and K. Olukotun. Delite: a compiler architecture for performance-oriented embedded domain-specific languages. TECS, 13(4s), 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. K. Suzuki, O. Kiselyov, and Y. Kameyama. Finally, safely-extensible and efficient language integrated query. In PEPM. ACM, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. J. Svenningsson and E. Axelsson. Combining deep and shallow embedding for EDSL. In TFP. Springer, 2012.Google ScholarGoogle Scholar
  53. J. Svenningsson and B. Svensson. Simple and compositional reification of monadic embedded languages. In ICFP. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. J. Svensson, M. Sheeran, and K. Claessen. Obsidian: A domain specific embedded language for parallel programming of graphics processors. In IFL. Springer, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. D. Syme. Leveraging .NET meta-programming components from F#: integrated queries and interoperable heterogeneous execution. In ML. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. W. Taha and T. Sheard. MetaML and multi-stage programming with explicit annotations. TCS, 248(1), 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  57. P. Wadler. Propositions as types. CACM, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  58. L. Wong. Normal forms and conservative extension properties for query languages over collection types. JCSS, 52(3), 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Everything old is new again: quoted domain-specific languages

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in
        • Published in

          cover image ACM Conferences
          PEPM '16: Proceedings of the 2016 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation
          January 2016
          108 pages
          ISBN:9781450340977
          DOI:10.1145/2847538

          Copyright © 2016 ACM

          Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 11 January 2016

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article

          Acceptance Rates

          Overall Acceptance Rate66of120submissions,55%

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader