UNPKG

telegram-mtproto

Version:
128 lines (119 loc) 2.92 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Tagged = undefined; var _apropos = require('apropos'); var _tuple = require('./tuple'); var _tuple2 = _interopRequireDefault(_tuple); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } class Tagged { constructor(x) { this.x /*:: ; const xx*/ = x; } bimap(f, g) { return new Tagged(g(this.x)); } left() { return new Tagged((0, _apropos.Left)(this.x)); } right() { return new Tagged((0, _apropos.Right)(this.x)); } static of(x) { return new Tagged(x); } } exports.Tagged = Tagged; // // const dimapʹ = curry((f, g, x) => { // return isFunction(x[dimap]) // ? x[dimap](f, g) // : compose(g)(compose(x)(f)) // }) // // const lmapʹ = curry((f, x) => { // return isFunction(x[lmap]) // ? x[lmap]() // : isFunction(x[dimap]) // ? dimapʹ(f, identity, x) // : compose(x)(f); // }) // // const mapʹ = curry((f, x) => { // return isFunction(x[map]) // ? x[map]() // : isFunction(x[dimap]) // ? dimap(identity, f, x) // : compose(f)(x) // }) // // const arr = f => mapʹ(f, x => x) // // class Profunctor<I, O> { // /*:: + */run: (x: I) => O // constructor(run: (x: I) => O) { // this.run/*:: ; const xx*/ = run // } // dimap(f, g) { // return new Profunctor(dimapʹ(f, g, this.run)) // } // // lmap<Iʹ>(f: (x: Iʹ) => I): Profunctor<Iʹ, O> // return new Profunctor((x: Iʹ) => this.run(f(x))) // } // // map<Oʹ>(f: (x: O) => Oʹ): Profunctor<I, Oʹ> { // return new Profunctor((x: I) => f(this.run(x))) // } // } // // const Profunctor = tagged('run') // // // // // export type λStar<M> = { // of<-T>(data: T): M, // } // // const Star = M => { // // const Star = tagged('run'); // // Star.prototype[dimap] = function(f, g) { // return Star(mapʹ(g, compose(this.run)(f))); // }; // // Star.prototype[lmap] = function(f) { // return Star(compose(this.run)(f)); // }; // // Star.prototype[map] = function(f) { // return Star(mapʹ(f, this.run)); // }; // // Star.prototype.first = function() { // return Star(x => this.run(x._1)[map](y => Tuple(y, x._2))); // }; // // Star.prototype.second = function() { // return Star(x => this.run(x._2)[map](y => Tuple(x._1, y))); // }; // // Star.prototype.left = function() { // return Star(x => x.fold( // a => this.run(a)[map](Left), // a => M[of](Right(a)) // )); // }; // // Star.prototype.right = function() { // return Star(x => x.fold( // a => M[of](Left(a)), // a => this.run(a)[map](Right) // )); // }; // // return Star; // }; //# sourceMappingURL=pro.js.map