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

var _chunk3GCDIUJCjs = require('./chunk-3GCDIUJC.js');


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


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

// src/StateT.ts
var StateT_exports = {};
_chunk6C3VEZWHjs.__export.call(void 0, StateT_exports, {
  ap: () => ap,
  chain: () => chain,
  evaluate: () => evaluate,
  execute: () => execute,
  flatMap: () => flatMap,
  fromF: () => fromF,
  fromState: () => fromState,
  getStateM: () => getStateM,
  map: () => map,
  of: () => of
});
function of(F) {
  return (a) => (s) => F.of([a, s]);
}
function map(F) {
  return (f) => (fa) => (s) => F.map(fa(s), ([a, s1]) => [f(a), s1]);
}
function ap(M) {
  return (fa) => (fab) => (s) => M.chain(fab(s), ([f, s2]) => M.map(fa(s2), ([a, s3]) => [f(a), s3]));
}
function chain(M) {
  const flatMapM = flatMap(M);
  return (f) => (ma) => flatMapM(ma, f);
}
function flatMap(M) {
  return (ma, f) => (s) => M.chain(ma(s), ([a, s1]) => f(a)(s1));
}
function fromState(F) {
  return (sa) => (s) => F.of(sa(s));
}
function fromF(F) {
  return (ma) => (s) => F.map(ma, (a) => [a, s]);
}
function evaluate(F) {
  return (s) => (ma) => F.map(ma(s), ([a]) => a);
}
function execute(F) {
  return (s) => (ma) => F.map(ma(s), _chunk3GCDIUJCjs.snd);
}
function getStateM(M) {
  const _ap = ap(M);
  const _map = map(M);
  const _chain = chain(M);
  const _evaluate = evaluate(M);
  const _execute = execute(M);
  return {
    map: (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, _map(f)),
    ap: (fab, fa) => _chunkSQA7G4TEjs.pipe.call(void 0, fab, _ap(fa)),
    of: of(M),
    chain: (ma, f) => _chunkSQA7G4TEjs.pipe.call(void 0, ma, _chain(f)),
    get: () => (s) => M.of([s, s]),
    put: (s) => () => M.of([void 0, s]),
    modify: (f) => (s) => M.of([void 0, f(s)]),
    gets: (f) => (s) => M.of([f(s), s]),
    fromState: fromState(M),
    fromM: fromF(M),
    evalState: (fa, s) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, _evaluate(s)),
    execState: (fa, s) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, _execute(s))
  };
}













exports.of = of; exports.map = map; exports.ap = ap; exports.chain = chain; exports.flatMap = flatMap; exports.fromState = fromState; exports.fromF = fromF; exports.evaluate = evaluate; exports.execute = execute; exports.getStateM = getStateM; exports.StateT_exports = StateT_exports;
