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

var _chunkEBISTSVAjs = require('./chunk-EBISTSVA.js');




var _chunkOTKMOSH2js = require('./chunk-OTKMOSH2.js');


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


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

// src/FromEither.ts
var FromEither_exports = {};
_chunk6C3VEZWHjs.__export.call(void 0, FromEither_exports, {
  chainEitherK: () => chainEitherK,
  chainFirstEitherK: () => chainFirstEitherK,
  chainOptionK: () => chainOptionK,
  filterOrElse: () => filterOrElse,
  fromEitherK: () => fromEitherK,
  fromOption: () => fromOption,
  fromOptionK: () => fromOptionK,
  fromPredicate: () => fromPredicate,
  tapEither: () => tapEither
});
function fromOption(F) {
  return (onNone) => (ma) => F.fromEither(_chunkOTKMOSH2js.isNone.call(void 0, ma) ? _chunkOTKMOSH2js.left.call(void 0, onNone()) : _chunkOTKMOSH2js.right.call(void 0, ma.value));
}
function fromPredicate(F) {
  return (predicate, onFalse) => (a) => F.fromEither(predicate(a) ? _chunkOTKMOSH2js.right.call(void 0, a) : _chunkOTKMOSH2js.left.call(void 0, onFalse(a)));
}
function fromOptionK(F) {
  const fromOptionF = fromOption(F);
  return (onNone) => {
    const from = fromOptionF(onNone);
    return (f) => _chunkSQA7G4TEjs.flow.call(void 0, f, from);
  };
}
function chainOptionK(F, M) {
  const fromOptionKF = fromOptionK(F);
  return (onNone) => {
    const from = fromOptionKF(onNone);
    return (f) => (ma) => M.chain(ma, from(f));
  };
}
function fromEitherK(F) {
  return (f) => _chunkSQA7G4TEjs.flow.call(void 0, f, F.fromEither);
}
function chainEitherK(F, M) {
  const fromEitherKF = fromEitherK(F);
  return (f) => (ma) => M.chain(ma, fromEitherKF(f));
}
function chainFirstEitherK(F, M) {
  const tapEitherM = tapEither(F, M);
  return (f) => (ma) => tapEitherM(ma, f);
}
function filterOrElse(F, M) {
  return (predicate, onFalse) => (ma) => M.chain(ma, (a) => F.fromEither(predicate(a) ? _chunkOTKMOSH2js.right.call(void 0, a) : _chunkOTKMOSH2js.left.call(void 0, onFalse(a))));
}
function tapEither(F, M) {
  const fromEither = fromEitherK(F);
  const tapM = _chunkEBISTSVAjs.tap.call(void 0, M);
  return (self, f) => tapM(self, fromEither(f));
}












exports.fromOption = fromOption; exports.fromPredicate = fromPredicate; exports.fromOptionK = fromOptionK; exports.chainOptionK = chainOptionK; exports.fromEitherK = fromEitherK; exports.chainEitherK = chainEitherK; exports.chainFirstEitherK = chainFirstEitherK; exports.filterOrElse = filterOrElse; exports.tapEither = tapEither; exports.FromEither_exports = FromEither_exports;
