"use strict";Object.defineProperty(exports, "__esModule", {value: true});

var _chunk6C3VEZWHjs = require('./chunk-6C3VEZWH.js');

// src/function.ts
var function_exports = {};
_chunk6C3VEZWHjs.__export.call(void 0, function_exports, {
  SK: () => SK,
  absurd: () => absurd,
  apply: () => apply,
  constFalse: () => constFalse,
  constNull: () => constNull,
  constTrue: () => constTrue,
  constUndefined: () => constUndefined,
  constVoid: () => constVoid,
  constant: () => constant,
  decrement: () => decrement,
  dual: () => dual,
  flip: () => flip,
  flow: () => flow,
  getBooleanAlgebra: () => getBooleanAlgebra,
  getEndomorphismMonoid: () => getEndomorphismMonoid,
  getMonoid: () => getMonoid,
  getRing: () => getRing,
  getSemigroup: () => getSemigroup,
  getSemiring: () => getSemiring,
  hole: () => hole,
  identity: () => identity,
  increment: () => increment,
  not: () => not,
  pipe: () => pipe,
  tuple: () => tuple,
  tupled: () => tupled,
  unsafeCoerce: () => unsafeCoerce,
  untupled: () => untupled
});
var getBooleanAlgebra = (B) => () => ({
  meet: (x, y) => (a) => B.meet(x(a), y(a)),
  join: (x, y) => (a) => B.join(x(a), y(a)),
  zero: () => B.zero,
  one: () => B.one,
  implies: (x, y) => (a) => B.implies(x(a), y(a)),
  not: (x) => (a) => B.not(x(a))
});
var getSemigroup = (S) => () => ({
  concat: (f, g) => (a) => S.concat(f(a), g(a))
});
var getMonoid = (M) => {
  const getSemigroupM = getSemigroup(M);
  return () => ({
    concat: getSemigroupM().concat,
    empty: () => M.empty
  });
};
var getSemiring = (S) => ({
  add: (f, g) => (x) => S.add(f(x), g(x)),
  zero: () => S.zero,
  mul: (f, g) => (x) => S.mul(f(x), g(x)),
  one: () => S.one
});
var getRing = (R) => {
  const S = getSemiring(R);
  return {
    add: S.add,
    mul: S.mul,
    one: S.one,
    zero: S.zero,
    sub: (f, g) => (x) => R.sub(f(x), g(x))
  };
};
var apply = (a) => (f) => f(a);
function identity(a) {
  return a;
}
var unsafeCoerce = identity;
function constant(a) {
  return () => a;
}
var constTrue = /* @__PURE__ */ constant(true);
var constFalse = /* @__PURE__ */ constant(false);
var constNull = /* @__PURE__ */ constant(null);
var constUndefined = /* @__PURE__ */ constant(void 0);
var constVoid = constUndefined;
function flip(f) {
  return (...args) => {
    if (args.length > 1) {
      return f(args[1], args[0]);
    }
    return (a) => f(a)(args[0]);
  };
}
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
  switch (arguments.length) {
    case 1:
      return ab;
    case 2:
      return function() {
        return bc(ab.apply(this, arguments));
      };
    case 3:
      return function() {
        return cd(bc(ab.apply(this, arguments)));
      };
    case 4:
      return function() {
        return de(cd(bc(ab.apply(this, arguments))));
      };
    case 5:
      return function() {
        return ef(de(cd(bc(ab.apply(this, arguments)))));
      };
    case 6:
      return function() {
        return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
      };
    case 7:
      return function() {
        return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
      };
    case 8:
      return function() {
        return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
      };
    case 9:
      return function() {
        return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
      };
  }
  return;
}
function tuple(...t) {
  return t;
}
function increment(n) {
  return n + 1;
}
function decrement(n) {
  return n - 1;
}
function absurd(_) {
  throw new Error("Called `absurd` function which should be uncallable");
}
function tupled(f) {
  return (a) => f(...a);
}
function untupled(f) {
  return (...a) => f(a);
}
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
  switch (arguments.length) {
    case 1:
      return a;
    case 2:
      return ab(a);
    case 3:
      return bc(ab(a));
    case 4:
      return cd(bc(ab(a)));
    case 5:
      return de(cd(bc(ab(a))));
    case 6:
      return ef(de(cd(bc(ab(a)))));
    case 7:
      return fg(ef(de(cd(bc(ab(a))))));
    case 8:
      return gh(fg(ef(de(cd(bc(ab(a)))))));
    case 9:
      return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
    default: {
      let ret = arguments[0];
      for (let i = 1; i < arguments.length; i++) {
        ret = arguments[i](ret);
      }
      return ret;
    }
  }
}
var hole = absurd;
var SK = (_, b) => b;
function not(predicate) {
  return (a) => !predicate(a);
}
var getEndomorphismMonoid = () => ({
  concat: (first, second) => flow(first, second),
  empty: identity
});
var dual = (arity, body) => {
  const isDataFirst = typeof arity === "number" ? (args) => args.length >= arity : arity;
  return function() {
    const args = Array.from(arguments);
    if (isDataFirst(arguments)) {
      return body.apply(this, args);
    }
    return (self) => body(self, ...args);
  };
};































exports.getBooleanAlgebra = getBooleanAlgebra; exports.getSemigroup = getSemigroup; exports.getMonoid = getMonoid; exports.getSemiring = getSemiring; exports.getRing = getRing; exports.apply = apply; exports.identity = identity; exports.unsafeCoerce = unsafeCoerce; exports.constant = constant; exports.constTrue = constTrue; exports.constFalse = constFalse; exports.constNull = constNull; exports.constUndefined = constUndefined; exports.constVoid = constVoid; exports.flip = flip; exports.flow = flow; exports.tuple = tuple; exports.increment = increment; exports.decrement = decrement; exports.absurd = absurd; exports.tupled = tupled; exports.untupled = untupled; exports.pipe = pipe; exports.hole = hole; exports.SK = SK; exports.not = not; exports.getEndomorphismMonoid = getEndomorphismMonoid; exports.dual = dual; exports.function_exports = function_exports;
