Copyright | (c) Eduard Sergeev 2011 |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | eduard.sergeev@gmail.com |
Stability | experimental |
Portability | non-portable (multi-param classes, flexible instances) |
Safe Haskell | None |
Language | Haskell2010 |
Defines MemoStateT - generalized (to any Data.MapLike content) memoization monad transformer
Synopsis
- type MemoStateT s k v = StateCache (Container s)
- runMemoStateT :: Monad m => MemoStateT s k v m a -> s -> m (a, s)
- evalMemoStateT :: Monad m => MemoStateT c k v m a -> c -> m a
- type MemoState c k v = MemoStateT c k v Identity
- runMemoState :: MemoState c k v a -> c -> (a, c)
- evalMemoState :: MemoState c k v a -> c -> a
- newtype Container s = Container {
- toState :: s
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
Instances
(Monad m, MapLike c k v) => MonadMemo k v (MemoStateT c k v m) Source # | |
Defined in Control.Monad.Trans.Memo.State 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 # | |
Defined in Control.Monad.Trans.Memo.State lookup :: k -> MemoStateT c k v m (Maybe v) Source # add :: k -> v -> MemoStateT c k v m () Source # |