Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Documentation
class Monad m => MonadMemoize m where Source #
:: forall a p. (Ord a, Typeable a, Typeable p) | |
=> Name | A unique name used to identify the function being memoized. There isn’t
really any metaprogramming going on here, we just use a Template Haskell
|
-> a | The value to use as the memoization key. It’s the caller’s responsibility to ensure multiple calls to the same function don’t use the same key. |
-> m p | |
-> m p |
Memoizes a parser constructor function for the extent of a single schema construction process. This is mostly useful for recursive parsers; see Note [Tying the knot] for more details.
The generality of the type here allows us to use this with multiple concrete parser types:
memoizeOn
:: (MonadMemoize
m, MonadParse n) =>Name
-> a -> m (Parser n b) -> m (Parser n b)memoizeOn
:: (MonadMemoize
m, MonadParse n) =>Name
-> a -> m (FieldParser n b) -> m (FieldParser n b)
Instances
MonadIO m => MonadMemoize (MemoizeT m) Source # | see Note [MemoizeT requires MonadIO] |
MonadMemoize m => MonadMemoize (SchemaT r m) Source # | |
MonadMemoize m => MonadMemoize (ReaderT a m) Source # | |
memoize :: (MonadMemoize m, Ord a, Typeable a, Typeable p) => Name -> (a -> m p) -> a -> m p Source #
A wrapper around memoizeOn
that memoizes a function by using its argument
as the key.
Instances
MonadTrans MemoizeT Source # | |
Defined in Control.Monad.Memoize | |
MonadError e m => MonadError e (MemoizeT m) Source # | |
Defined in Control.Monad.Memoize throwError :: e -> MemoizeT m a # catchError :: MemoizeT m a -> (e -> MemoizeT m a) -> MemoizeT m a # | |
MonadReader r m => MonadReader r (MemoizeT m) Source # | |
MonadState s m => MonadState s (MemoizeT m) Source # | Allow code in |
Monad m => Applicative (MemoizeT m) Source # | |
Defined in Control.Monad.Memoize | |
Functor m => Functor (MemoizeT m) Source # | |
Monad m => Monad (MemoizeT m) Source # | |
MonadIO m => MonadMemoize (MemoizeT m) Source # | see Note [MemoizeT requires MonadIO] |
runMemoizeT :: forall m a. Monad m => MemoizeT m a -> m a Source #