import {
  getFoldableComposition
} from "./chunk-NRCL53NI.mjs";
import {
  getFunctorComposition
} from "./chunk-WKK6AYQI.mjs";
import {
  pipe
} from "./chunk-ZI34HWXZ.mjs";
import {
  __export
} from "./chunk-QK4PKNB3.mjs";

// src/Traversable.ts
var Traversable_exports = {};
__export(Traversable_exports, {
  getTraversableComposition: () => getTraversableComposition,
  sequence: () => sequence,
  traverse: () => traverse
});
function traverse(T, G) {
  return (F) => {
    const traverseT = T.traverse(F);
    const traverseG = G.traverse(F);
    return (f) => (fga) => traverseT(fga, (ga) => traverseG(ga, f));
  };
}
function sequence(T, G) {
  return (F) => {
    const sequenceT = T.sequence(F);
    const sequenceG = G.sequence(F);
    return (fgha) => sequenceT(T.map(fgha, sequenceG));
  };
}
function getTraversableComposition(F, G) {
  const map = getFunctorComposition(F, G).map;
  const FC = getFoldableComposition(F, G);
  const _traverse = traverse(F, G);
  const _sequence = sequence(F, G);
  return {
    map,
    reduce: FC.reduce,
    foldMap: FC.foldMap,
    reduceRight: FC.reduceRight,
    traverse: (H) => {
      const traverseH = _traverse(H);
      return (fga, f) => pipe(fga, traverseH(f));
    },
    sequence: (H) => {
      const sequenceH = _sequence(H);
      return (fgha) => pipe(fgha, sequenceH);
    }
  };
}

export {
  traverse,
  sequence,
  getTraversableComposition,
  Traversable_exports
};
