Skip to main content

Just do it: Simple monadic equational reasoning

Jeremy Gibbons and Ralf Hinze

Abstract

One of the appeals of pure functional programming is that it is so amenable to equational reasoning. One of the problems of pure functional programming is that it rules out computational effects. Moggi and Wadler showed how to get round this problem by using monads to encapsulate the effects, leading in essence to a phase distinction–a pure functional evaluation yielding an impure imperative computation. Still, it has not been clear how to reconcile that phase distinction with the continuing appeal of functional programming; does the impure imperative part become inaccessible to equational reasoning? We think not; and to back that up, we present a simple axiomatic approach to reasoning about programs with computational effects.

Errata

  • At the end of S6, we can't assume a run function for arbitrary MonadState instance m. But we could specialize to the particular instance State.
  • At the end of S7, the argument crs should be deleted in the definition of safe3 (or it should be added on the right-hand side).

Book Title
ICFP
Month
September
Year
2011