monad-memo-0.5.1: Memoization monad transformer

Copyright(c) Eduard Sergeev 2011
LicenseBSD-style (see the file LICENSE)
Maintainereduard.sergeev@gmail.com
Stabilityexperimental
Portabilitynon-portable (multi-param classes, flexible instances)
Safe HaskellNone
LanguageHaskell2010

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 a Source #

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 Identity Source #

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 -> a Source #

Returns the result of MonadMemo computation discarding the cache

Internal

newtype Container s Source #

Constructors

Container 

Fields

Instances
(Monad m, MapLike c k v) => MonadMemo k v (MemoStateT c k v m) Source # 
Instance details

Defined in Control.Monad.Trans.Memo.State

Methods

memo :: (k -> MemoStateT c k v m v) -> k -> MemoStateT c k v m v Source #

(Monad m, MapLike c k v) => MonadCache k v (MemoStateT c k v m) Source # 
Instance details

Defined in Control.Monad.Trans.Memo.State

Methods

lookup :: k -> MemoStateT c k v m (Maybe v) Source #

add :: k -> v -> MemoStateT c k v m () Source #