A software engineer website

Polysemy: Higher-order effects with Final

Gautier DI FOLCO January 15, 2023 [Haskell] #haskell #polysemy #design #effects systems

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:

See the full the code here.