module Tendermint.SDK.BaseApp.Effects
  ( BaseAppEffs
  , defaultCompileToCore
  , defaultCompileToPureCore
  , module Tendermint.SDK.BaseApp.Effects.BaseEffs
  , module Tendermint.SDK.BaseApp.Effects.CoreEffs
  , module Tendermint.SDK.BaseApp.Effects.PureCoreEffs
  ) where

import           Polysemy                                    (Sem)
import           Tendermint.SDK.BaseApp.Effects.BaseEffs
import           Tendermint.SDK.BaseApp.Effects.CoreEffs
import           Tendermint.SDK.BaseApp.Effects.PureCoreEffs
import           Tendermint.SDK.BaseApp.Store                (StoreEffs)
import qualified Tendermint.SDK.BaseApp.Store.IAVLStore      as IAVL
import qualified Tendermint.SDK.BaseApp.Store.MemoryStore    as Memory
import           Tendermint.SDK.Types.Effects                ((:&))




type BaseAppEffs core = StoreEffs :& BaseEffs :& core

defaultCompileToCore
  :: forall a.
     Sem (BaseAppEffs CoreEffs) a
  -> Sem CoreEffs a
defaultCompileToCore :: Sem (BaseAppEffs CoreEffs) a -> Sem CoreEffs a
defaultCompileToCore = Sem (Metrics : Logger : Resource : Error AppError : CoreEffs) a
-> Sem CoreEffs a
forall (core :: [(* -> *) -> * -> *]) a.
Members
  '[Embed IO, Reader LogConfig, Reader (Maybe PrometheusEnv)] core =>
Sem (BaseEffs :& core) a -> Sem core a
evalBaseEffs (Sem (Metrics : Logger : Resource : Error AppError : CoreEffs) a
 -> Sem CoreEffs a)
-> (Sem
      (Tagged 'Consensus ReadStore
         : Tagged 'QueryAndMempool ReadStore : Tagged 'Consensus WriteStore
         : Transaction : CommitBlock : Metrics : Logger : Resource
         : Error AppError : CoreEffs)
      a
    -> Sem (Metrics : Logger : Resource : Error AppError : CoreEffs) a)
-> Sem
     (Tagged 'Consensus ReadStore
        : Tagged 'QueryAndMempool ReadStore : Tagged 'Consensus WriteStore
        : Transaction : CommitBlock : Metrics : Logger : Resource
        : Error AppError : CoreEffs)
     a
-> Sem CoreEffs a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sem
  (Tagged 'Consensus ReadStore
     : Tagged 'QueryAndMempool ReadStore : Tagged 'Consensus WriteStore
     : Transaction : CommitBlock : Metrics : Logger : Resource
     : Error AppError : CoreEffs)
  a
-> Sem (Metrics : Logger : Resource : Error AppError : CoreEffs) a
forall (r :: [(* -> *) -> * -> *]) a.
Members
  '[Embed IO, Reader IAVLVersions, Error AppError, Reader GrpcClient]
  r =>
Sem (StoreEffs :& r) a -> Sem r a
IAVL.evalStoreEffs

defaultCompileToPureCore
  :: forall a.
     Sem (BaseAppEffs PureCoreEffs) a
  -> Sem PureCoreEffs a
defaultCompileToPureCore :: Sem (BaseAppEffs PureCoreEffs) a -> Sem PureCoreEffs a
defaultCompileToPureCore = Sem (Metrics : Logger : Resource : Error AppError : PureCoreEffs) a
-> Sem PureCoreEffs a
forall (core :: [(* -> *) -> * -> *]) a.
Members '[Embed IO, Reader LogConfig] core =>
Sem (BaseEffs :& core) a -> Sem core a
evalBaseEffsPure (Sem
   (Metrics : Logger : Resource : Error AppError : PureCoreEffs) a
 -> Sem PureCoreEffs a)
-> (Sem
      (Tagged 'Consensus ReadStore
         : Tagged 'QueryAndMempool ReadStore : Tagged 'Consensus WriteStore
         : Transaction : CommitBlock : Metrics : Logger : Resource
         : Error AppError : PureCoreEffs)
      a
    -> Sem
         (Metrics : Logger : Resource : Error AppError : PureCoreEffs) a)
-> Sem
     (Tagged 'Consensus ReadStore
        : Tagged 'QueryAndMempool ReadStore : Tagged 'Consensus WriteStore
        : Transaction : CommitBlock : Metrics : Logger : Resource
        : Error AppError : PureCoreEffs)
     a
-> Sem PureCoreEffs a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sem
  (Tagged 'Consensus ReadStore
     : Tagged 'QueryAndMempool ReadStore : Tagged 'Consensus WriteStore
     : Transaction : CommitBlock : Metrics : Logger : Resource
     : Error AppError : PureCoreEffs)
  a
-> Sem
     (Metrics : Logger : Resource : Error AppError : PureCoreEffs) a
forall (r :: [(* -> *) -> * -> *]) a.
Members '[Embed IO, Reader DBVersions, Reader DB] r =>
Sem (StoreEffs :& r) a -> Sem r a
Memory.evalStoreEffs