Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix id_test and argument order in laws #193

Merged
merged 3 commits into from
Oct 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions id_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const fl = require('./');
const applicative = require('./laws/applicative');
const apply = require('./laws/apply');
const chain = require('./laws/chain');
Expand Down Expand Up @@ -35,7 +36,7 @@ Sum.prototype[equals] = function(x) {

const equality = (x, y) => x[equals] ? x[equals](y) : x === y;
const test = f => t => {
t.ok(f('x'));
t.ok(f('x') === true);
t.done();
};

Expand Down Expand Up @@ -79,11 +80,11 @@ exports.foldable = {

exports.functor = {
identity: test(functor.identity(Id[of])(equality)),
composition: test(functor.composition(Id[of])(equality)),
composition: test(functor.composition(Id[of])(equality)(a => [a, a])(a => [a])),
};

exports.monad = {
leftIdentity: test(monad.leftIdentity(Id)(equality)),
leftIdentity: test(monad.leftIdentity(Id)(equality)(Id[fl.of])),
rightIdentity: test(monad.rightIdentity(Id)(equality)),
};

Expand Down
2 changes: 1 addition & 1 deletion laws/functor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const identity = of => eq => x => {
return eq(a, b);
};

const composition = of => eq => x => f => g => {
const composition = of => eq => f => g => x => {
const a = of(x)[map](x => f(g(x)));
const b = of(x)[map](g)[map](f);
return eq(a, b);
Expand Down
2 changes: 1 addition & 1 deletion laws/monad.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {of, chain} = require('..');

**/

const leftIdentity = t => eq => x => f => {
const leftIdentity = t => eq => f => x => {
const a = t[of](x)[chain](f);
const b = f(x);
return eq(a, b);
Expand Down