graphql-engine/server/src-test/Control/Monad/MemoizeSpec.hs
Tom Harding e0c0043e76 Upgrade Ormolu to 0.7.0.0
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9284
GitOrigin-RevId: 2f2cf2ad01900a54e4bdb970205ac0ef313c7e00
2023-05-24 13:53:53 +00:00

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