mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-20 14:01:39 +03:00
e0c0043e76
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9284 GitOrigin-RevId: 2f2cf2ad01900a54e4bdb970205ac0ef313c7e00
23 lines
858 B
Haskell
23 lines
858 B
Haskell
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
module Control.Monad.MemoizeSpec (spec) where
|
|
|
|
import Control.Monad.MemoizationSpecDefinition
|
|
import Control.Monad.Memoize
|
|
import Hasura.Prelude
|
|
import Test.Hspec
|
|
|
|
-- We need to add a couple of extra parameters, 'k' and 'v', to align with the
|
|
-- shape of a memoizer as understood by 'Memoizer'.
|
|
newtype MemoizeWithExtraParamsT k v m a = MemoizeWithExtraParamsT {unMemoizeWithExtraParamsT :: MemoizeT m a}
|
|
deriving newtype (Functor, Applicative, Monad, MonadTrans)
|
|
|
|
instance Memoizer MemoizeWithExtraParamsT where
|
|
runMemoizer = runMemoizeT . unMemoizeWithExtraParamsT
|
|
memoize name key = MemoizeWithExtraParamsT . memoizeOn name key . unMemoizeWithExtraParamsT
|
|
|
|
deriving newtype instance (MonadState s m) => MonadState s (MemoizeWithExtraParamsT k v m)
|
|
|
|
spec :: Spec
|
|
spec = memoizationSpec @MemoizeWithExtraParamsT
|