UNPKG

@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">

130 lines (106 loc) 2.32 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.extract = exports.of = undefined; exports.id = id; exports.map = map; exports.ap = ap; exports.chain = chain; exports.reduce = reduce; exports.alt = alt; exports.traverse = traverse; exports.extend = extend; exports.chainRec = chainRec; exports.getSetoid = getSetoid; exports.getOrd = getOrd; exports.getSemigroup = getSemigroup; exports.getMonoid = getMonoid; var _HKT = require('./HKT'); var _ChainRec = require('./ChainRec'); var _Fun = require('./Fun'); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var IsIdentity = function IsIdentity() { _classCallCheck(this, IsIdentity); }; function prj(fa) { return fa; } function inj(a) { return a; } function id(a) { return a; } function map(f, fa) { return inj(f(prj(fa))); } function ap(fab, fa) { return map(prj(fab), fa); } var of = exports.of = inj; function chain(f, fa) { return f(prj(fa)); } function reduce(f, b, fa) { return f(b, prj(fa)); } function alt(fx, fy) { // eslint-disable-line no-unused-vars return fx; } function traverse(applicative, f, ta) { return applicative.map(of, f(prj(ta))); } function extend(f, ea) { return of(f(ea)); } var extract = exports.extract = prj; function chainRec(f, a) { return inj((0, _ChainRec.tailRec)((0, _Fun.compose)(extract, f), a)); } function getSetoid(setoid) { return { equals: function equals(fx, fy) { return setoid.equals(prj(fx), prj(fy)); } }; } function getOrd(ord) { return { equals: getSetoid(ord).equals, compare: function compare(fx, fy) { return ord.compare(prj(fx), prj(fy)); } }; } function getSemigroup(semigroup) { return { concat: function concat(fx, fy) { return inj(semigroup.concat(prj(fx), prj(fy))); } }; } function getMonoid(monoid) { return { concat: getSemigroup(monoid).concat, empty: function empty() { return inj(monoid.empty()); } }; } if (false) { // eslint-disable-line ({ map: map, ap: ap, of: of, chain: chain, reduce: reduce, alt: alt, traverse: traverse, extend: extend, extract: extract, chainRec: chainRec }); }