skip to main content
research-article

The remote monad design pattern

Published:30 August 2015Publication History
Skip Abstract Section

Abstract

Remote Procedure Calls are expensive. This paper demonstrates how to reduce the cost of calling remote procedures from Haskell by using the remote monad design pattern, which amortizes the cost of remote calls. This gives the Haskell community access to remote capabilities that are not directly supported, at a surprisingly inexpensive cost. We explore the remote monad design pattern through six models of remote execution patterns, using a simulated Internet of Things toaster as a running example. We consider the expressiveness and optimizations enabled by each remote execution model, and assess the feasibility of our approach. We then present a full-scale case study: a Haskell library that provides a Foreign Function Interface to the JavaScript Canvas API. Finally, we discuss existing instances of the remote monad design pattern found in Haskell libraries.

References

  1. H. Apfelmus. Hackage package threepenny-gui-0.6.0.2, 2015.Google ScholarGoogle Scholar
  2. R. Bird. Using circular programs to eliminate multiple traversals of data. Acta Informatica, 21(3):239–250, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. A. D. Birrell and B. J. Nelson. Implementing remote procedure calls. Transactions on Computer Systems, 2(1):39–59, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J. Bracker and A. Gill. Sunroof: A monadic DSL for generating JavaScript. In International Symposium on Practical Aspects of Declarative Languages, volume 8324 of LNCS, pages 65–80. Springer, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. D. Burke. Hackage package mcpi-0.0.1.2, 2014.Google ScholarGoogle Scholar
  6. J. Carette, O. Kiselyov, and C. Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming, 19(05):509–543, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. M. M. T. Chakravarty, R. Clifton-Everest, G. Keller, S. Lee, B. Lever, T. L. McDonell, R. Newtown, and S. Seefried. Hackage package accelerate-0.15.1.0, 2015.Google ScholarGoogle Scholar
  8. K. Claessen, M. Sheeran, and B. J. Svensson. Expressive array constructs in an embedded GPU kernel programming language. In Workshop on Declarative Aspects and Applications of Multicore Programming, pages 21–30. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. A. Courtney, H. Nilsson, and J. Peterson. The Yampa arcade. In Haskell Workshop, pages 7–18. ACM, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. A. Ekblad. Hackage package haste-compiler-0.4.4.4, 2015.Google ScholarGoogle Scholar
  11. A. Ekblad and K. Claessen. A seamless, client-centric programming model for type safe web applications. In Haskell Symposium, pages 79–89. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. C. Elliott, S. Finne, and O. de Moor. Compiling embedded languages. Journal of Functional Programming, 13(3):455–481, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J. Epstein, A. P. Black, and S. Peyton Jones. Towards Haskell in the cloud. In Haskell Symposium, pages 118–129, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. L. Erkok. Hackage package hArduino-0.9, 2014.Google ScholarGoogle Scholar
  15. L. Erkok. Hackage package sbv-4.4, 2015.Google ScholarGoogle Scholar
  16. L. Erkök and J. Launchbury. Recursive monadic bindings. In International Conference on Functional Programming, pages 174–185. ACM, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. L. Erkök and J. Launchbury. A recursive do for Haskell. In Haskell Workshop, pages 29–37. ACM, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. B. Gamari. Hackage package bus-pirate-0.6.2, 2015.Google ScholarGoogle Scholar
  19. E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. A. Gill and J. Bracker. Hackage package sunroof-server-0.2.1, 2014.Google ScholarGoogle Scholar
  21. A. Gill and A. Farmer. Hackage package kansas-comet-0.3.1, 2014.Google ScholarGoogle Scholar
  22. A. Gill and R. Paterson. Hackage package transformers-0.4.3.0, 2015.Google ScholarGoogle Scholar
  23. T. Hannan. Hackage package mongoDB-2.0.5, 2015.Google ScholarGoogle Scholar
  24. P. C. Hickey, L. Pike, T. Elliott, J. Bielman, and J. Launchbury. Building embedded systems with embedded DSLs. In International Conference on Functional Programming, pages 3–9. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. P. Hudak. Modular domain specific languages and tools. In International Conference on Software Reuse, pages 134–142. IEEE Press, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. D. Leijen and E. Meijer. Domain specific embedded compilers. In Conference on Domain-Specific Languages, pages 109–122. ACM, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. S. Liang, P. Hudak, and M. Jones. Monad transformers and modular interpreters. In Symposium on Principles of Programming Languages, pages 333–343. ACM, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. R. Love. Get on the D-BUS. Linux Journal, 2005(130):3, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. S. Marlow, L. Brandy, J. Coens, and J. Purdy. There is no fork: An abstraction for efficient, concurrent, and concise data access. In International Conference on Functional Programming, pages 325– 337. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. C. McBride and R. Paterson. Applicative programming with effects. Journal of Functional Programming, 18:1–13, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. S. Microsystems. RPC: Remote procedure call protocol specification. Technical report, RFC 1050, Apr. 1988.Google ScholarGoogle Scholar
  32. S. Microsystems. RPC: Remote procedure call protocol specification: Version 2. Technical report, RFC 1057, June 1988.Google ScholarGoogle Scholar
  33. J. Millikin. Hackage package ncurses-0.2.11, 2014.Google ScholarGoogle Scholar
  34. E. Moggi. Computational lambda-calculus and monads. In Symposium on Logic in Computer Science, pages 14–23. IEEE Press, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. OpenCores Organization. Wishbone B4: WISHBONE System-on-Chip (SoC) Interconnection Architecture for Portable IP Cores, 2010. URL http://opencores.org/opencores,wishbone.Google ScholarGoogle Scholar
  36. B. O’Sullivan. Hackage package criterion-1.1.0.0, 2015.Google ScholarGoogle Scholar
  37. A. Persson, E. Axelsson, and J. Svenningsson. Generic monadic constructs for embedded languages. In Symposium on Implementation and Application of Functional Languages, volume 7257 of LNCS, pages 85–99. Springer, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. L. Pike, N. Wegmann, S. Niller, and A. Goodloe. A do-it-yourself high-assurance compiler. In International Conference on Functional Programming, pages 335–340. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. N. Sculthorpe. Hackage package yampa-canvas-0.2, 2014.Google ScholarGoogle Scholar
  40. N. Sculthorpe, J. Bracker, G. Giorgidze, and A. Gill. The constrainedmonad problem. In International Conference on Functional Programming, pages 287–298. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. J. Svenningsson and B. J. Svensson. Simple and compositional reification of monadic embedded languages. In International Conference on Functional Programming, pages 299–304. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. P. Wadler. Comprehending monads. In Conference on LISP and Functional Programming, pages 61–78. ACM, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. The remote monad design pattern

    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

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 50, Issue 12
      Haskell '15
      December 2015
      212 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2887747
      Issue’s Table of Contents
      • cover image ACM Conferences
        Haskell '15: Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell
        August 2015
        212 pages
        ISBN:9781450338080
        DOI:10.1145/2804302

      Copyright © 2015 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 30 August 2015

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!