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