Skip to content

Commit

Permalink
abandon Ramda-style currying in favour of simple currying
Browse files Browse the repository at this point in the history
‘def’ has served two roles:

  - currying an uncurried implementation function; and
  - performing type checking at run time.

At the time of this project's inception in 2015 it seemed unreasonable
to require users to provide curried implementation functions. Defining
curried functions manually was onerous prior to ES6:

    function(x) {
      return function(y) {
        return function(z) {
          return ...;
        };
      };
    }

With ES6, defining curried functions is trivial:

    x => y => z => ...

The landscape has changed since 2015, and it's now reasonable to assume
that users are targeting ES6. Furthermore, the advantages of Ramda-style
currying over simple currying do not justify the additional complexity.
There's no compelling reason for ‘def’ to continue to serve two roles.

User-facing changes:

  - ‘$’ functions must now be applied to arguments one at a time;
  - ‘def’ now requires a curried implementation function;
  - ‘def’ no longer imposes an arbitrary arity limit;
  - ‘def’ functions must now be applied to arguments one at a time; and
  - ‘__’ has been removed (simple currying precludes placeholders).

Internal changes:

  - the ‘checkTypes’ option is now checked in just one place; and
  - ‘def’ is now essentially a no-op if type checking is disabled.
  • Loading branch information
davidchambers committed Apr 1, 2018
1 parent 1761137 commit 48529ee
Show file tree
Hide file tree
Showing 9 changed files with 2,100 additions and 2,509 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"root": true,
"extends": ["./node_modules/sanctuary-style/eslint-es3.json"]
"extends": ["./eslint/es3.js"]
}
11 changes: 11 additions & 0 deletions eslint/es3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
root: true,
extends: ['../node_modules/sanctuary-style/eslint-es3.json'],
rules: {
'func-call-spacing': ['off'],
'indent': require ('./rules/indent'),
'no-unexpected-multiline': ['off'],
},
};
27 changes: 27 additions & 0 deletions eslint/es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

module.exports = {
root: true,
extends: ['../node_modules/sanctuary-style/eslint-es6.json'],
env: {node: true},
rules: {
'func-call-spacing': ['error', 'always', {allowNewlines: true}],
'indent': require ('./rules/indent'),
'no-extra-parens': ['off'],
'no-unexpected-multiline': ['off'],
},
overrides: [
{
files: ['*.md'],
plugins: ['markdown'],
env: {node: false},
rules: {
'max-len': ['off'],
'no-undef': ['off'],
'no-unused-vars': ['off'],
'object-shorthand': ['error', 'always'],
'strict': ['off'],
},
},
],
};
13 changes: 13 additions & 0 deletions eslint/rules/indent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

const common = require ('sanctuary-style/eslint-common.json');


const indent = (JSON.parse (JSON.stringify (common))).rules['indent'];
indent[2].ignoredNodes.push (
'CallExpression',
'CallExpression > *',
'CallExpression > ArrowFunctionExpression ArrowFunctionExpression > *',
'CallExpression > FunctionExpression > BlockStatement'
);
module.exports = indent;
Loading

0 comments on commit 48529ee

Please sign in to comment.