TY - GEN
T1 - Extensible effects
T2 - 2013 ACM SIGPLAN Haskell Symposium, Haskell 2013 - Co-located with the 18th ACM SIGPLAN International Conference on Functional Programming, ICFP 2013
AU - Kiselyov, Oleg
AU - Sabry, Amr
AU - Swords, Cameron
PY - 2013
Y1 - 2013
N2 - We design and implement a library that solves the long-standing problem of combining effects without imposing restrictions on their interactions (such as static ordering). Effects arise from interactions between a client and an effect handler (interpreter); interactions may vary throughout the program and dynamically adapt to execution conditions. Existing code that relies on monad transformers may be used with our library with minor changes, gaining efficiency over long monad stacks. In addition, our library has greater expressiveness, allowing for practical idioms that are inefficient, cumbersome, or outright impossible with monad transformers. Our alternative to a monad transformer stack is a single monad, for the coroutine-like communication of a client with its handler. Its type reflects possible requests, i.e., possible effects of a computation. To support arbitrary effects and their combinations, requests are values of an extensible union type, which allows adding and, notably, subtracting summands. Extending and, upon handling, shrinking of the union of possible requests is reflected in its type, yielding a type-and-effect system for Haskell. The library is lightweight, generalizing the extensible exception handling to other effects and accurately tracking them in types.
AB - We design and implement a library that solves the long-standing problem of combining effects without imposing restrictions on their interactions (such as static ordering). Effects arise from interactions between a client and an effect handler (interpreter); interactions may vary throughout the program and dynamically adapt to execution conditions. Existing code that relies on monad transformers may be used with our library with minor changes, gaining efficiency over long monad stacks. In addition, our library has greater expressiveness, allowing for practical idioms that are inefficient, cumbersome, or outright impossible with monad transformers. Our alternative to a monad transformer stack is a single monad, for the coroutine-like communication of a client with its handler. Its type reflects possible requests, i.e., possible effects of a computation. To support arbitrary effects and their combinations, requests are values of an extensible union type, which allows adding and, notably, subtracting summands. Extending and, upon handling, shrinking of the union of possible requests is reflected in its type, yielding a type-and-effect system for Haskell. The library is lightweight, generalizing the extensible exception handling to other effects and accurately tracking them in types.
KW - Coroutine
KW - Effect handler
KW - Effect interaction
KW - Monad
KW - Monad transformer
KW - Open union
KW - Type and effect system
UR - http://www.scopus.com/inward/record.url?scp=84885669799&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=84885669799&partnerID=8YFLogxK
U2 - 10.1145/2503778.2503791
DO - 10.1145/2503778.2503791
M3 - Conference contribution
AN - SCOPUS:84885669799
SN - 9781450323833
T3 - Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP
SP - 59
EP - 70
BT - Haskell 2013 - Proceedings of the 2013 ACM SIGPLAN Haskell Symposium, Co-located with ICFP 2013
Y2 - 23 September 2013 through 24 September 2013
ER -