Repository: sanctuary-js/sanctuary (js)

Issue:
S.div argument order should match that of S.sub
Currently we have:

```haskell
sub :: FiniteNumber -> (FiniteNumber -> FiniteNumber)
sub_ :: FiniteNumber -> FiniteNumber -> FiniteNumber
```

I suggest we update [`S.div`][1] to match, giving:

```haskell
div :: FiniteNumber -> (FiniteNumber -> FiniteNumber)
div_ :: FiniteNumber -> FiniteNumber -> FiniteNumber
```

The _divide by two_ function would then be `S.div(2)` rather than `S.div(S.__, 2)`. :)


[1]: https://github.com/sanctuary-js/sanctuary/tree/v0.13.2#div


Pull request:
number: flip S.div argument order
Closes #430


Patch:
diff --git a/index.js b/index.js
index 60a5885..6a29cff 100644
--- a/index.js
+++ b/index.js
@@ -3827,24 +3827,49 @@
       [f($.FiniteNumber), $.FiniteNumber],
       product);
 
-  //# div :: FiniteNumber -> NonZeroFiniteNumber -> FiniteNumber
+  //# div :: NonZeroFiniteNumber -> (FiniteNumber -> FiniteNumber)
+  //.
+  //. Takes a non-zero finite number `n` and returns the _divide by `n`_
+  //. function.
+  //.
+  //. See also [`div_`](#div_).
+  //.
+  //. ```javascript
+  //. > S.map(S.div(2), [0, 1, 2, 3])
+  //. [0, 0.5, 1, 1.5]
+  //. ```
+  S.div =
+  def('div',
+      {},
+      [$.NonZeroFiniteNumber, Fn($.FiniteNumber, $.FiniteNumber)],
+      flip$(div_));
+
+  //# div_ :: FiniteNumber -> NonZeroFiniteNumber -> FiniteNumber
   //.
   //. Returns the result of dividing its first argument (a finite number) by
   //. its second argument (a non-zero finite number).
   //.
+  //. See also [`div`](#div).
+  //.
   //. ```javascript
-  //. > S.div(7, 2)
+  //. > S.div_(7, 2)
   //. 3.5
+  //.
+  //. > S.map(S.div_(24), [1, 2, 3, 4])
+  //. [24, 12, 8, 6]
   //. ```
-  function div(x, y) {
+  function div_(x, y) {
     return x / y;
   }
-  S.div =
-  def('div', {}, [$.FiniteNumber, $.NonZeroFiniteNumber, $.FiniteNumber], div);
+  S.div_ =
+  def('div_',
+      {},
+      [$.FiniteNumber, $.NonZeroFiniteNumber, $.FiniteNumber],
+      div_);
 
   //# pow :: FiniteNumber -> (FiniteNumber -> FiniteNumber)
   //.
-  //. Takes a finite number `n` and returns the _`n` squared_ function.
+  //. Takes a finite number `n` and returns the _power of `n`_ function.
   //.
   //. See also [`pow_`](#pow_).
   //.


Test patch:
diff --git a/test/div.js b/test/div.js
index 33dd3da..3739a9c 100644
--- a/test/div.js
+++ b/test/div.js
@@ -8,14 +8,9 @@ var eq = require('./internal/eq');
 test('div', function() {
 
   eq(typeof S.div, 'function');
-  eq(S.div.length, 2);
-  eq(S.div.toString(), 'div :: FiniteNumber -> NonZeroFiniteNumber -> FiniteNumber');
+  eq(S.div.length, 1);
+  eq(S.div.toString(), 'div :: NonZeroFiniteNumber -> (FiniteNumber -> FiniteNumber)');
 
-  eq(S.div(8, 2), 4);
-  eq(S.div(8, -2), -4);
-  eq(S.div(-8, -2), 4);
-  eq(S.div(1.5, 2), 0.75);
-  eq(S.div(1.5, -2), -0.75);
-  eq(S.div(-1.5, -2), 0.75);
+  eq(S.map(S.div(2), [0, 1, 2, 3]), [0, 0.5, 1, 1.5]);
 
 });
diff --git a/test/div_.js b/test/div_.js
new file mode 100644
index 0000000..30503fc
--- /dev/null
+++ b/test/div_.js
@@ -0,0 +1,17 @@
+'use strict';
+
+var S = require('..');
+
+var eq = require('./internal/eq');
+
+
+test('div_', function() {
+
+  eq(typeof S.div_, 'function');
+  eq(S.div_.length, 2);
+  eq(S.div_.toString(), 'div_ :: FiniteNumber -> NonZeroFiniteNumber -> FiniteNumber');
+
+  eq(S.div_(0, 10), 0);
+  eq(S.map(S.div_(24), [1, 2, 3, 4]), [24, 12, 8, 6]);
+
+});