@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">
39 lines (32 loc) • 957 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.asFold = asFold;
exports.choice = choice;
exports.composeGetter = composeGetter;
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 asFold(getter) {
return {
foldMap: function foldMap(monoid, f, s) {
return f(getter.get(s));
}
};
}
/** join two Getter with the same target */
function choice(getter1, getter2) {
return {
get: function get(s) {
return either.either(getter1.get, getter2.get, s);
}
};
}
function composeGetter(ab, sa) {
return {
get: function get(s) {
return ab.get(sa.get(s));
}
};
}