From custom Monad to PolysemyGautier DI FOLCO October 29, 2023 [dev] #haskell #design #polysemy
Previously we have studied a custom
and how to refactor it to make it easier to work with.
For reminder, it was this one:
And it was used as a basis for:
At some point, we would like to integrate it with a broader Polysemy-based codebase.
A first move to make would be to replace each reader by Polysemy
type MyAppMonadEffects = '[ Reader SmtpConfig, Reader S3Config, Reader RedisParams ]
Then, to avoid any change in the codebase, we have to drop in
with a fixed
type MyAppMonad m = m ~ Sem MyAppMonadEffects
And then our getters:
= ask getS3Config = ask getRedisParams = ask getSmtpConfig
It's not ideal as effects being fixed dealing with this code (calling/being called by)
raise each time effects differ.
But that's a first step, then we can progressively substitute consumers with
Members and create individual effects/interpreters.