Abstract
Capturing control flow is the Achilles heel of Haskell-based deeply embedded domain specific languages. Rather than use the builtin control flow mechanisms, artificial control flow combinators are used instead. However, capturing traditional control flow in a deeply embedded domain specific language would support the writing of programs in a natural style by allowing the programmer to use the constructs that are already builtin to the base language, such as pattern matching and recursion. In this paper, we expand the capabilities of Haskell-based deep embeddings with a compiler extension for reifying conditionals and pattern matching. With this new support, the subset of Haskell that we use for expressing deeply embedded domain specific languages can be cleaner, Haskell-idiomatic, and more declarative in nature.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
Atkey, R., Lindley, S., Yallop, J.: Unembedding domain-specific languages. In: Proceedings of the 2nd ACM SIGPLAN Symposium on Haskell, Haskell 2009, pp. 37–48. Association for Computing Machinery, New York (2009). https://doi.org/10.1145/1596638.1596644
Axelsson, E., et al.: Feldspar: a domain specific language for digital signal processing algorithms. In: MEMOCODE 2010, pp. 169–178 (2010)
Bird, R.: Pearls of Functional Algorithm Design. Cambridge University Press, Cambridge (2010). https://doi.org/10.1017/CBO9780511763199
Elliott, C.: (2015). https://github.com/conal/lambda-ccc
Elliott, C.: (2015). https://github.com/conal/talk-2015-haskell-to-hardware
Elliott, C.: (2016). https://github.com/conal/reification-rules
Elliott, C.: Compiling to categories. Proc. ACM Program. Lang. 1(ICFP) (2017). https://doi.org/10.1145/3110271. http://conal.net/papers/compiling-to-categories
Elliott, C.: The simple essence of automatic differentiation. In: Proceedings of the ACM on Programming Languages (ICFP) (2018). http://conal.net/papers/essence-of-ad/
Elliott, C.: Generalized convolution and efficient language recognition (extended version). CoRR abs/1903.10677 (2019). https://arxiv.org/abs/1903.10677
Elliott, C., Finne, S., de Moor, O.: Compiling embedded languages. J. Funct. Program. 13(2) (2003). http://conal.net/papers/jfp-saig/. updated version of paper by the same name that appeared in SAIG ’00 proceedings
Elliott, T., et al.: Guilt free ivory. In: Proceedings of the 8th ACM SIGPLAN Symposium on Haskell, pp. 189–200. ACM (2015)
Ganz, S.E., Friedman, D.P., Wand, M.: Trampolined style. In: Proceedings of the Fourth ACM SIGPLAN International Conference on Functional Programming, ICFP 1999, pp. 18–27. Association for Computing Machinery, New York (1999). https://doi.org/10.1145/317636.317779
Gibbons, J.: Calculating functional programs. In: Backhouse, R., Crole, R., Gibbons, J. (eds.) Algebraic and Coalgebraic Methods in the Mathematics of Program Construction. LNCS, vol. 2297, pp. 151–203. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-47797-7_5
Gill, A.: Domain-specific languages and code synthesis using Haskell. Commun. ACM 57(6), 42–49 (2014). https://doi.org/10.1145/2605205
Gill, A., Hutton, G.: The worker/wrapper transformation. J. Funct. Program. 19(2), 227–251 (2009)
Grebe, M., Young, D., Gill, A.: Rewriting a shallow DSL using a GHC compiler extension. In: Proceedings of the 16th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences, GPCE 2017, pp. 246–258. ACM, New York (2017). https://doi.org/10.1145/3136040.3136048
Jovanovic, V., Shaikhha, A., Stucki, S., Nikolaev, V., Koch, C., Odersky, M.: Yin-yang: Concealing the deep embedding of DSLs. In: Proceedings of the 2014 International Conference on Generative Programming: Concepts and Experiences, GPCE 2014, pp. 73–82. Association for Computing Machinery, New York (2014). https://doi.org/10.1145/2658761.2658771
Persson, A., Axelsson, E., Svenningsson, J.: Generic monadic constructs for embedded languages. In: Gill, A., Hage, J. (eds.) IFL 2011. LNCS, vol. 7257, pp. 85–99. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-34407-7_6
Sculthorpe, N., Bracker, J., Giorgidze, G., Gill, A.: The constrained-monad problem. In: Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming, pp. 287–298. ACM (2013). http://dl.acm.org/citation.cfm?doid=2500365.2500602
Sujeeth, A.K., et al.: Delite: a compiler architecture for performance-oriented embedded domain-specific languages. ACM Trans. Embedd. Comput. Syst. (TECS) 13(4s), 1–25 (2014)
Sujeeth, A.K., et al.: Forge: generating a high performance DSL implementation from a declarative specification. In: Proceedings of the 12th International Conference on Generative Programming: Concepts and Experiences, GPCE 2013, pp. 145–154. ACM, New York (2013). https://doi.org/10.1145/2517208.2517220
Svenningsson, J., Axelsson, E.: Combining deep and shallow embedding for EDSL. In: Loidl, H.-W., Peña, R. (eds.) TFP 2012. LNCS, vol. 7829, pp. 21–36. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-40447-4_2
Svenningsson, J.D., Svensson, B.J.: Simple and compositional reification of monadic embedded languages. In: Proceedings of the 18th International Conference on Functional Programming, pp. 299–304. ACM (2013)
Vytiniotis, D., Weirich, S., Peyton Jones, S.: Simple unification-based type inference for GADTs. In: International Conference on Functional Programming (ICFP 2006). ACM SIGPLAN (2006). https://www.microsoft.com/en-us/research/publication/simple-unification-based-type-inference-for-gadts/. 2016 ACM SIGPLAN Most Influential ICFP Paper Award
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2021 Springer Nature Switzerland AG
About this paper
Cite this paper
Young, D., Grebe, M., Gill, A. (2021). On Adding Pattern Matching to Haskell-Based Deeply Embedded Domain Specific Languages. In: Morales, J.F., Orchard, D. (eds) Practical Aspects of Declarative Languages. PADL 2021. Lecture Notes in Computer Science(), vol 12548. Springer, Cham. https://doi.org/10.1007/978-3-030-67438-0_2
Download citation
DOI: https://doi.org/10.1007/978-3-030-67438-0_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-67437-3
Online ISBN: 978-3-030-67438-0
eBook Packages: Computer ScienceComputer Science (R0)