@hackage monad-memo0.5.1

Memoization monad transformer

Memoization monad transformer supporting most of the standard monad transformers and a range of memoization cache types: from default pure maps to extremely fast mutable vectors

To add memoization behaviour to a monadic function:

1) Add Control.Monad.Memo.memo combinator at the point when memoization is required (i.e. recursive call)

import Control.Monad.Memo

fibm 0 = return 0
fibm 1 = return 1
fibm n = do
  n1 <- memo fibm (n-1)
  n2 <- memo fibm (n-2)
  return (n1+n2)

2) Use approprite *eval* or *run* function to evaluate resulting MonadMemo monad:

startEvalMemo (fibm 100)

See detailed description and examples: Control.Monad.Memo