[TYPES] effect vs. coeffect expressiveness
Jonathan Aldrich
jonathan.aldrich at cs.cmu.edu
Wed Apr 29 19:48:29 EDT 2020
Dear Types,
I am curious about the relative expressiveness of effects and
coeffects. Has this been studied?
The cleanest distinction I've seen is that effects capture the impact
a program has on its environment, i.e. what it produces. Coeffects
capture the requirements that a program puts on its environment: what
it consumes. This is discussed, for example, in Gaboardi et al's ICFP
2016 paper, "Combining Effects and Coeffects via Grading" (and
elsewhere).
There is some useful intuition in this distinction, and it describes
the different structure of checking rules in effect and coeffect
systems. However, I don't find this distinction very helpful in
thinking about expressiveness. It seems like many examples can be
expressed in either an effect or a coeffect system. For example, an
exception is a classic example of an effect (e.g. in the paper
mentioned above, and many others). However, it seems to me that
exceptions can also be modeled as coeffects: code that might throw an
exception requires the caller to pass a handler for that exception to
it--or perhaps an abstract "permission" to throw that exception. So
in what sense are exceptions an effect, rather than a coeffect?
Is this true of all the kinds of things that are typically expressed
with effects and coeffects--that they could just as easily be
expressed in the other style? If so, what are the benefits of one
style vs. the other? Or are there examples that can only be expressed
in one style--or for which expression in the other style is much more
awkward?
Perhaps these questions have been written about, but I haven't been
able to find it. I would love to get some pointers. I am
particularly interested in a practical explanation of the differences
in expressiveness, or theoretical results that have a direct and
explicit relationship to practice--with practical examples in either
case. (co-)Monads and/or anything categorical are not a very helpful
starting point for me, but effect systems and/or linear types are
(I've done research on both). I am also more interested in the
descriptive view of effects/coeffects (in the sense of Filinski,
ICFP'11) than the prescriptive view.
Thanks,
Jonathan
More information about the Types-list
mailing list