interpose currrently has the "local" semantics of swapping handlers. That is, effects introduced outside of the scope of interpose will not have their dependency handlers swapped. This allows us to "overlay" behaviors on existing handlers.
However, it is also useful to have the "global" semantics of swapping handlers: all effects, in scope or out of scope, will have their dependency handlers swapped. This behavior is crucial in the implementation of scoped effects.
replace :: e :> es => Handler e es -> Eff es ~> Eff es
replace handle m = Eff \es@(Env _ re _) ->
let ix = Rec.index re
in unEff m $ updateEnv ix (mkInternalHandler ix es m)
interposecurrrently has the "local" semantics of swapping handlers. That is, effects introduced outside of the scope ofinterposewill not have their dependency handlers swapped. This allows us to "overlay" behaviors on existing handlers.However, it is also useful to have the "global" semantics of swapping handlers: all effects, in scope or out of scope, will have their dependency handlers swapped. This behavior is crucial in the implementation of scoped effects.