monad-memo-0.4.0: Memoization monad transformer

Portabilitynon-portable (multi-param classes, flexible instances)
Stabilityexperimental
Maintainereduard.sergeev@gmail.com
Safe HaskellSafe-Inferred

Control.Monad.Trans.Memo.State

Contents

Description

Defines MemoStateT - generalized (to any Data.MapLike content) memoization monad transformer

Synopsis

MemoStateT monad transformer

type MemoStateT s k v = StateCache (Container s)Source

Memoization monad transformer based on StateCache to be used with pure cache containers which support MapLike interface

runMemoStateT :: Monad m => MemoStateT s k v m a -> s -> m (a, s)Source

Returns the pair of the result of MonadMemo computation along with the final state of the internal pure container wrapped in monad

evalMemoStateT :: Monad m => MemoStateT c k v m a -> c -> m aSource

Returns the result of MonadMemo computation wrapped in monad. This function discards the cache

MemoState monad

type MemoState c k v = MemoStateT c k v IdentitySource

Memoization monad based on StateCache to be used with pure cache containers which support MapLike interface

runMemoState :: MemoState c k v a -> c -> (a, c)Source

Returns the pair of the result of MonadMemo computation along with the final state of the internal pure container

evalMemoState :: MemoState c k v a -> c -> aSource

Returns the result of MonadMemo computation discarding the cache

Internal

newtype Container s Source

Constructors

Container 

Fields

toState :: s
 

Instances

(Monad m, MapLike c k v) => MonadMemo k v (MemoStateT c k v m) 
(Monad m, MapLike c k v) => MonadCache k v (MemoStateT c k v m)