A Timed IO Monad

  • David JaninEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 12007)


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.


  1. 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. 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. 3.
    Elliott, C., Hudak, P.: Functional reactive animation. In: International Conference on Functional Programming (ICFP). ACM (1997)Google Scholar
  4. 4.
    Elliott, C.M.: Push-pull functional reactive programming. In: Symposium on Haskell, pp. 25–36. ACM (2009)Google Scholar
  5. 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. 6.
    Halstead Jr., R.H.: Multilisp: a language for concurrent symbolic computation. ACM Trans. Program. Lang. Syst. 7(4), 501–538 (1985)CrossRefGoogle Scholar
  7. 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). Scholar
  8. 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. 9.
    Hudak, P., Quick, D.: The Haskell School of Music : From Signals to Symphonies. Cambridge University Press, Cambridge (2018)CrossRefGoogle Scholar
  10. 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). Scholar
  11. 11.
    Janin, D.: An equational modeling of asynchronous concurrent programming. Technical report, LaBRI, Université de Bordeaux (2019)Google Scholar
  12. 12.
    Janin, D.: Screaming in the IO monad. In: ACM Workshop on Functional Art, Music, Modeling and Design (FARM). ACM (2019)Google Scholar
  13. 13.
    Krishnaswami, N.R.: Higher-order functional reactive programming without spacetime leaks. In: International Conference on Functional Programming (ICFP) (2013)Google Scholar
  14. 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. 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). Scholar
  16. 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). Scholar
  17. 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. 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. 19.
    Wadler, P.: Comprehending monads. In: Conference on LISP and Functional Programming (LFP), New York. ACM (1990)Google Scholar
  20. 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

Copyright information

© Springer Nature Switzerland AG 2020

Authors and Affiliations

  1. 1.LaBRI, Bordeaux INP, University of BordeauxTalenceFrance

Personalised recommendations