This is part of a presentation I gave on using State monad for memoization