Maximum Segment Sum, Monadically (distilled tutorial, with solutions)
Jeremy Gibbons (University of Oxford)

TL;DR
This paper explores the maximum segment sum problem using monadic functional programming, presenting a tutorial with solutions that highlight algebraic and datatype-generic approaches for efficient computation.
Contribution
It introduces a monadic, datatype-generic perspective on the maximum segment sum problem, contrasting traditional relational methods with a more elegant, linear-time solution.
Findings
Linear-time solution for maximum segment sum problem
Demonstrates monadic and datatype-generic programming techniques
Provides tutorial exercises for understanding the concepts
Abstract
The maximum segment sum problem is to compute, given a list of integers, the largest of the sums of the contiguous segments of that list. This problem specification maps directly onto a cubic-time algorithm; however, there is a very elegant linear-time solution too. The problem is a classic exercise in the mathematics of program construction, illustrating important principles such as calculational development, pointfree reasoning, algebraic structure, and datatype-genericity. Here, we take a sideways look at the datatype-generic version of the problem in terms of monadic functional programming, instead of the traditional relational approach; the presentation is tutorial in style, and leavened with exercises for the reader.
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.
