The author continues their multi-part series on dynamic programming in Haskell and explores the idea of a magic memoization function that can automatically generate a memo table for any given recursive function, making it faster. While it seems impossible, the author breaks down the concept and provides a solution that sticks the call to memo directly into the definition of the recursive function, producing a much nicer and more compact solution that doesn’t require separate definitions for a function and memo table. The final solution for the sample problem is shown to be just five lines of code.
https://byorgey.wordpress.com/2023/06/06/dynamic-programming-in-haskell-automatic-memoization/