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

var _chunk7K74W2G3js = require('./chunk-7K74W2G3.js');


var _chunkSQA7G4TEjs = require('./chunk-SQA7G4TE.js');


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

// src/Writer.ts
var Writer_exports = {};
_chunk6C3VEZWHjs.__export.call(void 0, Writer_exports, {
  Functor: () => Functor,
  URI: () => URI,
  censor: () => censor,
  evalWriter: () => evalWriter,
  evaluate: () => evaluate,
  execWriter: () => execWriter,
  execute: () => execute,
  flap: () => flap2,
  getApplicative: () => getApplicative,
  getApply: () => getApply,
  getChain: () => getChain,
  getMonad: () => getMonad,
  getPointed: () => getPointed,
  listen: () => listen,
  listens: () => listens,
  map: () => map,
  pass: () => pass,
  tell: () => tell,
  writer: () => writer
});
var tell = (w) => () => [void 0, w];
var listen = (fa) => () => {
  const [a, w] = fa();
  return [[a, w], w];
};
var pass = (fa) => () => {
  const [[a, f], w] = fa();
  return [a, f(w)];
};
var listens = (f) => (fa) => () => {
  const [a, w] = fa();
  return [[a, f(w)], w];
};
var censor = (f) => (fa) => () => {
  const [a, w] = fa();
  return [a, f(w)];
};
var _map = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, map(f));
var map = (f) => (fa) => () => {
  const [a, w] = fa();
  return [f(a), w];
};
var URI = "Writer";
var getPointed = (M) => ({
  URI,
  _E: void 0,
  of: (a) => () => [a, M.empty]
});
var getApply = (S) => ({
  URI,
  _E: void 0,
  map: _map,
  ap: (fab, fa) => () => {
    const [f, w1] = fab();
    const [a, w2] = fa();
    return [f(a), S.concat(w1, w2)];
  }
});
var getApplicative = (M) => {
  const A = getApply(M);
  const P = getPointed(M);
  return {
    URI,
    _E: void 0,
    map: _map,
    ap: A.ap,
    of: P.of
  };
};
function getChain(S) {
  const A = getApply(S);
  return {
    URI,
    _E: void 0,
    map: _map,
    ap: A.ap,
    chain: (fa, f) => () => {
      const [a, w1] = fa();
      const [b, w2] = f(a)();
      return [b, S.concat(w1, w2)];
    }
  };
}
function getMonad(M) {
  const A = getApplicative(M);
  const C = getChain(M);
  return {
    URI,
    _E: void 0,
    map: _map,
    ap: A.ap,
    of: A.of,
    chain: C.chain
  };
}
var Functor = {
  URI,
  map: _map
};
var flap2 = /* @__PURE__ */ _chunk7K74W2G3js.flap.call(void 0, Functor);
var evaluate = (fa) => fa()[0];
var execute = (fa) => fa()[1];
var evalWriter = (fa) => fa()[0];
var execWriter = (fa) => fa()[1];
var writer = Functor;






















exports.tell = tell; exports.listen = listen; exports.pass = pass; exports.listens = listens; exports.censor = censor; exports.map = map; exports.URI = URI; exports.getPointed = getPointed; exports.getApply = getApply; exports.getApplicative = getApplicative; exports.getChain = getChain; exports.getMonad = getMonad; exports.Functor = Functor; exports.flap = flap2; exports.evaluate = evaluate; exports.execute = execute; exports.evalWriter = evalWriter; exports.execWriter = execWriter; exports.writer = writer; exports.Writer_exports = Writer_exports;
