Abstract
We begin with a functional reactive programming (FRP) model in which every program is viewed as a signal function that converts a stream of input values into a stream of output values. We observe that objects in the real world – such as a keyboard or sound card – can be thought of as signal functions as well. This leads us to a radically different approach to I/O: instead of treating real-world objects as being external to the program, we expand the sphere of influence of program execution to include them within. We call this virtualizing real-world objects. We explore how virtual objects (such as GUI widgets) and even non-local effects (such as debugging and random number generation) can be handled in the same way.
The key to our approach is the notion of a resource type that assures that a virtualized object cannot be duplicated, and is safe. Resource types also provide a deeper level of transparency: by inspecting the type, one can see exactly what resources are being used. We use arrows, type classes, and type families to implement our ideas in Haskell, and the result is a safe, effective, and transparent approach to stream-based I/O.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Courtney, A.: Modelling User Interfaces in a Functional Language. Ph.D. thesis, Department of Computer Science, Yale University (May 2004)
Courtney, A., Elliott, C.: Genuinely functional user interfaces. In: 2001 Haskell Workshop (September 2001)
Courtney, A., Nilsson, H., Peterson, J.: The Yampa arcade. In: Proceedings of the 2003 ACM SIGPLAN Haskell Workshop (Haskell 2003), pp. 7–18. ACM Press, Uppsala (2003)
Elliott, C.: Tangible functional programming. In: International Conference on Functional Programming (2007), http://conal.net/papers/Eros/
Elliott, C., Hudak, P.: Functional reactive animation. In: International Conference on Functional Programming, pp. 263–273 (June 1997)
Elliott, C., Schechter, G., Yeung, R., Abi-Ezzi, S.: Tbag: A high level framework for interactive, animated 3d graphics applications. In: Proceedings of SIGGRAPH 1994, pp. 421–434. ACM SIGGRAPH (July 1994)
Girard, J.Y.: Linear logic. Theoretical Computer Science 50, 1–102 (1987)
Hawblitzel, C.: Linear types for aliased resources (extended version). Tech. Rep. MSR-TR-2005-141, Microsoft Research, Redmond, WA (October 2005)
Hudak, P.: The Haskell School of Expression – Learning Functional Programming through Multimedia. Cambridge University Press, New York (2000)
Hudak, P.: Describing and interpreting music in Haskell. In: The Fun of Programming, ch. 4. Palgrave (2003)
Hudak, P.: The Haskell School of Music – from Signals to Symphonies (Version 2.0) (January 2011), http://haskell.cs.yale.edu/?post_type=publication&p=112
Hudak, P., Courtney, A., Nilsson, H., Peterson, J.: Arrows, Robots, and Functional Reactive Programming. In: Jeuring, J., Jones, S.L.P. (eds.) AFP 2002. LNCS, vol. 2638, pp. 159–187. Springer, Heidelberg (2003)
Hughes, J.: Generalising monads to arrows. Science of Computer Programming 37, 67–111 (2000)
Kiselyov, O., Lämmel, R., Schupke, K.: Strongly typed heterogeneous collections. In: Haskell 2004: Proceedings of the ACM SIGPLAN Workshop on Haskell, pp. 96–107. ACM Press (2004)
Nilsson, H., Courtney, A., Peterson, J.: Functional Reactive Programming, continued. In: ACM SIGPLAN 2002 Haskell Workshop (October 2002)
Norell, U.: Dependently Typed Programming in Agda. In: Koopman, P., Plasmeijer, R., Swierstra, D. (eds.) AFP 2008. LNCS, vol. 5832, pp. 230–266. Springer, Heidelberg (2009)
OHearn, P., Reynolds, J., Yang, H.: Local reasoning about programs that alter data structures. Computer Science Logic, p. 1
Paterson, R.: A new notation for arrows. In: ICFP 2001: International Conference on Functional Programming, Firenze, Italy, pp. 229–240 (2001)
Peyton Jones, S., Wadler, P.: Imperative functional programming. In: Proceedings 20th Symposium on Principles of Programming Languages, pp. 71–84. ACM (January 1993)
Peyton Jones, S., et al.: The Haskell 98 language and libraries: The revised report. Journal of Functional Programming 13(1), 0–255 (January 2003)
Plasmeijer, R., van Eekelen, M.: Clean – version 2.1 language report. Tech. rep., Department of Software Technology, University of Nijmegen (November 2002)
Reynolds, J.: Separation logic: A logic for shared mutable data structures. In: Proc. Logic in Computer Science (LICS 2002), pp. 55–74 (July 2002)
Voellmy, A., Hudak, P.: Nettle: Taking the Sting Out of Programming Network Routers. In: Rocha, R., Launchbury, J. (eds.) PADL 2011. LNCS, vol. 6539, pp. 235–249. Springer, Heidelberg (2011)
Wadler, P.: Is there a use for linear logic? In: Symposium on Partial Evaluation and Semantics Based Program Manipulation, pp. 255–273. ACM/IFIP (1991)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Winograd-Cort, D., Liu, H., Hudak, P. (2012). Virtualizing Real-World Objects in FRP. In: Russo, C., Zhou, NF. (eds) Practical Aspects of Declarative Languages. PADL 2012. Lecture Notes in Computer Science, vol 7149. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-27694-1_17
Download citation
DOI: https://doi.org/10.1007/978-3-642-27694-1_17
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-27693-4
Online ISBN: 978-3-642-27694-1
eBook Packages: Computer ScienceComputer Science (R0)