monad-memo-0.5.4: Memoization monad transformer

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, functional dependencies)
Safe Haskell | None
Language | Haskell2010

Control.Monad.Trans.Memo.Map

Contents

- MemoT monad transformer
- Memo monad

Description

Specialization of `MemoStateT` with `Map` as a container

Synopsis

- type MemoT k v = MemoStateT (Map k v) k v
- runMemoT :: Monad m => MemoT k v m a -> Map k v -> m (a, Map k v)
- evalMemoT :: Monad m => MemoT k v m a -> Map k v -> m a
- startRunMemoT :: Monad m => MemoT k v m a -> m (a, Map k v)
- startEvalMemoT :: Monad m => MemoT k v m a -> m a
- type Memo k v = MemoT k v Identity
- runMemo :: Memo k v a -> Map k v -> (a, Map k v)
- evalMemo :: Memo k v a -> Map k v -> a
- startRunMemo :: Memo k v a -> (a, Map k v)
- startEvalMemo :: Memo k v a -> a

# MemoT monad transformer

type MemoT k v = MemoStateT (Map k v) k v Source #

Memoization monad transformer which uses `Map` as a cache container

runMemoT :: Monad m => MemoT k v m a -> Map k v -> m (a, Map k v) Source #

Given an initial cache, compute the result of a memoized computation along with the final state of the cache

evalMemoT :: Monad m => MemoT k v m a -> Map k v -> m a Source #

Given an initial state, compute the result of a memoized computation discarding the final state of the cache

startRunMemoT :: Monad m => MemoT k v m a -> m (a, Map k v) Source #

Compute the result of memoized computation along with the final state of the cache. This function uses empty `Map` as an initial state

startEvalMemoT :: Monad m => MemoT k v m a -> m a Source #

Compute the result of a memoized computation discarding the final state of the cache. This function uses empty `Map` as an initial state

# Memo monad

type Memo k v = MemoT k v Identity Source #

Memoization monad which uses `Map` as a cache container

runMemo :: Memo k v a -> Map k v -> (a, Map k v) Source #

Given an initial cache, compute the result of a memoized computation along with the final state of the cache

evalMemo :: Memo k v a -> Map k v -> a Source #

Given an initial state, compute the result of a memoized computation discarding the final state of the cache

startRunMemo :: Memo k v a -> (a, Map k v) Source #

Compute the result of memoized computation along with the final state of the cache. This function uses empty `Map` as an initial state

startEvalMemo :: Memo k v a -> a Source #

Compute the result of a memoized computation discarding the final state of the cache. This function uses empty `Map` as an initial state