// ets_tracing: off
import { bracket_ } from "../Effect/bracket";
import { chain } from "../Effect/core";
import { pipe } from "../Function";
import { get } from "./get";
import { set } from "./set";
/**
 * Returns an `IO` that runs with `value` bound to the current fiber.
 *
 * Guarantees that fiber data is properly restored via `bracket`.
 */

export const locally = value => use => fiberRef => chain(oldValue => bracket_(set(value)(fiberRef), () => use, () => set(oldValue)(fiberRef)))(get(fiberRef));
//# sourceMappingURL=locally.js.map