Polysemy: Design heuristics: Grouping interpreters
In our previous log, we ended up with a lot of interpreters:
intrepretUserRegistration =
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
We can leverage InterpretersFor
to provide a single (and simpler) interpreter:
interpretAllUserEffectsCognito =
interpretInternalUserEffectCognito
. intrepretUserAuthenticationCheck
. intrepretUserAuthenticationManagement
. intrepretUserRegistration
. raise3Under @InternalUserEffect
See the full the code here.