import {
  tailRec
} from "./chunk-3AL4EMTU.mjs";
import {
  bindTo,
  flap,
  let_
} from "./chunk-WKK6AYQI.mjs";
import {
  apFirst,
  apS,
  apSecond
} from "./chunk-ZMCLCMOU.mjs";
import {
  bind,
  chainFirst
} from "./chunk-MDNVYLGG.mjs";
import {
  emptyRecord
} from "./chunk-WPJQNT3M.mjs";
import {
  dual,
  identity,
  pipe
} from "./chunk-ZI34HWXZ.mjs";
import {
  __export
} from "./chunk-QK4PKNB3.mjs";

// src/Identity.ts
var Identity_exports = {};
__export(Identity_exports, {
  Alt: () => Alt,
  Applicative: () => Applicative,
  Apply: () => Apply,
  Chain: () => Chain,
  ChainRec: () => ChainRec,
  Comonad: () => Comonad,
  Do: () => Do,
  Foldable: () => Foldable,
  Functor: () => Functor,
  Monad: () => Monad,
  Pointed: () => Pointed,
  Traversable: () => Traversable,
  URI: () => URI,
  alt: () => alt,
  altW: () => altW,
  ap: () => ap,
  apFirst: () => apFirst2,
  apS: () => apS2,
  apSecond: () => apSecond2,
  bind: () => bind2,
  bindTo: () => bindTo2,
  chain: () => chain,
  chainFirst: () => chainFirst2,
  chainRec: () => chainRec,
  duplicate: () => duplicate,
  extend: () => extend,
  extract: () => extract,
  flap: () => flap2,
  flatMap: () => flatMap,
  flatten: () => flatten,
  foldMap: () => foldMap,
  getEq: () => getEq,
  getShow: () => getShow,
  identity: () => identity2,
  let: () => let_2,
  map: () => map,
  of: () => of,
  reduce: () => reduce,
  reduceRight: () => reduceRight,
  sequence: () => sequence,
  traverse: () => traverse
});
var _map = (fa, f) => pipe(fa, map(f));
var _ap = (fab, fa) => pipe(fab, ap(fa));
var _reduce = (fa, b, f) => pipe(fa, reduce(b, f));
var _foldMap = (M) => (fa, f) => pipe(fa, foldMap(M)(f));
var _reduceRight = (fa, b, f) => pipe(fa, reduceRight(b, f));
var _alt = (fa, that) => pipe(fa, alt(that));
var _extend = (wa, f) => pipe(wa, extend(f));
var _traverse = (F) => {
  const traverseF = traverse(F);
  return (ta, f) => pipe(ta, traverseF(f));
};
var map = (f) => (fa) => f(fa);
var ap = (fa) => (fab) => fab(fa);
var of = identity;
var flatMap = /* @__PURE__ */ dual(2, (ma, f) => f(ma));
var extend = (f) => (wa) => f(wa);
var extract = identity;
var duplicate = /* @__PURE__ */ extend(identity);
var flatten = /* @__PURE__ */ flatMap(identity);
var reduce = (b, f) => (fa) => f(b, fa);
var foldMap = () => (f) => (fa) => f(fa);
var reduceRight = (b, f) => (fa) => f(fa, b);
var traverse = (F) => (f) => (ta) => F.map(f(ta), identity);
var sequence = (F) => (ta) => {
  return F.map(ta, identity);
};
var altW = () => identity;
var alt = altW;
var URI = "Identity";
var getShow = identity;
var getEq = identity;
var Functor = {
  URI,
  map: _map
};
var flap2 = /* @__PURE__ */ flap(Functor);
var Pointed = {
  URI,
  of
};
var Apply = {
  URI,
  map: _map,
  ap: _ap
};
var apFirst2 = /* @__PURE__ */ apFirst(Apply);
var apSecond2 = /* @__PURE__ */ apSecond(Apply);
var Applicative = {
  URI,
  map: _map,
  ap: _ap,
  of
};
var Chain = {
  URI,
  map: _map,
  ap: _ap,
  chain: flatMap
};
var Monad = {
  URI,
  map: _map,
  ap: _ap,
  of,
  chain: flatMap
};
var chainFirst2 = /* @__PURE__ */ chainFirst(Chain);
var Foldable = {
  URI,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight
};
var Traversable = {
  URI,
  map: _map,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  traverse: _traverse,
  sequence
};
var Alt = {
  URI,
  map: _map,
  alt: _alt
};
var Comonad = {
  URI,
  map: _map,
  extend: _extend,
  extract
};
var chainRec = tailRec;
var ChainRec = {
  URI,
  map: _map,
  ap: _ap,
  chain: flatMap,
  chainRec
};
var Do = /* @__PURE__ */ of(emptyRecord);
var bindTo2 = /* @__PURE__ */ bindTo(Functor);
var let_2 = /* @__PURE__ */ let_(Functor);
var bind2 = /* @__PURE__ */ bind(Chain);
var apS2 = /* @__PURE__ */ apS(Apply);
var chain = flatMap;
var identity2 = {
  URI,
  map: _map,
  ap: _ap,
  of,
  chain: flatMap,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  traverse: _traverse,
  sequence,
  alt: _alt,
  extract,
  extend: _extend,
  chainRec
};

export {
  map,
  ap,
  of,
  flatMap,
  extend,
  extract,
  duplicate,
  flatten,
  reduce,
  foldMap,
  reduceRight,
  traverse,
  sequence,
  altW,
  alt,
  URI,
  getShow,
  getEq,
  Functor,
  flap2 as flap,
  Pointed,
  Apply,
  apFirst2 as apFirst,
  apSecond2 as apSecond,
  Applicative,
  Chain,
  Monad,
  chainFirst2 as chainFirst,
  Foldable,
  Traversable,
  Alt,
  Comonad,
  chainRec,
  ChainRec,
  Do,
  bindTo2 as bindTo,
  let_2 as let_,
  bind2 as bind,
  apS2 as apS,
  chain,
  identity2 as identity,
  Identity_exports
};
