Evaluation strategies for monadic computations
Tomas Petricek (University of Cambridge)

TL;DR
This paper introduces a unified translation method for monadic computations in functional programming, allowing flexible evaluation strategies like call-by-value and call-by-name through a new operation called malias, based on categorical principles.
Contribution
It proposes a novel translation framework using malias to abstract evaluation strategies, and extends monads to support call-by-need semantics, addressing an open research question.
Findings
Malias operation enables switching evaluation strategies without changing code structure.
Implementations of malias for call-by-value and call-by-name are provided.
Extended monads can support call-by-need semantics for certain monads.
Abstract
Monads have become a powerful tool for structuring effectful computations in functional programming, because they make the order of effects explicit. When translating pure code to a monadic version, we need to specify evaluation order explicitly. Two standard translations give call-by-value and call-by-name semantics. The resulting programs have different structure and types, which makes revisiting the choice difficult. In this paper, we translate pure code to monadic using an additional operation malias that abstracts out the evaluation strategy. The malias operation is based on computational comonads; we use a categorical framework to specify the laws that are required to hold about the operation. For any monad, we show implementations of malias that give call-by-value and call-by-name semantics. Although we do not give call-by-need semantics for all monads, we show how to turn…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
