Handlers for Non-Monadic Computations

Algebraic effects and handlers are a convenient method for structuring monadic effects with primitive effectful operations and separating the syntax from the interpretation of these operations. However, the scope of conventional handlers are somewhat limited as not all side effects are monadic in nature. This paper generalizes the notion of algebraic effects and handlers from monads to generalized monoids, which notably covers applicative functors and arrows. For this purpose we switch the category theoretical basis from free algebras to free monoids. In addition, we show how lax monoidal functors enable the reuse of handlers and programs across different computation classes, for example handling applicative computations with monadic handlers.

[1]  Edwin Brady,et al.  Programming and reasoning with algebraic effects and dependent types , 2013, ICFP.

[2]  Conor McBride,et al.  Do be do be do , 2017, POPL.

[3]  Gordon D. Plotkin,et al.  Handlers of Algebraic Effects , 2009, ESOP.

[4]  Philip Wadler,et al.  Idioms are Oblivious, Arrows are Meticulous, Monads are Promiscuous , 2011, Electron. Notes Theor. Comput. Sci..

[5]  Oleg Kiselyov,et al.  Freer monads, more extensible effects , 2015, Haskell.

[6]  Nils Anders Danielsson,et al.  Fast and loose reasoning is morally correct , 2006, POPL '06.

[7]  John Hughes,et al.  Generalising monads to arrows , 2000, Sci. Comput. Program..

[8]  Tom Schrijvers,et al.  From monoids to near-semirings: the essence of MonadPlus and alternative , 2015, PPDP.

[9]  Sam Lindley Algebraic effects and effect handlers for idioms and arrows , 2014, WGP '14.

[10]  Philip Wadler,et al.  Comprehending monads , 1990, Mathematical Structures in Computer Science.

[11]  Daan Leijen Algebraic Effects for Functional Programming , 2016 .

[12]  S. Lane Categories for the Working Mathematician , 1971 .

[13]  Andrej Bauer,et al.  Programming with algebraic effects and handlers , 2012, J. Log. Algebraic Methods Program..

[14]  Conor McBride,et al.  Applicative programming with effects , 2008, J. Funct. Program..

[15]  Exequiel Rivas,et al.  Notions of computation as monoids* , 2014, Journal of Functional Programming.