graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Memoize

Synopsis

Documentation

class Monad m => MonadMemoize m where Source #

Methods

memoizeOn Source #

Arguments

:: 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 Name as a convenient source for a static, unique identifier.

-> 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

Instances details
MonadIO m => MonadMemoize (MemoizeT m) Source #

see Note [MemoizeT requires MonadIO]

Instance details

Defined in Control.Monad.Memoize

Methods

memoizeOn :: (Ord a, Typeable a, Typeable p) => Name -> a -> MemoizeT m p -> MemoizeT m p Source #

MonadMemoize m => MonadMemoize (SchemaT r m) Source # 
Instance details

Defined in Hasura.GraphQL.Schema.Common

Methods

memoizeOn :: (Ord a, Typeable a, Typeable p) => Name -> a -> SchemaT r m p -> SchemaT r m p Source #

MonadMemoize m => MonadMemoize (ReaderT a m) Source # 
Instance details

Defined in Control.Monad.Memoize

Methods

memoizeOn :: (Ord a0, Typeable a0, Typeable p) => Name -> a0 -> ReaderT a m p -> ReaderT a m p 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.

data MemoizeT m a Source #

Instances

Instances details
MonadTrans MemoizeT Source # 
Instance details

Defined in Control.Monad.Memoize

Methods

lift :: Monad m => m a -> MemoizeT m a #

MonadError e m => MonadError e (MemoizeT m) Source # 
Instance details

Defined in Control.Monad.Memoize

Methods

throwError :: e -> MemoizeT m a #

catchError :: MemoizeT m a -> (e -> MemoizeT m a) -> MemoizeT m a #

MonadReader r m => MonadReader r (MemoizeT m) Source # 
Instance details

Defined in Control.Monad.Memoize

Methods

ask :: MemoizeT m r #

local :: (r -> r) -> MemoizeT m a -> MemoizeT m a #

reader :: (r -> a) -> MemoizeT m a #

MonadState s m => MonadState s (MemoizeT m) Source #

Allow code in MemoizeT to have access to any underlying state capabilities, hiding the fact that MemoizeT itself is a state monad.

Instance details

Defined in Control.Monad.Memoize

Methods

get :: MemoizeT m s #

put :: s -> MemoizeT m () #

state :: (s -> (a, s)) -> MemoizeT m a #

Monad m => Applicative (MemoizeT m) Source # 
Instance details

Defined in Control.Monad.Memoize

Methods

pure :: a -> MemoizeT m a #

(<*>) :: MemoizeT m (a -> b) -> MemoizeT m a -> MemoizeT m b #

liftA2 :: (a -> b -> c) -> MemoizeT m a -> MemoizeT m b -> MemoizeT m c #

(*>) :: MemoizeT m a -> MemoizeT m b -> MemoizeT m b #

(<*) :: MemoizeT m a -> MemoizeT m b -> MemoizeT m a #

Functor m => Functor (MemoizeT m) Source # 
Instance details

Defined in Control.Monad.Memoize

Methods

fmap :: (a -> b) -> MemoizeT m a -> MemoizeT m b #

(<$) :: a -> MemoizeT m b -> MemoizeT m a #

Monad m => Monad (MemoizeT m) Source # 
Instance details

Defined in Control.Monad.Memoize

Methods

(>>=) :: MemoizeT m a -> (a -> MemoizeT m b) -> MemoizeT m b #

(>>) :: MemoizeT m a -> MemoizeT m b -> MemoizeT m b #

return :: a -> MemoizeT m a #

MonadIO m => MonadMemoize (MemoizeT m) Source #

see Note [MemoizeT requires MonadIO]

Instance details

Defined in Control.Monad.Memoize

Methods

memoizeOn :: (Ord a, Typeable a, Typeable p) => Name -> a -> MemoizeT m p -> MemoizeT m p Source #

runMemoizeT :: forall m a. Monad m => MemoizeT m a -> m a Source #