Functional Pearl: Control to Correct A recipe for robustness

Olin Shivers, Aaron Joseph Turon · 2011

Making a program robust is often a recipe for making it ugly: the core logic becomes hopelessly entwined with error handling, and quickly dwarfed by it. The concerns are hard to separate, since error checking may depend on earlier bits of core logic, and the core logic may assume error-free input. In this pearl we show, through two distinct but related examples, how to wield first-class control to interleave error checking and correction functionality without interleaving its code. Prologue We all make mistakes. What counts is how we handle them. There’s little less pleasant in programming than watching beautiful code turn ugly. And nothing causes more contortion than catching and correcting input errors. The problem is that error handling is not naturally modular:

Read the paper · More papers on PaperTik