"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.do = exports.bind = exports.let = exports.let_ = exports.bind_ = void 0
// tracing: off
const core_1 = require("./core")
const map_1 = require("./map")
/**
 * Binds an effectful value in a `do` scope
 *
 * @dataFirst bind_
 */
function bind(tag, f, __trace) {
  return (mk) => bind_(mk, tag, f, __trace)
}
exports.bind = bind
/**
 * Binds an effectful value in a `do` scope
 */
function bind_(mk, tag, f, __trace) {
  return (0, core_1.chain_)(
    mk,
    (k) => (0, map_1.map_)(f(k), (a) => ({ ...k, [tag]: a })),
    __trace
  )
}
exports.bind_ = bind_
/**
 * Like bind for values
 *
 * @dataFirst let_
 */
function let__(tag, f, __trace) {
  return (mk) => let_(mk, tag, f)
}
exports.let = let__
/**
 * Like bind for values
 */
function let_(mk, tag, f, __trace) {
  return (0, map_1.map_)(mk, (k) => ({ ...k, [tag]: f(k) }), __trace)
}
exports.let_ = let_
const do_ = (0, core_1.succeed)({})
exports.do = do_
//# sourceMappingURL=do.js.map
