Skip to content

Commit

Permalink
Reinterpret the injecting handler
Browse files Browse the repository at this point in the history
  • Loading branch information
raduom committed Feb 25, 2021
1 parent c0a61ae commit aeca113
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions plutus-pab/src/Plutus/PAB/MockApp.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
Expand Down Expand Up @@ -36,7 +37,7 @@ module Plutus.PAB.MockApp
import qualified Cardano.Node.Types as NodeServer
import Control.Lens hiding (use)
import Control.Monad (void)
import Control.Monad.Freer (Eff, Member, interpret, runM, type (~>))
import Control.Monad.Freer (Eff, Member, interpret, reinterpret, runM, type (~>))
import Control.Monad.Freer.Error (Error, handleError, runError, throwError)
import Control.Monad.Freer.Extras.Log (LogMessage, LogMsg, handleLogWriter)
import Control.Monad.Freer.Extras.State (use)
Expand Down Expand Up @@ -210,11 +211,10 @@ notifyChainIndex ::
( Member ChainEffect effs
, Member MultiAgentPABEffect effs
)
=> ( ChainControlEffect ~> Eff effs )
-> ChainControlEffect ~> Eff effs
notifyChainIndex handler = \case
=> ChainControlEffect ~> Eff (ChainControlEffect ': effs)
notifyChainIndex = \case
ProcessBlock -> do
block <- handler ProcessBlock
block <- processBlock
slot <- Wallet.Emulator.Chain.getCurrentSlot
traverse_ (notifyWallet block slot) (Wallet <$> [1..10])
pure block
Expand Down Expand Up @@ -242,7 +242,8 @@ handleTopLevelEffects ::
=> Eff (ChainControlEffect ': MultiAgentPABEffect ': ChainEffect ': effs) ~> Eff effs
handleTopLevelEffects action =
action
& interpret (notifyChainIndex handleControlChain)
& reinterpret notifyChainIndex
& interpret handleControlChain
& PAB.MultiAgent.handleMultiAgent
& interpret handleChain

Expand Down

0 comments on commit aeca113

Please sign in to comment.