@dillonkearns/elm-graphql
Version:
<img src="https://cdn.jsdelivr.net/gh/martimatix/logo-graphqelm/logo.svg" alt="dillonearns/elm-graphql logo" width="40%" align="right">
28 lines (23 loc) • 836 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getApplicative = getApplicative;
var _Either = require('./Either');
var either = _interopRequireWildcard(_Either);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function getApplicative(semigroup) {
function ap(fab, fa) {
var ab = either.prj(fab);
var a = either.prj(fa);
if (ab instanceof either.Left && a instanceof either.Left) {
return either.left(semigroup.concat(ab.value0, a.value0));
}
return either.ap(fab, fa);
}
return {
map: either.map,
ap: ap,
of: either.of
};
}