import {
  dual
} from "./chunk-ZI34HWXZ.mjs";

// src/internal.ts
var isNone = (fa) => fa._tag === "None";
var isSome = (fa) => fa._tag === "Some";
var none = { _tag: "None" };
var some = (a) => ({ _tag: "Some", value: a });
var isLeft = (ma) => ma._tag === "Left";
var isRight = (ma) => ma._tag === "Right";
var left = (e) => ({ _tag: "Left", left: e });
var right = (a) => ({ _tag: "Right", right: a });
var singleton = (a) => [a];
var isNonEmpty = (as) => as.length > 0;
var head = (as) => as[0];
var tail = (as) => as.slice(1);
var emptyReadonlyArray = [];
var emptyRecord = {};
var has = Object.prototype.hasOwnProperty;
var fromReadonlyNonEmptyArray = (as) => [as[0], ...as.slice(1)];
var liftNullable = (F) => (f, onNullable) => (...a) => {
  const o = f(...a);
  return F.fromEither(
    o == null ? left(onNullable(...a)) : right(o)
  );
};
var liftOption = (F) => (f, onNone) => (...a) => {
  const o = f(...a);
  return F.fromEither(isNone(o) ? left(onNone(...a)) : right(o.value));
};
var flatMapNullable = (F, M) => /* @__PURE__ */ dual(
  3,
  (self, f, onNullable) => M.flatMap(self, liftNullable(F)(f, onNullable))
);
var flatMapOption = (F, M) => /* @__PURE__ */ dual(
  3,
  (self, f, onNone) => M.flatMap(self, liftOption(F)(f, onNone))
);
var flatMapEither = (F, M) => /* @__PURE__ */ dual(
  2,
  (self, f) => M.flatMap(self, (a) => F.fromEither(f(a)))
);
var flatMapIO = (F, M) => /* @__PURE__ */ dual(
  2,
  (self, f) => M.flatMap(self, (a) => F.fromIO(f(a)))
);
var flatMapTask = (F, M) => /* @__PURE__ */ dual(
  2,
  (self, f) => M.flatMap(self, (a) => F.fromTask(f(a)))
);
var flatMapReader = (F, M) => /* @__PURE__ */ dual(
  2,
  (self, f) => M.flatMap(self, (a) => F.fromReader(f(a)))
);

export {
  isNone,
  isSome,
  none,
  some,
  isLeft,
  isRight,
  left,
  right,
  singleton,
  isNonEmpty,
  head,
  tail,
  emptyReadonlyArray,
  emptyRecord,
  has,
  fromReadonlyNonEmptyArray,
  liftNullable,
  liftOption,
  flatMapNullable,
  flatMapOption,
  flatMapEither,
  flatMapIO,
  flatMapTask,
  flatMapReader
};
