All files / construct/domain_layer/library/structure Result.bs.js

75.68% Statements 28/37
75% Branches 6/8
70% Functions 7/10
75.68% Lines 28/37

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109    7x 7x 7x 7x     2240375x             2x           7x     1x             2240118x 2x   2240116x         2240110x                                                                         2240669x 1x         2240668x               260x 1x   259x       7x 7x 7x 7x 7x 7x 7x 7x 7x 7x    
'use strict';
 
var Curry = require("bs-platform/lib/js/curry.js");
var Js_exn = require("bs-platform/lib/js/js_exn.js");
var Caml_js_exceptions = require("bs-platform/lib/js/caml_js_exceptions.js");
var Exception$Wonderjs = require("./Exception.bs.js");
 
function succeed(x) {
  return {
          TAG: /* Success */0,
          _0: x
        };
}
 
function fail(x) {
  return {
          TAG: /* Fail */1,
          _0: x
        };
}
 
var _raiseErrorAndReturn = Exception$Wonderjs.buildErr;
 
function failWith(x) {
  return {
          TAG: /* Fail */1,
          _0: Exception$Wonderjs.buildErr(x)
        };
}
 
function either(twoTrackInput, successFunc, failureFunc) {
  if (twoTrackInput.TAG) {
    return Curry._1(failureFunc, twoTrackInput._0);
  } else {
    return Curry._1(successFunc, twoTrackInput._0);
  }
}
 
function bind(twoTrackInput, switchFunc) {
  return either(twoTrackInput, switchFunc, fail);
}
 
function tap(twoTrackInput, oneTrackFunc) {
  return either(twoTrackInput, (function (result) {
                Curry._1(oneTrackFunc, result);
                return {
                        TAG: /* Success */0,
                        _0: result
                      };
              }), fail);
}
 
function tryCatch(oneTrackFunc) {
  try {
    return {
            TAG: /* Success */0,
            _0: Curry._1(oneTrackFunc, undefined)
          };
  }
  catch (raw_e){
    var e = Caml_js_exceptions.internalToOCamlException(raw_e);
    if (e.RE_EXN_ID === Js_exn.$$Error) {
      return {
              TAG: /* Fail */1,
              _0: e._1
            };
    } else {
      return {
              TAG: /* Fail */1,
              _0: Exception$Wonderjs.buildErr("unknown error: " + e)
            };
    }
  }
}
 
function mapSuccess(result, mapFunc) {
  if (result.TAG) {
    return {
            TAG: /* Fail */1,
            _0: result._0
          };
  } else {
    return {
            TAG: /* Success */0,
            _0: Curry._1(mapFunc, result._0)
          };
  }
}
 
function handleFail(result, handleFailFunc) {
  if (result.TAG) {
    return Curry._1(handleFailFunc, result._0);
  } else {
    return result._0;
  }
}
 
exports.succeed = succeed;
exports.fail = fail;
exports._raiseErrorAndReturn = _raiseErrorAndReturn;
exports.failWith = failWith;
exports.either = either;
exports.bind = bind;
exports.tap = tap;
exports.tryCatch = tryCatch;
exports.mapSuccess = mapSuccess;
exports.handleFail = handleFail;
/* No side effect */