import * as tsplus_module_1 from "@effect/core/io/FiberRef/operations/currentEnvironment";
import * as tsplus_module_2 from "@effect/core/io/FiberRef/operations/get";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/flatMap";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/suspendSucceed";
/**
 * Effectfully accesses the specified service in the environment of the
 * effect.
 *
 * Especially useful for creating "accessor" methods on services' companion
 * objects.
 *
 * @tsplus static ets/Effect/Ops serviceWithEffect
 */

export function serviceWithEffect(tag, f, __tsplusTrace) {
  return tsplus_module_4.suspendSucceed(() => tsplus_module_3.flatMap_(tsplus_module_2.get(tsplus_module_1.currentEnvironment.value, __tsplusTrace), env => f(env.unsafeGet(tag)), __tsplusTrace), __tsplusTrace);
}
//# sourceMappingURL=serviceWithEffect.mjs.map