Skip to main content

Tracing monadic computations and representing effects

Maciej Pirog and Jeremy Gibbons

Abstract

In functional programming, monads are supposed to encapsulate computations, effectfully producing the final result, but keeping the means of acquiring it to themselves. For various reasons, we sometimes want to reveal the internals of a computation. To make that possible, in this paper we introduce monad transformers that add the ability to automatically accumulate observations about the course of execution as an effect. We discover that if we treat the resulting trace as the actual result of the computation, we can find new functionality in existing monads, notably when working with non-terminating computations.

Book Title
Proceedings Fourth Workshop on Mathematically Structured Functional Programming‚ Tallinn‚ Estonia‚ 25 March 2012
Editor
Chapman‚ James and Levy‚ Paul Blain
Pages
90−111
Publisher
Open Publishing Association
Series
Electronic Proceedings in Theoretical Computer Science
Volume
76
Year
2012