def scopes
bend-kit-camber@0.15.0.1 · camber.bend:794
import bend-kit-camber@0.15.0.1/camber.bend as Camber
import Base
import bend-kit-http@0.38.1.1/http.bend as Http
794def scopes(~S: Type, ~K: Data, ~E: Data, ~H: Data,
795 ~before_hook: H -> S -> K -> Metadata -> IO(Step<S, E>),
796 ~after_hook: H -> S -> K -> Http.Res -> IO(S & Result<&2, &1, Error<E>, Http.Res>),
797 ~mapper: S -> K -> Error<E> -> IO(S & Result<&2, &1, Error<E>, Http.Res>),
798 policies: List<&2, Policy<H>>, state: S, +config: K, +meta: Metadata, entered: List<&2, Policy<H>>, body: Http.Body,
799 next: S -> List<&2, Policy<H>> -> Http.Body -> IO(Completion<S, H>)
800) -> IO(Completion<S, H>):
801 match policies:
802 case Nil{}:
803 next(state, entered, body)
804 case Policy{+id, +hooks, +unwind} <> rest:
805 scope = {Policy{id, hooks, unwind} : Policy<H>}
806 do IO<Completion<S, H>>:
807 step : Step<S, E> <- before(~S, ~K, ~E, ~H, ~before_hook, hooks, state, config, meta)
808 inner : Completion<S, H> <- entered.step(~S, ~K, ~E, ~H, ~mapper, config, scope <> entered, body, step, s => ids => b => scopes(~S, ~K, ~E, ~H, ~before_hook, ~after_hook, ~mapper, rest, s, config, meta, ids, b, next))
809 transforms(~S, ~K, ~E, ~H, ~after_hook, ~mapper, unwind, config, inner)