mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-24 07:52:14 +03:00
23 lines
856 B
Haskell
23 lines
856 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
|