Polysemy: Design heuristics: Grouping interpreters
Gautier DI FOLCO April 05, 2023 [Haskell] #haskell #polysemy #design #effects systemsIn our previous log, we ended up with a lot of interpreters:
=
interpret $
\case
SignUp userInfo password -> internalSignUp userInfo password
ConfirmSignUp confirmationInfo -> internalConfirmSignUp confirmationInfo
intrepretUserAuthenticationManagement =
interpret $
\case
SignIn emailAddress password -> internalSignIn emailAddress password
SignOut token -> internalSignOut token
intrepretUserAuthenticationCheck =
interpret $
\case
AuthenticateUser token -> internalAuthenticateUser token
intrepretUserRegistration
We can leverage InterpretersFor
to provide a single (and simpler) interpreter:
=
interpretInternalUserEffectCognito
. intrepretUserAuthenticationCheck
. intrepretUserAuthenticationManagement
. intrepretUserRegistration
. raise3Under @InternalUserEffect
interpretAllUserEffectsCognito
See the full the code here.