Skip to main content

A Timed IO Monad

  • Conference paper
  • First Online:
Practical Aspects of Declarative Languages (PADL 2020)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 12007))

Included in the following conference series:

Abstract

Programming with explicit timing information is often tedious and error prone. This is especially visible in music programming where, when played, the specified durations of notes and rests must be shortened in order to compensate the actual duration of all surrounding processing. In this paper, we develop the notion of timed extension of a monad that aims at relieving programmers from such a burden. We show how, under simple conditions, such extensions can be built, and how useful features of monad programming such as asynchronous concurrency with promises or data-flow programming with monadic streams can be uniformly lifted to the resulting timed programming framework. Even though presented and developed in the abstract, the notion of timed extension of a monad is nevertheless illustrated by two concrete instances: a default timed IO monad where programmers specify durations in microseconds, and a musically timed IO monad, where programmers specify durations in number of beats, the underlying tempo, that is, the speed of the music in beats per minute, possibly changed whenever needed.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    A careful reading of this code shows that the resulting specified duration of a timed lifted action is, more precisely, the actual duration of its execution minus the existing time drift right before its execution.

References

  1. Archipoff, S., Janin, D.: Structured reactive programming with polymorphic temporal tiles. In: ACM Workshop on Functional Art, Music, Modeling and Design (FARM). ACM Press (2016)

    Google Scholar 

  2. Colaço, J.-L., Girault, A., Hamon, G., Pouzet, M.: Towards a higher-order synchronous data-flow language. In: International Conference on Embedded Software (EMSOFT), pp. 230–239. ACM (2004)

    Google Scholar 

  3. Elliott, C., Hudak, P.: Functional reactive animation. In: International Conference on Functional Programming (ICFP). ACM (1997)

    Google Scholar 

  4. Elliott, C.M.: Push-pull functional reactive programming. In: Symposium on Haskell, pp. 25–36. ACM (2009)

    Google Scholar 

  5. Giavitto, J.-L., Echeveste, J., Cont, A., Cuvillier, P.: Time, timelines and temporal scopes in the Antescofo DLS v1.0. In: International Computer Music Conference (ICMC) (2017)

    Google Scholar 

  6. Halstead Jr., R.H.: Multilisp: a language for concurrent symbolic computation. ACM Trans. Program. Lang. Syst. 7(4), 501–538 (1985)

    Article  Google Scholar 

  7. Hudak, P.: An algebraic theory of polymorphic temporal media. In: Jayaraman, B. (ed.) PADL 2004. LNCS, vol. 3057, pp. 1–15. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-24836-1_1

    Chapter  Google Scholar 

  8. Hudak, P., Janin, D.: From out-of-time design to in-time production of temporal media. Research report, LaBRI, Université de Bordeaux (2015)

    Google Scholar 

  9. Hudak, P., Quick, D.: The Haskell School of Music : From Signals to Symphonies. Cambridge University Press, Cambridge (2018)

    Book  Google Scholar 

  10. Janin, D.: Spatio-temporal domains: an overview. In: Fischer, B., Uustalu, T. (eds.) ICTAC 2018. LNCS, vol. 11187, pp. 231–251. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-02508-3_13

    Chapter  Google Scholar 

  11. Janin, D.: An equational modeling of asynchronous concurrent programming. Technical report, LaBRI, Université de Bordeaux (2019)

    Google Scholar 

  12. Janin, D.: Screaming in the IO monad. In: ACM Workshop on Functional Art, Music, Modeling and Design (FARM). ACM (2019)

    Google Scholar 

  13. Krishnaswami, N.R.: Higher-order functional reactive programming without spacetime leaks. In: International Conference on Functional Programming (ICFP) (2013)

    Google Scholar 

  14. Mandel, L., Pouzet, M.: ReactiveML, a reactive extension to ML. In: International Symposium on Principles and Practice of Declarative Programming (PPDP). ACM (2005)

    Google Scholar 

  15. Moggi, E.: A modular approach to denotational semantics. In: Pitt, D.H., Curien, P.-L., Abramsky, S., Pitts, A.M., Poigné, A., Rydeheard, D.E. (eds.) CTCS 1991. LNCS, vol. 530, pp. 138–139. Springer, Heidelberg (1991). https://doi.org/10.1007/BFb0013462

    Chapter  Google Scholar 

  16. Nilsson, H., Peterson, J., Hudak, P.: Functional hybrid modeling. In: Dahl, V., Wadler, P. (eds.) PADL 2003. LNCS, vol. 2562, pp. 376–390. Springer, Heidelberg (2003). https://doi.org/10.1007/3-540-36388-2_25

    Chapter  Google Scholar 

  17. van der Ploeg, A., Claessen, K.: Practical principled FRP: forget the past, change the future, FRPNow! In: International Conference on Functional Programming (ICFP), pp. 302–314. ACM (2015)

    Google Scholar 

  18. de Simone, R., Talpin, J.-P., Potop-Butucaru, D.: The synchronous hypothesis and synchronous languages. In: Embedded Systems Handbook. CRC Press (2005)

    Google Scholar 

  19. Wadler, P.: Comprehending monads. In: Conference on LISP and Functional Programming (LFP), New York. ACM (1990)

    Google Scholar 

  20. Winograd-Cort, D., Hudak, P.: Settable and non-interfering signal functions for FRP: how a first-order switch is more than enough. In: International Conference on Functional Programming (ICFP), pp. 213–225. ACM (2014)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to David Janin .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Janin, D. (2020). A Timed IO Monad. In: Komendantskaya, E., Liu, Y. (eds) Practical Aspects of Declarative Languages. PADL 2020. Lecture Notes in Computer Science(), vol 12007. Springer, Cham. https://doi.org/10.1007/978-3-030-39197-3_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-39197-3_9

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-39196-6

  • Online ISBN: 978-3-030-39197-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics