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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 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
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)
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)
Elliott, C., Hudak, P.: Functional reactive animation. In: International Conference on Functional Programming (ICFP). ACM (1997)
Elliott, C.M.: Push-pull functional reactive programming. In: Symposium on Haskell, pp. 25–36. ACM (2009)
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)
Halstead Jr., R.H.: Multilisp: a language for concurrent symbolic computation. ACM Trans. Program. Lang. Syst. 7(4), 501–538 (1985)
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
Hudak, P., Janin, D.: From out-of-time design to in-time production of temporal media. Research report, LaBRI, Université de Bordeaux (2015)
Hudak, P., Quick, D.: The Haskell School of Music : From Signals to Symphonies. Cambridge University Press, Cambridge (2018)
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
Janin, D.: An equational modeling of asynchronous concurrent programming. Technical report, LaBRI, Université de Bordeaux (2019)
Janin, D.: Screaming in the IO monad. In: ACM Workshop on Functional Art, Music, Modeling and Design (FARM). ACM (2019)
Krishnaswami, N.R.: Higher-order functional reactive programming without spacetime leaks. In: International Conference on Functional Programming (ICFP) (2013)
Mandel, L., Pouzet, M.: ReactiveML, a reactive extension to ML. In: International Symposium on Principles and Practice of Declarative Programming (PPDP). ACM (2005)
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
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
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)
de Simone, R., Talpin, J.-P., Potop-Butucaru, D.: The synchronous hypothesis and synchronous languages. In: Embedded Systems Handbook. CRC Press (2005)
Wadler, P.: Comprehending monads. In: Conference on LISP and Functional Programming (LFP), New York. ACM (1990)
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)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2020 Springer Nature Switzerland AG
About this paper
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)