Generic memo combinators