"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.do = exports.let = exports.let_ = exports.bind_ = exports.bind = void 0
// tracing: off
const core_1 = require("./core")
const succeed_1 = require("./succeed")
/**
 * 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, core_1.map_)(f(k), (a) => ({ ...k, [tag]: a }), __trace)
  )
}
exports.bind_ = bind_
/**
 * Binds a value in a `do` scope
 *
 * @dataFirst let_
 */
function let__(tag, f, __trace) {
  return (mk) => (0, core_1.map_)(mk, (k) => ({ ...k, [tag]: f(k) }), __trace)
}
exports.let = let__
/**
 * Binds a value in a `do` scope
 */
function let_(mk, tag, f) {
  return (0, core_1.map_)(mk, (k) => ({ ...k, [tag]: f(k) }))
}
exports.let_ = let_
/**
 * Begin a `do` scope
 */
const do_ = (0, succeed_1.succeed)({})
exports.do = do_
//# sourceMappingURL=do.js.map
