Polysemy: Higher-order effects with Final

In a previous log, we introduced Higher-order effects definition and interpretation through tactics.

Some elements from tactics are already deprecated, and my guess is that it will spread until tactics will be completly removed.

According to the documentation strategies should be choosed if possible.

Let's review our effect:

data When (m :: Type -> Type) a where
  WhenM :: m () -> When m ()

makeSem ''When

Now we can define the interpreter:

interpretWhenFinal :: forall r. Member (Final IO) r => InterpreterFor When r
interpretWhenFinal =
  interpretFinal @IO $
    \case
      WhenM act -> runS act

Here are the key differences:

  • interpretFinal required a Final m to work
  • runS is a general function (while runTSimple is a special case of runT)

See the full the code here.