source: node_modules/ramda-adjunct/es/liftF.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1import { curryN } from 'ramda';
2import liftFN from './liftFN';
3
4/**
5 * "lifts" a function to be the specified arity, so that it may "map over" objects that satisfy
6 * the fantasy land Apply spec of algebraic structures.
7 *
8 * Lifting is specific for {@link https://github.com/scalaz/scalaz|scalaz} and {@link http://functionaljava.org/|function Java} implementations.
9 * Old version of fantasy land spec were not compatible with this approach,
10 * but as of fantasy land 1.0.0 Apply spec also adopted this approach.
11 *
12 * This function acts as interop for ramda <= 0.23.0 and {@link https://monet.github.io/monet.js/|monet.js}.
13 *
14 * More info {@link https://github.com/fantasyland/fantasy-land/issues/50|here}.
15 *
16 * @func liftF
17 * @memberOf RA
18 * @since {@link https://char0n.github.io/ramda-adjunct/1.2.0|v1.2.0}
19 * @category Function
20 * @sig Apply a => (a... -> a) -> (a... -> a)
21 * @param {Function} fn The function to lift into higher context
22 * @return {Function} The lifted function
23 * @see {@link RA.liftFN|liftFN}
24 * @example
25 *
26 * const { Maybe } = require('monet');
27 *
28 * const add3 = (a, b, c) => a + b + c;
29 * const madd3 = RA.liftF(add3);
30 *
31 * madd3(Maybe.Some(10), Maybe.Some(15), Maybe.Some(17)); //=> Maybe.Some(42)
32 * madd3(Maybe.Some(10), Maybe.Nothing(), Maybe.Some(17)); //=> Maybe.Nothing()
33 */
34var liftF = curryN(1, function (fn) {
35 return liftFN(fn.length, fn);
36});
37export default liftF;
Note: See TracBrowser for help on using the repository browser.