Is it be possible, to pass in a function that resolves high-level application-specific effects into lower level effects like State x and especially into Error ServerError? This function would just be a chain of event-handlers.
This way you can use only high level effects in all servant handlers. You can resolve high level effects that could result in a Error ServerError before the servant machinery kicks in and all other effects still propagate outside.
|
interpretServer :: Env es -> Eff (Error ServerError : es) a -> Servant.Handler a |
|
interpretServer env action = do |
|
v <- liftIO $ do |
|
es' <- cloneEnv env |
|
unEff (runErrorNoCallStack action) es' |
|
T.liftEither v |
(I know its possible to handle effects in each effect handler manually, but that seems a lot more tedious than to have a clear boundary between the effects that could cause an Error ServerError and generic ones that can't/shouldn't.)
Is it be possible, to pass in a function that resolves high-level application-specific effects into lower level effects like
State xand especially intoError ServerError? This function would just be a chain of event-handlers.This way you can use only high level effects in all servant handlers. You can resolve high level effects that could result in a
Error ServerErrorbefore the servant machinery kicks in and all other effects still propagate outside.servant-effectful/src/Effectful/Servant.hs
Lines 95 to 100 in 1e574e6
(I know its possible to handle effects in each effect handler manually, but that seems a lot more tedious than to have a clear boundary between the effects that could cause an
Error ServerErrorand generic ones that can't/shouldn't.)