UNPKG

@fpjs/overture

Version:
37 lines (36 loc) 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uncurry = exports.typerep = exports.type = exports.rapply = exports.not = exports.isPrimitive = exports.id = exports.flip = exports.fanout = exports.curry = exports.constant = exports.compose = exports.apply = exports.always = void 0; const id = x => x; exports.id = id; const compose = f => g => x => f(g(x)); exports.compose = compose; const type = x => { if (typeof x === 'object' && '@@type' in x) { return x['@@type']; } return Object.prototype.toString.call(x).slice("[object ".length, -"]".length); }; exports.type = type; const typerep = x => x.constructor; exports.typerep = typerep; const isPrimitive = x => x == null || typeof x !== 'object' && typeof x !== 'function'; exports.isPrimitive = isPrimitive; const curry = f => x => y => f(x, y); exports.curry = curry; const uncurry = f => (x, y) => f(x)(y); exports.uncurry = uncurry; const flip = f => y => x => f(x)(y); exports.flip = flip; const apply = f => f; exports.apply = apply; const rapply = exports.rapply = flip(apply); const constant = x => y => x; exports.constant = constant; const always = exports.always = constant; const not = x => !x; exports.not = not; const fanout = f => g => x => [f(x), g(x)]; exports.fanout = fanout;