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 (110 loc) 2.53 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.inj = inj; exports.prj = prj; exports.compose = compose; exports.map = map; exports.contramap = contramap; exports.getSetoid = getSetoid; exports.getSemigroup = getSemigroup; exports.getMonoid = getMonoid; exports.getApply = getApply; exports.getApplicative = getApplicative; exports.getChain = getChain; var _HKT = require('./HKT'); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } // The `Const` type constructor, which wraps its first type argument // and ignores its second. That is, `Const a b` is isomorphic to `a` // for any `b`. // // `Const` has some useful instances. For example, the `Applicative` // instance allows us to collect results using a `Monoid` while // ignoring return values. var IsConst = function IsConst() { _classCallCheck(this, IsConst); }; // eslint-disable-line no-unused-vars function inj(a) { return a; } function prj(a) { return a; } function compose(x, y) { return y; } function map(f, fa) { return fa; } function contramap(f, fa) { return fa; } function getSetoid(setoid) { return { equals: function equals(x, y) { return setoid.equals(prj(x), prj(y)); } }; } function getSemigroup(semigroup) { return { concat: function concat(x, y) { return inj(semigroup.concat(prj(x), prj(y))); } }; } function getMonoid(monoid) { var _getSemigroup = getSemigroup(monoid), concat = _getSemigroup.concat; var _empty = inj(monoid.empty()); return { concat: concat, empty: function empty() { return _empty; } }; } function getApply(semigroup) { return { map: map, ap: function ap(fab, fa) { var x = prj(fab); var y = prj(fa); return inj(semigroup.concat(x, y)); } }; } function getApplicative(monoid) { var _getApply = getApply(monoid), map = _getApply.map, ap = _getApply.ap; return { map: map, ap: ap, of: function of(b) { // eslint-disable-line no-unused-vars return inj(monoid.empty()); } }; } function getChain(semigroup) { var _getApply2 = getApply(semigroup), map = _getApply2.map, ap = _getApply2.ap; return { map: map, ap: ap, chain: function chain(f, fa) { return fa; } }; } if (false) { // eslint-disable-line ({ compose: compose, map: map, contramap: contramap }); }