Repository: sanctuary-js/sanctuary
Pull request #370 (2017-04-03 01:18:46)

sanctuary-type-classes@4.0.0
https://github.com/sanctuary-js/sanctuary-type-classes/compare/v3.1.0...v4.0.0

:warning: This propagates the breaking change from sanctuary-js/sanctuary-type-classes#37.



Patch:
diff --git a/bower.json b/bower.json
index d47a251..7fcbe99 100644
--- a/bower.json
+++ b/bower.json
@@ -23,7 +23,7 @@
   ],
   "dependencies": {
     "sanctuary-def": "0.9.0",
-    "sanctuary-type-classes": "3.1.0",
+    "sanctuary-type-classes": "4.0.0",
     "sanctuary-type-identifiers": "1.0.0"
   },
   "ignore": [
diff --git a/index.js b/index.js
index c7e3f18..6e90880 100644
--- a/index.js
+++ b/index.js
@@ -998,6 +998,20 @@
   S.extract =
   def('extract', {w: [Z.Comonad]}, [w(a), a], Z.extract);
 
+  //# contramap :: Contravariant f => (b -> a) -> f a -> f b
+  //.
+  //. [Type-safe][sanctuary-def] version of [`Z.contramap`][].
+  //.
+  //. ```javascript
+  //. > S.contramap(s => s.length, Math.sqrt)('Sanctuary')
+  //. 3
+  //. ```
+  S.contramap =
+  def('contramap',
+      {f: [Z.Contravariant]},
+      [Fn(b, a), f(a), f(b)],
+      Z.contramap);
+
   //# filter :: (Applicative f, Foldable f, Monoid (f a)) => (a -> Boolean) -> f a -> f a
   //.
   //. Curried version of [`Z.filter`][].
@@ -1020,7 +1034,7 @@
       [Fn(a, $.Boolean), f(a), f(a)],
       Z.filter);
 
-  //# filterM :: (Monad m, Monoid (m a)) => (a -> Boolean) -> m a -> m a
+  //# filterM :: (Alternative m, Monad m) => (a -> Boolean) -> m a -> m a
   //.
   //. Curried version of [`Z.filterM`][].
   //.
@@ -1038,7 +1052,7 @@
   //. ```
   S.filterM =
   def('filterM',
-      {m: [Z.Monad, Z.Monoid]},
+      {m: [Z.Alternative, Z.Monad]},
       [Fn(a, $.Boolean), m(a), m(a)],
       Z.filterM);
 
@@ -4075,6 +4089,7 @@
 //. [`Z.chain`]:        v:sanctuary-js/sanctuary-type-classes#chain
 //. [`Z.chainRec`]:     v:sanctuary-js/sanctuary-type-classes#chainRec
 //. [`Z.concat`]:       v:sanctuary-js/sanctuary-type-classes#concat
+//. [`Z.contramap`]:    v:sanctuary-js/sanctuary-type-classes#contramap
 //. [`Z.empty`]:        v:sanctuary-js/sanctuary-type-classes#empty
 //. [`Z.equals`]:       v:sanctuary-js/sanctuary-type-classes#equals
 //. [`Z.extend`]:       v:sanctuary-js/sanctuary-type-classes#extend
diff --git a/package.json b/package.json
index 69897e6..44c9e3a 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
   },
   "dependencies": {
     "sanctuary-def": "0.9.0",
-    "sanctuary-type-classes": "3.1.0",
+    "sanctuary-type-classes": "4.0.0",
     "sanctuary-type-identifiers": "1.0.0"
   },
   "devDependencies": {


Test patch:
diff --git a/test/contramap.js b/test/contramap.js
new file mode 100644
index 0000000..0278d4b
--- /dev/null
+++ b/test/contramap.js
@@ -0,0 +1,16 @@
+'use strict';
+
+var S = require('..');
+
+var eq = require('./internal/eq');
+
+
+test('contramap', function() {
+
+  eq(typeof S.contramap, 'function');
+  eq(S.contramap.length, 2);
+  eq(S.contramap.toString(), 'contramap :: Contravariant f => (b -> a) -> f a -> f b');
+
+  eq(S.contramap(S.prop('length'), Math.sqrt)('Sanctuary'), 3);
+
+});
diff --git a/test/filterM.js b/test/filterM.js
index c6e7381..9cd8cdc 100644
--- a/test/filterM.js
+++ b/test/filterM.js
@@ -9,7 +9,7 @@ test('filterM', function() {
 
   eq(typeof S.filterM, 'function');
   eq(S.filterM.length, 2);
-  eq(S.filterM.toString(), 'filterM :: (Monad m, Monoid m) => (a -> Boolean) -> m a -> m a');
+  eq(S.filterM.toString(), 'filterM :: (Alternative m, Monad m) => (a -> Boolean) -> m a -> m a');
 
   eq(S.filterM(S.odd, []), []);
   eq(S.filterM(S.odd, [0, 2, 4, 6, 8]), []);