Polysemy: Final vs EmbedGautier DI FOLCO February 01, 2023 [Haskell] #haskell #polysemy #design #effects systems
In a previous log, we introduce
Final as an alternative to
If we look at the intents:
Embedaims to lift any
Finalaims to embed higher-order actions in the effects stack
Each of them come with an interpreter allowing to interpret an effect into other effects of the same type.
Let's start with
This is pretty straightforward: for two embedded
Monad, we have to provide a function to convert the first one into the second one.
Now, we can have a look at
A bit more complex: we have to provide two functions to go back and forth between the two Monads.
It's actually due to a property highlight in
Beware: Final actions are interpreted as actions of the final monad, [..] This means that any interpreter built using Final will not respect local/global state semantics based on the order of interpreters run.
See the full the code here and here.