Skip to main content

Project Paper: Embedding Generic Monadic Transformer into Scala

Can We Merge Monadic Programming into Mainstream?

  • Conference paper
  • First Online:
Trends in Functional Programming (TFP 2022)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 13401))

Included in the following conference series:

Abstract

Dotty-cps-async is an open-source package that consists of scala macro, which implements generic async/await via monadic cps transform, and library, which provides monadic substitutions for higher-order functions from the standard library. It allows developers to use direct control flow constructions of the base language instead of monadic DSL for various applications. Behind well-known async/await operations, the package provides options for transforming higher-order function applications, generating call-chain proxies, and automatic coloring.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

References

  1. Adam, Ghahramani, Z., Gordon, A.D.: Practical probabilistic programming with monads. SIGPLAN Not. 50(12), 165–176 (2015). https://doi.org/10.1145/2887747.2804317

  2. Brachthäuser, J.I., Schuster, P., Ostermann, K.: Effekt: capability-passing style for type- and effect-safe, extensible effect handlers in scala. J. Funct. Program. 30, e8 (2020). https://doi.org/10.1017/S0956796820000027

  3. Brachthäuser, J., Boruch-Gruszecki, A., Odersky, M.: Representing monads with capabilities. Technical report, Higher-Order Programming with Effects (HOPE) (2021). https://github.com/lampepfl/monadic-reflection

  4. Claessen, K.: A poor man’s concurrency monad. J. Funct. Program. 9(3), 313–323 (1999). https://doi.org/10.1017/S0956796899003342

    Article  MATH  Google Scholar 

  5. Erwig, M., Ren, D.: Monadification of functional programs. Sci. Comput. Program. 52(1–3), 101–129 (2004). https://doi.org/10.1016/j.scico.2004.03.004

    Article  MathSciNet  MATH  Google Scholar 

  6. Filinski, A.: Representing monads. In: Proceedings of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1994, Association for Computing Machinery, New York, pp. 446–457 (1994). https://doi.org/10.1145/174675.178047

  7. Haller, P., Lightbend: scala-async (2013). https://github.com/scala-async/scala-async

  8. Haller, P., Miller, H.: A formal model for direct-style asynchronous observables. CoRR abs/1511.00511 (2015). http://arxiv.org/abs/1511.00511

  9. Hatcliff, J., Danvy, O.: A generic account of continuation-passing styles. In: Proceedings of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1994, Association for Computing Machinery, New York, pp. 458–471 (1994). https://doi.org/10.1145/174675.178053

  10. Hoare, C.: Communicating Sequential Processes. Prentice-Hall International Series in Computer Science, Prentice Hall (1985). http://www.usingcsp.com/cspbook.pdf

  11. Hudak, P.: Building domain-specific embedded languages. ACM Comput. Surv. 28(4es), 196-es (1996). https://doi.org/10.1145/242224.242477

  12. Kiselyov, O., Shan, C.c., Friedman, D.P., Sabry, A.: Backtracking, interleaving, and terminating monad transformers: (functional pearl). SIGPLAN Not. 40(9), 192–203 (2005). https://doi.org/10.1145/1090189.1086390

  13. Oracle: Project loom (2018–2022). https://openjdk.java.net/projects/loom/

  14. Petricek, T., Syme, D.: The F# computation expression zoo. In: Proceedings of Practical Aspects of Declarative Languages. PADL 2014 (2014)

    Google Scholar 

  15. Prokopec, A., Liu, F.: Theory and practice of coroutines with snapshots. In: Millstein, T. (ed.) 32nd European Conference on Object-Oriented Programming (ECOOP 2018). Leibniz International Proceedings in Informatics (LIPIcs), vol. 109, pp. 3:1–3:32. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany (2018). https://doi.org/10.4230/LIPIcs.ECOOP.2018.3, http://drops.dagstuhl.de/opus/volltexte/2018/9208

  16. Rompf, T., Amin, N., Moors, A., Haller, P., Odersky, M.: Scala-virtualized: linguistic reuse for deep embeddings. High.-Order Symbolic Comput. 25(1), 165–207 (2013). https://doi.org/10.1007/s10990-013-9096-9

    Article  Google Scholar 

  17. Rompf, T., Maier, I., Odersky, M.: Implementing first-class polymorphic delimited continuations by a type-directed selective CPS-transform. In: Hutton, G., Tolmach, A.P. (eds.) Proceeding of the 14th ACM SIGPLAN International Conference on Functional programming, ICFP 2009, Edinburgh, Scotland, UK, 31 August–2 September, 2009, pp. 317–328. ACM (2009). https://doi.org/10.1145/1596550.1596596

  18. Syme, D.: The early history of F#. Proc. ACM Program. Lang. 4(HOPL) (2020). https://doi.org/10.1145/3386325

  19. Wadler, P., Thiemann, P.: The marriage of effects and monads. ACM Trans. Comput. Logic 4(1), 1–32 (Jan 2003). https://doi.org/10.1145/601775.601776

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Ruslan Shevchenko .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2022 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Shevchenko, R. (2022). Project Paper: Embedding Generic Monadic Transformer into Scala. In: Swierstra, W., Wu, N. (eds) Trends in Functional Programming. TFP 2022. Lecture Notes in Computer Science, vol 13401. Springer, Cham. https://doi.org/10.1007/978-3-031-21314-4_1

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-21314-4_1

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-21313-7

  • Online ISBN: 978-3-031-21314-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics