diff --git a/test/A.js b/test/A.js index a2eb2d56..e3f1d5d1 100644 --- a/test/A.js +++ b/test/A.js @@ -1,10 +1,9 @@ 'use strict'; -var Z = require('sanctuary-type-classes'); - var S = require('..'); var eq = require('./internal/eq'); +var map = require('./internal/map'); test('A', function() { @@ -14,6 +13,6 @@ test('A', function() { eq(S.A.toString(), 'A :: (a -> b) -> a -> b'); eq(S.A(S.inc, 1), 2); - eq(Z.map(S.A(S.__, 100), [S.inc, Math.sqrt]), [101, 10]); + eq(map(S.A(S.__, 100))([S.inc, Math.sqrt]), [101, 10]); }); diff --git a/test/C.js b/test/C.js index 8b71b3f2..7964f5c6 100644 --- a/test/C.js +++ b/test/C.js @@ -1,10 +1,9 @@ 'use strict'; -var Z = require('sanctuary-type-classes'); - var S = require('..'); var eq = require('./internal/eq'); +var map = require('./internal/map'); test('C', function() { @@ -14,6 +13,6 @@ test('C', function() { eq(S.C.toString(), 'C :: (a -> b -> c) -> b -> a -> c'); eq(S.C(S.concat, 'foo', 'bar'), 'barfoo'); - eq(Z.map(S.C(S.concat, '!'), ['BAM', 'POW', 'KA-POW']), ['BAM!', 'POW!', 'KA-POW!']); + eq(map(S.C(S.concat, '!'))(['BAM', 'POW', 'KA-POW']), ['BAM!', 'POW!', 'KA-POW!']); }); diff --git a/test/Either/Either.js b/test/Either/Either.js index 52030d39..5a3d114c 100644 --- a/test/Either/Either.js +++ b/test/Either/Either.js @@ -1,13 +1,13 @@ 'use strict'; var jsc = require('jsverify'); -var Z = require('sanctuary-type-classes'); var S = require('../internal/sanctuary'); var EitherArb = require('../internal/EitherArb'); var Identity = require('../internal/Identity'); var IdentityArb = require('../internal/IdentityArb'); +var equals = require('../internal/equals'); var laws = require('../internal/laws'); var squareRoot = require('../internal/squareRoot'); @@ -37,7 +37,7 @@ suite('Either', function() { suite('Semigroup laws', function() { - var semigroupLaws = laws.Semigroup(Z.equals); + var semigroupLaws = laws.Semigroup(equals); semigroupLaws.associativity( EitherArb(jsc.string, jsc.string), @@ -49,7 +49,7 @@ suite('Either', function() { suite('Functor laws', function() { - var functorLaws = laws.Functor(Z.equals); + var functorLaws = laws.Functor(equals); functorLaws.identity( EitherArb(jsc.string, jsc.number) @@ -65,7 +65,7 @@ suite('Either', function() { suite('Bifunctor laws', function() { - var bifunctorLaws = laws.Bifunctor(Z.equals); + var bifunctorLaws = laws.Bifunctor(equals); bifunctorLaws.identity( EitherArb(jsc.string, jsc.number) @@ -83,7 +83,7 @@ suite('Either', function() { suite('Apply laws', function() { - var applyLaws = laws.Apply(Z.equals); + var applyLaws = laws.Apply(equals); applyLaws.composition( EitherArb(jsc.string, jsc.constant(Math.sqrt)), @@ -95,7 +95,7 @@ suite('Either', function() { suite('Applicative laws', function() { - var applicativeLaws = laws.Applicative(Z.equals, S.Either); + var applicativeLaws = laws.Applicative(equals, S.Either); applicativeLaws.identity( EitherArb(jsc.string, jsc.number) @@ -115,7 +115,7 @@ suite('Either', function() { suite('Chain laws', function() { - var chainLaws = laws.Chain(Z.equals); + var chainLaws = laws.Chain(equals); chainLaws.associativity( EitherArb(jsc.string, jsc.array(jsc.number)), @@ -127,7 +127,7 @@ suite('Either', function() { suite('Monad laws', function() { - var monadLaws = laws.Monad(Z.equals, S.Either); + var monadLaws = laws.Monad(equals, S.Either); monadLaws.leftIdentity( jsc.constant(squareRoot), @@ -142,7 +142,7 @@ suite('Either', function() { suite('Alt laws', function() { - var altLaws = laws.Alt(Z.equals); + var altLaws = laws.Alt(equals); altLaws.associativity( EitherArb(jsc.string, jsc.number), @@ -160,7 +160,7 @@ suite('Either', function() { suite('Foldable laws', function() { - var foldableLaws = laws.Foldable(Z.equals); + var foldableLaws = laws.Foldable(equals); foldableLaws.associativity( jsc.constant(function(x, y) { return x + y; }), @@ -172,7 +172,7 @@ suite('Either', function() { suite('Traversable laws', function() { - var traversableLaws = laws.Traversable(Z.equals); + var traversableLaws = laws.Traversable(equals); traversableLaws.naturality( jsc.constant(S.compose(S.Just, S.prop('value'))), @@ -196,7 +196,7 @@ suite('Either', function() { suite('Extend laws', function() { - var extendLaws = laws.Extend(Z.equals); + var extendLaws = laws.Extend(equals); extendLaws.associativity( EitherArb(jsc.string, jsc.integer), diff --git a/test/Maybe/Maybe.js b/test/Maybe/Maybe.js index c83fac43..c74809b1 100644 --- a/test/Maybe/Maybe.js +++ b/test/Maybe/Maybe.js @@ -1,7 +1,6 @@ 'use strict'; var jsc = require('jsverify'); -var Z = require('sanctuary-type-classes'); var S = require('../internal/sanctuary'); @@ -9,6 +8,7 @@ var EitherArb = require('../internal/EitherArb'); var Identity = require('../internal/Identity'); var IdentityArb = require('../internal/IdentityArb'); var MaybeArb = require('../internal/MaybeArb'); +var equals = require('../internal/equals'); var laws = require('../internal/laws'); @@ -37,7 +37,7 @@ suite('Maybe', function() { suite('Semigroup laws', function() { - var semigroupLaws = laws.Semigroup(Z.equals); + var semigroupLaws = laws.Semigroup(equals); semigroupLaws.associativity( MaybeArb(jsc.string), @@ -49,7 +49,7 @@ suite('Maybe', function() { suite('Monoid laws', function() { - var monoidLaws = laws.Monoid(Z.equals, S.Maybe); + var monoidLaws = laws.Monoid(equals, S.Maybe); monoidLaws.leftIdentity( MaybeArb(jsc.string) @@ -63,7 +63,7 @@ suite('Maybe', function() { suite('Functor laws', function() { - var functorLaws = laws.Functor(Z.equals); + var functorLaws = laws.Functor(equals); functorLaws.identity( MaybeArb(jsc.number) @@ -79,7 +79,7 @@ suite('Maybe', function() { suite('Apply laws', function() { - var applyLaws = laws.Apply(Z.equals); + var applyLaws = laws.Apply(equals); applyLaws.composition( MaybeArb(jsc.constant(Math.sqrt)), @@ -91,7 +91,7 @@ suite('Maybe', function() { suite('Applicative laws', function() { - var applicativeLaws = laws.Applicative(Z.equals, S.Maybe); + var applicativeLaws = laws.Applicative(equals, S.Maybe); applicativeLaws.identity( MaybeArb(jsc.number) @@ -111,7 +111,7 @@ suite('Maybe', function() { suite('Chain laws', function() { - var chainLaws = laws.Chain(Z.equals); + var chainLaws = laws.Chain(equals); chainLaws.associativity( MaybeArb(jsc.array(jsc.asciistring)), @@ -123,7 +123,7 @@ suite('Maybe', function() { suite('Monad laws', function() { - var monadLaws = laws.Monad(Z.equals, S.Maybe); + var monadLaws = laws.Monad(equals, S.Maybe); monadLaws.leftIdentity( jsc.constant(S.head), @@ -138,7 +138,7 @@ suite('Maybe', function() { suite('Alt laws', function() { - var altLaws = laws.Alt(Z.equals); + var altLaws = laws.Alt(equals); altLaws.associativity( MaybeArb(jsc.number), @@ -156,7 +156,7 @@ suite('Maybe', function() { suite('Plus laws', function() { - var plusLaws = laws.Plus(Z.equals, S.Maybe); + var plusLaws = laws.Plus(equals, S.Maybe); plusLaws.leftIdentity( MaybeArb(jsc.number) @@ -174,7 +174,7 @@ suite('Maybe', function() { suite('Alternative laws', function() { - var alternativeLaws = laws.Alternative(Z.equals, S.Maybe); + var alternativeLaws = laws.Alternative(equals, S.Maybe); alternativeLaws.distributivity( MaybeArb(jsc.number), @@ -190,7 +190,7 @@ suite('Maybe', function() { suite('Foldable laws', function() { - var foldableLaws = laws.Foldable(Z.equals); + var foldableLaws = laws.Foldable(equals); foldableLaws.associativity( jsc.constant(function(x, y) { return x + y; }), @@ -202,7 +202,7 @@ suite('Maybe', function() { suite('Traversable laws', function() { - var traversableLaws = laws.Traversable(Z.equals); + var traversableLaws = laws.Traversable(equals); traversableLaws.naturality( jsc.constant(S.eitherToMaybe), @@ -226,7 +226,7 @@ suite('Maybe', function() { suite('Extend laws', function() { - var extendLaws = laws.Extend(Z.equals); + var extendLaws = laws.Extend(equals); extendLaws.associativity( MaybeArb(jsc.integer), diff --git a/test/T.js b/test/T.js index 26746f37..ab7ccc43 100644 --- a/test/T.js +++ b/test/T.js @@ -1,10 +1,9 @@ 'use strict'; -var Z = require('sanctuary-type-classes'); - var S = require('..'); var eq = require('./internal/eq'); +var map = require('./internal/map'); test('T', function() { @@ -14,6 +13,6 @@ test('T', function() { eq(S.T.toString(), 'T :: a -> (a -> b) -> b'); eq(S.T(42, S.inc), 43); - eq(Z.map(S.T(100), [S.inc, Math.sqrt]), [101, 10]); + eq(map(S.T(100))([S.inc, Math.sqrt]), [101, 10]); }); diff --git a/test/flip.js b/test/flip.js index 71b52cb7..fd3d9a37 100644 --- a/test/flip.js +++ b/test/flip.js @@ -1,10 +1,9 @@ 'use strict'; -var Z = require('sanctuary-type-classes'); - var S = require('..'); var eq = require('./internal/eq'); +var map = require('./internal/map'); test('flip', function() { @@ -13,7 +12,7 @@ test('flip', function() { eq(S.flip.length, 3); eq(S.flip.toString(), 'flip :: ((a, b) -> c) -> b -> a -> c'); - eq(Z.map(S.flip(Math.pow, 2), [1, 2, 3, 4, 5]), [1, 4, 9, 16, 25]); + eq(map(S.flip(Math.pow, 2))([1, 2, 3, 4, 5]), [1, 4, 9, 16, 25]); eq(S.flip(S.indexOf, ['a', 'b', 'c', 'd'], 'c'), S.Just(2)); }); diff --git a/test/internal/laws/$.js b/test/internal/$.js similarity index 100% rename from test/internal/laws/$.js rename to test/internal/$.js diff --git a/test/internal/Compose.js b/test/internal/Compose.js index 5d442591..3890ebfc 100644 --- a/test/internal/Compose.js +++ b/test/internal/Compose.js @@ -1,7 +1,12 @@ 'use strict'; var FL = require('fantasy-land'); -var Z = require('sanctuary-type-classes'); + +var ap = require('./ap'); +var equals = require('./equals'); +var map = require('./map'); +var of = require('./of'); +var toString = require('./toString'); // Compose :: (Apply f, Apply g) => { of :: b -> f b } -> { of :: c -> g c } -> f (g a) -> Compose f g a @@ -15,19 +20,19 @@ module.exports = function Compose(F) { ComposeFG['@@type'] = 'sanctuary/Compose'; ComposeFG[FL.of] = function(x) { - return ComposeFG(Z.of(F, Z.of(G, x))); + return ComposeFG(of(F)(of(G)(x))); }; ComposeFG.prototype[FL.equals] = function(other) { - return Z.equals(this.value, other.value); + return equals(this.value)(other.value); }; ComposeFG.prototype[FL.map] = function(f) { - return ComposeFG(Z.map(function(y) { return Z.map(f, y); }, this.value)); + return ComposeFG(map(map(f))(this.value)); }; ComposeFG.prototype[FL.ap] = function(other) { - return ComposeFG(Z.ap(Z.map(function(u) { return function(y) { return Z.ap(u, y); }; }, other.value), this.value)); + return ComposeFG(ap(map(ap)(other.value))(this.value)); }; // name :: TypeRep a -> String @@ -41,7 +46,7 @@ module.exports = function Compose(F) { ComposeFG.prototype.toString = function() { return 'Compose(' + name(F) + ')' + '(' + name(G) + ')' + - '(' + Z.toString(this.value) + ')'; + '(' + toString(this.value) + ')'; }; return ComposeFG; diff --git a/test/internal/EitherArb.js b/test/internal/EitherArb.js index 1fff6792..b732aac6 100644 --- a/test/internal/EitherArb.js +++ b/test/internal/EitherArb.js @@ -1,13 +1,14 @@ 'use strict'; var jsc = require('jsverify'); -var Z = require('sanctuary-type-classes'); var S = require('./sanctuary'); +var toString = require('./toString'); + // EitherArb :: Arbitrary a -> Arbitrary b -> Arbitrary (Either a b) module.exports = function EitherArb(lArb, rArb) { - return jsc.oneof(lArb.smap(S.Left, S.prop('value'), Z.toString), - rArb.smap(S.Right, S.prop('value'), Z.toString)); + return jsc.oneof(lArb.smap(S.Left, S.prop('value'), toString), + rArb.smap(S.Right, S.prop('value'), toString)); }; diff --git a/test/internal/Identity.js b/test/internal/Identity.js index e13a0186..85d254cb 100644 --- a/test/internal/Identity.js +++ b/test/internal/Identity.js @@ -2,7 +2,10 @@ var FL = require('fantasy-land'); -var Z = require('sanctuary-type-classes'); +var concat = require('./concat'); +var equals = require('./equals'); +var map = require('./map'); +var toString = require('./toString'); // Identity :: a -> Identity a @@ -16,11 +19,11 @@ Identity['@@type'] = 'sanctuary/Identity'; Identity[FL.of] = Identity; Identity.prototype[FL.equals] = function(other) { - return Z.equals(this.value, other.value); + return equals(this.value)(other.value); }; Identity.prototype[FL.concat] = function(other) { - return Identity(Z.concat(this.value, other.value)); + return Identity(concat(this.value)(other.value)); }; Identity.prototype[FL.map] = function(f) { @@ -28,7 +31,7 @@ Identity.prototype[FL.map] = function(f) { }; Identity.prototype[FL.ap] = function(other) { - return Z.map(other.value, this); + return map(other.value)(this); }; Identity.prototype[FL.chain] = function(f) { @@ -40,7 +43,7 @@ Identity.prototype[FL.reduce] = function(f, x) { }; Identity.prototype[FL.traverse] = function(f, of) { - return Z.map(Identity, f(this.value)); + return map(Identity)(f(this.value)); }; Identity.prototype[FL.extend] = function(f) { @@ -53,7 +56,7 @@ Identity.prototype[FL.extract] = function() { Identity.prototype.inspect = Identity.prototype.toString = function() { - return 'Identity(' + Z.toString(this.value) + ')'; + return 'Identity(' + toString(this.value) + ')'; }; module.exports = Identity; diff --git a/test/internal/IdentityArb.js b/test/internal/IdentityArb.js index 0c71fc10..4d28b0af 100644 --- a/test/internal/IdentityArb.js +++ b/test/internal/IdentityArb.js @@ -1,13 +1,12 @@ 'use strict'; -var Z = require('sanctuary-type-classes'); - var S = require('./sanctuary'); var Identity = require('./Identity'); +var toString = require('./toString'); // IdentityArb :: Arbitrary a -> Arbitrary (Identity a) module.exports = function IdentityArb(arb) { - return arb.smap(Identity, S.prop('value'), Z.toString); + return arb.smap(Identity, S.prop('value'), toString); }; diff --git a/test/internal/MaybeArb.js b/test/internal/MaybeArb.js index 473654f3..79e065ca 100644 --- a/test/internal/MaybeArb.js +++ b/test/internal/MaybeArb.js @@ -1,13 +1,14 @@ 'use strict'; var jsc = require('jsverify'); -var Z = require('sanctuary-type-classes'); var S = require('./sanctuary'); +var toString = require('./toString'); + // MaybeArb :: Arbitrary a -> Arbitrary (Maybe a) module.exports = function MaybeArb(arb) { - return jsc.oneof(arb.smap(S.Just, S.prop('value'), Z.toString), + return jsc.oneof(arb.smap(S.Just, S.prop('value'), toString), jsc.constant(S.Nothing)); }; diff --git a/test/internal/laws/alt_.js b/test/internal/alt.js similarity index 100% rename from test/internal/laws/alt_.js rename to test/internal/alt.js diff --git a/test/internal/laws/ap.js b/test/internal/ap.js similarity index 100% rename from test/internal/laws/ap.js rename to test/internal/ap.js diff --git a/test/internal/laws/bimap.js b/test/internal/bimap.js similarity index 100% rename from test/internal/laws/bimap.js rename to test/internal/bimap.js diff --git a/test/internal/laws/chain_.js b/test/internal/chain.js similarity index 100% rename from test/internal/laws/chain_.js rename to test/internal/chain.js diff --git a/test/internal/laws/composeK.js b/test/internal/composeK.js similarity index 89% rename from test/internal/laws/composeK.js rename to test/internal/composeK.js index f8b0001f..8dc34887 100644 --- a/test/internal/laws/composeK.js +++ b/test/internal/composeK.js @@ -1,6 +1,6 @@ 'use strict'; -var chain = require('./chain_'); +var chain = require('./chain'); // composeK :: Chain m => (b -> m c) -> (a -> m b) -> a -> m c // diff --git a/test/internal/laws/compose.js b/test/internal/compose_.js similarity index 100% rename from test/internal/laws/compose.js rename to test/internal/compose_.js diff --git a/test/internal/laws/concat.js b/test/internal/concat.js similarity index 100% rename from test/internal/laws/concat.js rename to test/internal/concat.js diff --git a/test/internal/laws/curry2.js b/test/internal/curry2.js similarity index 100% rename from test/internal/laws/curry2.js rename to test/internal/curry2.js diff --git a/test/internal/laws/curry3.js b/test/internal/curry3.js similarity index 100% rename from test/internal/laws/curry3.js rename to test/internal/curry3.js diff --git a/test/internal/eq.js b/test/internal/eq.js index 92d0c68d..e273f40a 100644 --- a/test/internal/eq.js +++ b/test/internal/eq.js @@ -2,11 +2,12 @@ var assert = require('assert'); -var Z = require('sanctuary-type-classes'); +var equals = require('./equals'); +var toString = require('./toString'); // eq :: (a, b) -> Undefined ! module.exports = function eq(actual, expected) { assert.strictEqual(arguments.length, eq.length); - assert.strictEqual(Z.toString(actual), Z.toString(expected)); - assert.strictEqual(Z.equals(actual, expected), true); + assert.strictEqual(toString(actual), toString(expected)); + assert.strictEqual(equals(actual)(expected), true); }; diff --git a/test/internal/equals.js b/test/internal/equals.js new file mode 100644 index 00000000..9cee5987 --- /dev/null +++ b/test/internal/equals.js @@ -0,0 +1,8 @@ +'use strict'; + +var Z = require('sanctuary-type-classes'); + +var curry2 = require('./curry2'); + +// equals :: a -> b -> Boolean +module.exports = curry2(Z.equals); diff --git a/test/internal/laws/extend_.js b/test/internal/extend.js similarity index 100% rename from test/internal/laws/extend_.js rename to test/internal/extend.js diff --git a/test/internal/laws/forall.js b/test/internal/forall.js similarity index 100% rename from test/internal/laws/forall.js rename to test/internal/forall.js diff --git a/test/internal/laws/id.js b/test/internal/id.js similarity index 100% rename from test/internal/laws/id.js rename to test/internal/id.js diff --git a/test/internal/laws/Alt.js b/test/internal/laws/Alt.js index f84ef304..876d11dd 100644 --- a/test/internal/laws/Alt.js +++ b/test/internal/laws/Alt.js @@ -1,8 +1,8 @@ 'use strict'; -var alt = require('./alt_'); -var forall = require('./forall'); -var map = require('./map'); +var alt = require('../alt'); +var forall = require('../forall'); +var map = require('../map'); module.exports = function(equals) { @@ -12,14 +12,14 @@ module.exports = function(equals) { associativity: function(a, b, c) { var lhs = alt(alt(a)(b))(c); var rhs = alt(a)(alt(b)(c)); - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // f <$> (a <|> b) = (f <$> a) <|> (f <$> b) distributivity: function(a, b, f) { var lhs = map(f)(alt(a)(b)); var rhs = alt(map(f)(a))(map(f)(b)); - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Alternative.js b/test/internal/laws/Alternative.js index c60a21c0..3e3b3086 100644 --- a/test/internal/laws/Alternative.js +++ b/test/internal/laws/Alternative.js @@ -2,9 +2,9 @@ var Z = require('sanctuary-type-classes'); -var alt = require('./alt_'); -var ap = require('./ap'); -var forall = require('./forall'); +var alt = require('../alt'); +var ap = require('../ap'); +var forall = require('../forall'); module.exports = function(equals, A) { @@ -15,14 +15,14 @@ module.exports = function(equals, A) { distributivity: function(x, f, g) { var lhs = ap(alt(f)(g))(x); var rhs = alt(ap(f)(x))(ap(g)(x)); - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // zero <*> x = zero annihilation: function(x) { var lhs = ap(zero)(x); var rhs = zero; - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Applicative.js b/test/internal/laws/Applicative.js index 50318613..b077df58 100644 --- a/test/internal/laws/Applicative.js +++ b/test/internal/laws/Applicative.js @@ -1,10 +1,10 @@ 'use strict'; -var $ = require('./$'); -var ap = require('./ap'); -var forall = require('./forall'); -var id = require('./id'); -var of = require('./of'); +var $ = require('../$'); +var ap = require('../ap'); +var forall = require('../forall'); +var id = require('../id'); +var of = require('../of'); module.exports = function(equals, A) { @@ -15,21 +15,21 @@ module.exports = function(equals, A) { identity: function(v) { var lhs = ap(pure(id))(v); var rhs = v; - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // pure f <*> pure x = pure (f x) homomorphism: function(f, x) { var lhs = ap(pure(f))(pure(x)); var rhs = pure(f(x)); - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // u <*> pure y = pure ($ y) <*> u interchange: function(u, y) { var lhs = ap(u)(pure(y)); var rhs = ap(pure($(y)))(u); - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Apply.js b/test/internal/laws/Apply.js index ed3ec84a..42a0a199 100644 --- a/test/internal/laws/Apply.js +++ b/test/internal/laws/Apply.js @@ -1,9 +1,9 @@ 'use strict'; -var ap = require('./ap'); -var compose = require('./compose'); -var forall = require('./forall'); -var map = require('./map'); +var ap = require('../ap'); +var compose = require('../compose_'); +var forall = require('../forall'); +var map = require('../map'); module.exports = function(equals) { @@ -13,7 +13,7 @@ module.exports = function(equals) { composition: function(u, v, w) { var lhs = ap(ap(map(compose)(u))(v))(w); var rhs = ap(u)(ap(v)(w)); - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Bifunctor.js b/test/internal/laws/Bifunctor.js index a9dae6fc..182116e8 100644 --- a/test/internal/laws/Bifunctor.js +++ b/test/internal/laws/Bifunctor.js @@ -1,9 +1,9 @@ 'use strict'; -var bimap = require('./bimap'); -var compose = require('./compose'); -var forall = require('./forall'); -var id = require('./id'); +var bimap = require('../bimap'); +var compose = require('../compose_'); +var forall = require('../forall'); +var id = require('../id'); module.exports = function(equals) { @@ -13,14 +13,14 @@ module.exports = function(equals) { identity: function(p) { var lhs = bimap(id)(id)(p); var rhs = p; - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // bimap (f . g) (h . i) p = bimap f h (bimap g i p) composition: function(p, f, g, h, i) { var lhs = bimap(compose(f)(g))(compose(h)(i))(p); var rhs = bimap(f)(h)(bimap(g)(i)(p)); - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Chain.js b/test/internal/laws/Chain.js index 05547b8d..1dfbdbf6 100644 --- a/test/internal/laws/Chain.js +++ b/test/internal/laws/Chain.js @@ -1,8 +1,8 @@ 'use strict'; -var chain = require('./chain_'); -var composeK = require('./composeK'); -var forall = require('./forall'); +var chain = require('../chain'); +var composeK = require('../composeK'); +var forall = require('../forall'); module.exports = function(equals) { @@ -12,7 +12,7 @@ module.exports = function(equals) { associativity: function(m, f, g) { var lhs = chain(g)(chain(f)(m)); var rhs = chain(composeK(g)(f))(m); - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Extend.js b/test/internal/laws/Extend.js index 7d5761e0..7cb232f8 100644 --- a/test/internal/laws/Extend.js +++ b/test/internal/laws/Extend.js @@ -1,8 +1,8 @@ 'use strict'; -var compose = require('./compose'); -var extend = require('./extend_'); -var forall = require('./forall'); +var compose = require('../compose_'); +var extend = require('../extend'); +var forall = require('../forall'); module.exports = function(equals) { @@ -12,7 +12,7 @@ module.exports = function(equals) { associativity: function(w, f, g) { var lhs = compose(extend(f))(extend(g))(w); var rhs = extend(compose(f)(extend(g)))(w); - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Foldable.js b/test/internal/laws/Foldable.js index 58cca3a5..c0c868df 100644 --- a/test/internal/laws/Foldable.js +++ b/test/internal/laws/Foldable.js @@ -1,7 +1,7 @@ 'use strict'; -var forall = require('./forall'); -var reduce = require('./reduce'); +var forall = require('../forall'); +var reduce = require('../reduce'); module.exports = function(equals) { @@ -11,7 +11,7 @@ module.exports = function(equals) { associativity: function(f, x, u) { var lhs = reduce(f)(x)(u); var rhs = reduce(f)(x)(reduce(function(xs, x) { return xs.concat([x]); })([])(u)); - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Functor.js b/test/internal/laws/Functor.js index ad86d04c..f3ed2580 100644 --- a/test/internal/laws/Functor.js +++ b/test/internal/laws/Functor.js @@ -1,9 +1,9 @@ 'use strict'; -var compose = require('./compose'); -var forall = require('./forall'); -var id = require('./id'); -var map = require('./map'); +var compose = require('../compose_'); +var forall = require('../forall'); +var id = require('../id'); +var map = require('../map'); module.exports = function(equals) { @@ -13,14 +13,14 @@ module.exports = function(equals) { identity: function(u) { var lhs = map(id)(u); var rhs = u; - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // (f . g) <$> u = f <$> g <$> u composition: function(u, f, g) { var lhs = map(compose(f)(g))(u); var rhs = compose(map(f))(map(g))(u); - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Monad.js b/test/internal/laws/Monad.js index 244cb265..53d3aec9 100644 --- a/test/internal/laws/Monad.js +++ b/test/internal/laws/Monad.js @@ -1,8 +1,8 @@ 'use strict'; -var chain = require('./chain_'); -var forall = require('./forall'); -var of = require('./of'); +var chain = require('../chain'); +var forall = require('../forall'); +var of = require('../of'); module.exports = function(equals, M) { @@ -13,14 +13,14 @@ module.exports = function(equals, M) { leftIdentity: function(f, x) { var lhs = chain(f)(pure(x)); var rhs = f(x); - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // m >>= pure = m rightIdentity: function(m) { var lhs = chain(pure)(m); var rhs = m; - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Monoid.js b/test/internal/laws/Monoid.js index a89ffd2e..9d881716 100644 --- a/test/internal/laws/Monoid.js +++ b/test/internal/laws/Monoid.js @@ -2,8 +2,8 @@ var Z = require('sanctuary-type-classes'); -var concat = require('./concat'); -var forall = require('./forall'); +var concat = require('../concat'); +var forall = require('../forall'); module.exports = function(equals, M) { @@ -14,14 +14,14 @@ module.exports = function(equals, M) { leftIdentity: function(m) { var lhs = concat(empty)(m); var rhs = m; - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // m `concat` empty = m rightIdentity: function(m) { var lhs = concat(m)(empty); var rhs = m; - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Plus.js b/test/internal/laws/Plus.js index f7142a4d..8a842d7e 100644 --- a/test/internal/laws/Plus.js +++ b/test/internal/laws/Plus.js @@ -2,9 +2,9 @@ var Z = require('sanctuary-type-classes'); -var alt = require('./alt_'); -var forall = require('./forall'); -var map = require('./map'); +var alt = require('../alt'); +var forall = require('../forall'); +var map = require('../map'); module.exports = function(equals, P) { @@ -15,21 +15,21 @@ module.exports = function(equals, P) { leftIdentity: function(x) { var lhs = alt(zero)(x); var rhs = x; - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // x <|> zero = x rightIdentity: function(x) { var lhs = alt(x)(zero); var rhs = x; - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // f <$> zero = zero annihilation: function(f) { var lhs = map(f)(zero); var rhs = zero; - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Semigroup.js b/test/internal/laws/Semigroup.js index db71630b..f7279f14 100644 --- a/test/internal/laws/Semigroup.js +++ b/test/internal/laws/Semigroup.js @@ -1,7 +1,7 @@ 'use strict'; -var concat = require('./concat'); -var forall = require('./forall'); +var concat = require('../concat'); +var forall = require('../forall'); module.exports = function(equals) { @@ -11,7 +11,7 @@ module.exports = function(equals) { associativity: function(x, y, z) { var lhs = concat(concat(x)(y))(z); var rhs = concat(x)(concat(y)(z)); - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/Setoid.js b/test/internal/laws/Setoid.js index b3a85d06..f547e283 100644 --- a/test/internal/laws/Setoid.js +++ b/test/internal/laws/Setoid.js @@ -1,25 +1,24 @@ 'use strict'; -var Z = require('sanctuary-type-classes'); - -var forall = require('./forall'); +var equals = require('../equals'); +var forall = require('../forall'); module.exports = forall({ // a `equals` a = true reflexivity: function(a) { - return Z.equals(a, a); + return equals(a)(a); }, // a `equals` b = b `equals` a symmetry: function(a, b) { - return Z.equals(a, b) === Z.equals(b, a); + return equals(a)(b) === equals(b)(a); }, // a `equals` b & b `equals` c => a `equals` c transitivity: function(a, b, c) { - return Z.equals(a, b) && Z.equals(b, c) ? Z.equals(a, c) : true; + return equals(a)(b) && equals(b)(c) ? equals(a)(c) : true; } }); diff --git a/test/internal/laws/Traversable.js b/test/internal/laws/Traversable.js index 96e29787..06e8f5d4 100644 --- a/test/internal/laws/Traversable.js +++ b/test/internal/laws/Traversable.js @@ -1,11 +1,11 @@ 'use strict'; var Compose = require('../Compose'); -var forall = require('./forall'); -var id = require('./id'); -var map = require('./map'); -var of = require('./of'); -var traverse = require('./traverse'); +var forall = require('../forall'); +var id = require('../id'); +var map = require('../map'); +var of = require('../of'); +var traverse = require('../traverse'); module.exports = function(equals) { @@ -15,14 +15,14 @@ module.exports = function(equals) { naturality: function(t, u, F, G) { var lhs = t(traverse(of(F))(id)(u)); var rhs = traverse(of(G))(t)(u); - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // traverse (of F) (of F) u = of F u identity: function(u, F) { var lhs = traverse(of(F))(of(F))(u); var rhs = of(F)(u); - return equals(lhs, rhs); + return equals(lhs)(rhs); }, // traverse (of C) C u = C (traverse (of G) id <$> traverse (of F) id u) @@ -30,7 +30,7 @@ module.exports = function(equals) { var C = Compose(F)(G); var lhs = traverse(of(C))(C)(u); var rhs = C(map(traverse(of(G))(id))(traverse(of(F))(id)(u))); - return equals(lhs, rhs); + return equals(lhs)(rhs); } }); diff --git a/test/internal/laws/map.js b/test/internal/map.js similarity index 100% rename from test/internal/laws/map.js rename to test/internal/map.js diff --git a/test/internal/laws/of.js b/test/internal/of.js similarity index 100% rename from test/internal/laws/of.js rename to test/internal/of.js diff --git a/test/internal/laws/reduce.js b/test/internal/reduce.js similarity index 100% rename from test/internal/laws/reduce.js rename to test/internal/reduce.js diff --git a/test/internal/toString.js b/test/internal/toString.js new file mode 100644 index 00000000..2071004a --- /dev/null +++ b/test/internal/toString.js @@ -0,0 +1,6 @@ +'use strict'; + +var Z = require('sanctuary-type-classes'); + +// toString :: a -> String +module.exports = Z.toString; diff --git a/test/internal/laws/traverse.js b/test/internal/traverse.js similarity index 100% rename from test/internal/laws/traverse.js rename to test/internal/traverse.js diff --git a/test/match.js b/test/match.js index 8415121d..79a1cc47 100644 --- a/test/match.js +++ b/test/match.js @@ -1,11 +1,11 @@ 'use strict'; var jsc = require('jsverify'); -var Z = require('sanctuary-type-classes'); var S = require('..'); var eq = require('./internal/eq'); +var equals = require('./internal/equals'); test('match', function() { @@ -35,7 +35,7 @@ test('match', function() { var p = '([A-Za-z]+)'; var lhs = S.head(S.matchAll(S.regex('g', p), s)); var rhs = S.match(S.regex('', p), s); - return Z.equals(lhs, rhs); + return equals(lhs)(rhs); }), {tests: 1000}); }); diff --git a/test/properties.js b/test/properties.js index 2b56868e..02ed30be 100644 --- a/test/properties.js +++ b/test/properties.js @@ -1,7 +1,8 @@ 'use strict'; var jsc = require('jsverify'); -var Z = require('sanctuary-type-classes'); + +var equals = require('./internal/equals'); var basic = jsc.sum([jsc.integer, jsc.string, jsc.bool, jsc.falsy]); @@ -10,12 +11,12 @@ var useful = jsc.sum([basic, jsc.array(basic), jsc.dict(basic), jsc.fn(basic)]); exports.idempotent = function(f) { return jsc.checkForall(useful, function(x) { - return Z.equals(f(f(x)), f(x)); + return equals(f(f(x)))(f(x)); }); }; exports.involution = function(f) { return jsc.checkForall(useful, function(x) { - return Z.equals(f(f(x)), x); + return equals(f(f(x)))(x); }); };