Memoization is a technique for storing values of a function instead of recomputing them each time the function is called. Memoization without recursion You can just write a memoization function using a data structure that is suitable for your application. We don't go into the details of this case. If you want a general solution for several types, you need a type class, say Memoizable.