Abstract
The combination of monads and effects leads to a clean and easy to reason about programming paradigm. Monadic programming is easy to reason about, but can be cumbersome, as it requires explicit lifting and binding. In this paper, we combine monads and effects within a single programming paradigm: we use monads to define the semantics of effect types, and then, use the effects to program with those monads. We implemented an extension to the effect type system of Koka [15] with user defined effects. We use a type-directed translation to automatically lift effectful into monadic programs, by inserting bind - and unit operations.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsReferences
Bauer, A., Pretnar, M.: An effect system for algebraic effects and handlers. Logical Methods Comput. Sci. 10(4), 1–29 (2014)
Bauer, A., Pretnar, M.: Programming with algebraic effects and handlers. J. Log. Algebr. Methods Program. 84(1), 108–123 (2015). doi:10.1016/j.jlamp.2014.02.001
Benton, N., Buchlovsky, P.: Semantics of an effect analysis for exceptions. In: TLDI (2007). doi:10.1145/1190315.1190320
Benton, N., Kennedy, A., Beringer, L., Hofmann, M.: Relational semantics for effect-based program transformations with dynamic allocation. In: PPDP (2007). doi:10.1145/1273920.1273932
Elliott, C., Hudak, P.: Functional reactive animation. In: ICFP (1997)
Filinski, A.: Representing monads. In: POPL (1994)
Filinski, A.: Controlling effects. Technical report (1996)
Filinski, A.: Monads in action. ACM Sigplan Not. 45, 483–494 (2010)
Gifford, D.K., Lucassen, J.M.: Integrating functional and imperative programming. In: LFP (1986). doi:10.1145/319838.319848
Girard, J.-Y.: The system F of variable types, fifteen years later. TCS 45, 159–192 (1986)
Gosling, J., Joy, B., Steele, G.: The java language specification (1996)
Hicks, M., Bierman, G., Guts, N., Leijen, D., Swamy, N.: Polymonadic programming. In: MSFP (2014)
Kiselyov, O., Shan, C.: Embedded probabilistic programming. In: Taha, W.M. (ed.) DSL 2009. LNCS, vol. 5658, pp. 360–384. Springer, Heidelberg (2009). doi:10.1007/978-3-642-03034-5_17
Leijen, D.: Koka: programming with row-polymorphic effect types. Technical report MSR-TR-2013-79, Microsoft Research (2013)
Leijen, D.: Koka: programming with row polymorphic effect types. In: MSFP (2014). doi:10.4204/EPTCS.153.8
Lucassen, J.M., Gifford, D.K.: Polymorphic effect systems. In: POPL (1988)
Moggi, E.: Notions of computation and monads. Inf. Comput. 93, 55–92 (1991)
Nielson, H.R., Nielson, F., Amtoft, T.: Polymorphic subtyping for effect analysis, the static semantics. In: LOMAPS (1997)
Pessaux, F., Leroy, X.: Type-based analysis of uncaught exceptions. In POPL (1999). doi:10.1145/292540.292565
Plotkin, G.D., Matija, P., Handling algebraic effects. 9 (2013). doi:10.2168/LMCS-9(4:23)2013
Pretnar, M.: Inferring algebraic effects. Logical Methods Comput. Sci. 10(3) (2014). doi: 10.2168/LMCS-10(3:21)2014
Reynolds, J.C.: Towards a theory of type structure. In: Programming Symposium (1974)
Rompf, T., Maier, I., Odersky, M.: Implementing first-class polymorphic delimited continuations by a type-directed selective cps-transform. In: ICFP (2009)
Rytz, L., Odersky, M., Haller, P.: Lightweight polymorphic effects. In: Noble, J. (ed.) ECOOP 2012. LNCS, vol. 7313, pp. 258–282. Springer, Heidelberg (2012). doi:10.1007/978-3-642-31057-7_13
Swamy, N., Guts, N., Leijen, D., Hicks, M.: Lightweight monadic programming in ML. In: ICFP (2011). doi:10.1145/2034773.2034778
Talpin, J.-P., Jouvelot, P.: The type and effect discipline. Inf. Comput. (1994). doi: 10.1006/inco.1994.1046
Talpin, J.P.: Theoretical and practical aspects of type and effect inference. Ph.D. thesis, Ecole des Mines de Paris and University Paris VI, Paris, France (1993)
Vazou, N., Leijen, D.: From monads to effects and back - technical report. Technical report, July 2015. http://goto.ucsd.edu/~nvazou/padl16/techrep.pdf
Wadler, P.: The essence of functional programming. In: POPL (1992)
Wadler, P., Thiemann, P.: The marriage of effects and monads. In: TOLC (2003). doi: 10.1145/601775.601776
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2016 Springer International Publishing Switzerland
About this paper
Cite this paper
Vazou, N., Leijen, D. (2016). From Monads to Effects and Back. In: Gavanelli, M., Reppy, J. (eds) Practical Aspects of Declarative Languages. PADL 2016. Lecture Notes in Computer Science(), vol 9585. Springer, Cham. https://doi.org/10.1007/978-3-319-28228-2_11
Download citation
DOI: https://doi.org/10.1007/978-3-319-28228-2_11
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-28227-5
Online ISBN: 978-3-319-28228-2
eBook Packages: Computer ScienceComputer Science (R0)