Skip to content

Commit

Permalink
Merge pull request #499 from sanctuary-js/davidchambers/no-placeholder
Browse files Browse the repository at this point in the history
placeholder: remove S.__
  • Loading branch information
davidchambers authored Mar 11, 2018
2 parents 878afae + 6ecebd3 commit 9d633a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 39 deletions.
39 changes: 2 additions & 37 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,41 +427,6 @@

var def = $.create({checkTypes: checkTypes, env: env});

//. ### Placeholder
//.
//. Sanctuary functions are designed with partial application in mind.
//. In many cases one can define a more specific function in terms of
//. a more general one simply by applying the more general function to
//. some (but not all) of its arguments. For example, one could define
//. `sum :: Foldable f => f Number -> Number` as `S.reduce(S.add, 0)`.
//.
//. In some cases, though, there are multiple orders in which one may
//. wish to provide a function's arguments. `S.concat('prefix')` is a
//. function which prefixes its argument, but how would one define a
//. function which suffixes its argument? It's possible with the help
//. of [`__`](#__), the special placeholder value.
//.
//. The placeholder indicates a hole to be filled at some future time.
//. The following are all equivalent (`_` represents the placeholder):
//.
//. - `f(x, y, z)`
//. - `f(_, y, z)(x)`
//. - `f(_, _, z)(x, y)`
//. - `f(_, _, z)(_, y)(x)`

//# __ :: Placeholder
//.
//. The special [placeholder](#placeholder) value.
//.
//. ```javascript
//. > S.map(S.concat('@'), ['foo', 'bar', 'baz'])
//. ['@foo', '@bar', '@baz']
//.
//. > S.map(S.concat(S.__, '?'), ['foo', 'bar', 'baz'])
//. ['foo?', 'bar?', 'baz?']
//. ```
S.__ = $.__;

//. ### Classify

//# type :: Any -> { namespace :: Maybe String, name :: String, version :: NonNegativeInteger }
Expand Down Expand Up @@ -1380,8 +1345,8 @@
//. > S.A(S.add(1), 42)
//. 43
//.
//. > S.map(S.A(S.__, 100), [S.add(1), Math.sqrt])
//. [101, 10]
//. > S.A(Math.sqrt, 64)
//. 8
//. ```
function A(f, x) {
return f(x);
Expand Down
3 changes: 1 addition & 2 deletions test/A.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var S = require('..');

var eq = require('./internal/eq');
var map = require('./internal/map');


test('A', function() {
Expand All @@ -13,6 +12,6 @@ test('A', function() {
eq(S.A.toString(), 'A :: (a -> b) -> a -> b');

eq(S.A(S.add(1), 1), 2);
eq(map(S.A(S.__, 100))([S.add(1), Math.sqrt]), [101, 10]);
eq(S.A(Math.sqrt, 64), 8);

});

0 comments on commit 9d633a4

Please sign in to comment.