Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const m = require('fantasy-land/laws/monoid');
const s = require('fantasy-land/laws/semigroup');
const sʹ = require('fantasy-land/laws/setoid');
const {Multiplicative} = require('../fantasy-monoids');
exports.monoid = {
'rightIdentity': λ.law(m.rightIdentity)(Multiplicative),
'leftIdentity': λ.law(m.leftIdentity)(Multiplicative)
};
exports.semigroup = {
'associativity': λ.law(s.associativity)(Multiplicative)
};
exports.setoid = {
'reflexivity': λ.law(sʹ.reflexivity)(Multiplicative),
'symmetry': λ.law(sʹ.symmetry)(Multiplicative),
'transitivity': λ.law(sʹ.transitivity)(Multiplicative)
};
const Ordʹ = Ord({ min: () => Ordʹ(Number.MIN_NUMBER)
, max: () => Ordʹ(Number.MAX_NUMBER)
, compare: (x, y) => x === y ? Ord.EQ : x < y ? Ord.LT : Ord.GT
});
const Maxʹ = Max(Ordʹ);
exports.monoid = {
'rightIdentity': λ.law(m.rightIdentity)(Maxʹ),
'leftIdentity': λ.law(m.leftIdentity)(Maxʹ)
};
exports.semigroup = {
'associativity': λ.law(s.associativity)(Maxʹ[of])
};
exports.setoid = {
'reflexivity': λ.law(sʹ.reflexivity)(Maxʹ[of]),
'symmetry': λ.law(sʹ.symmetry)(Maxʹ[of]),
'transitivity': λ.law(sʹ.transitivity)(Maxʹ[of])
};
exports.basicUsage = test => {
const expected = { x: { x: 9 } };
test.deepEqual(
Maxʹ(Ordʹ(3))
[concat](Maxʹ(Ordʹ(6)))
const Ordʹ = Ord({ min: () => Ordʹ(Number.MIN_NUMBER)
, max: () => Ordʹ(Number.MAX_NUMBER)
, compare: (x, y) => x === y ? Ord.EQ : x < y ? Ord.LT : Ord.GT
});
const Minʹ = Min(Ordʹ);
exports.monoid = {
'rightIdentity': λ.law(m.rightIdentity)(Minʹ),
'leftIdentity': λ.law(m.leftIdentity)(Minʹ)
};
exports.semigroup = {
'associativity': λ.law(s.associativity)(Minʹ[of])
};
exports.setoid = {
'reflexivity': λ.law(sʹ.reflexivity)(Minʹ[of]),
'symmetry': λ.law(sʹ.symmetry)(Minʹ[of]),
'transitivity': λ.law(sʹ.transitivity)(Minʹ[of])
};
exports.basicUsage = test => {
const expected = { x: { x: 1 } };
test.deepEqual(
Minʹ(Ordʹ(3))
[concat](Minʹ(Ordʹ(6)))
const m = require('fantasy-land/laws/monoid');
const s = require('fantasy-land/laws/semigroup');
const sʹ = require('fantasy-land/laws/setoid');
const {Conjunction} = require('../fantasy-monoids');
exports.monoid = {
'rightIdentity': λ.law(m.rightIdentity)(Conjunction),
'leftIdentity': λ.law(m.leftIdentity)(Conjunction)
};
exports.semigroup = {
'associativity': λ.law(s.associativity)(Conjunction)
};
exports.setoid = {
'reflexivity': λ.law(sʹ.reflexivity)(Conjunction),
'symmetry': λ.law(sʹ.symmetry)(Conjunction),
'transitivity': λ.law(sʹ.transitivity)(Conjunction)
};
const sʹ = require('fantasy-land/laws/setoid');
const {Additive, Dual} = require('../fantasy-monoids');
const Dualʹ = Dual(Additive);
exports.monoid = {
'rightIdentity': λ.law(m.rightIdentity)(Dualʹ),
'leftIdentity': λ.law(m.leftIdentity)(Dualʹ)
};
exports.semigroup = {
'associativity': λ.law(s.associativity)(Dualʹ[of])
};
exports.setoid = {
'reflexivity': λ.law(sʹ.reflexivity)(Dualʹ[of]),
'symmetry': λ.law(sʹ.symmetry)(Dualʹ[of]),
'transitivity': λ.law(sʹ.transitivity)(Dualʹ[of])
};
const m = require('fantasy-land/laws/monoid');
const s = require('fantasy-land/laws/semigroup');
const sʹ = require('fantasy-land/laws/setoid');
const {Disjunction} = require('../fantasy-monoids');
exports.monoid = {
'rightIdentity': λ.law(m.rightIdentity)(Disjunction),
'leftIdentity': λ.law(m.leftIdentity)(Disjunction)
};
exports.semigroup = {
'associativity': λ.law(s.associativity)(Disjunction)
};
exports.setoid = {
'reflexivity': λ.law(sʹ.reflexivity)(Disjunction),
'symmetry': λ.law(sʹ.symmetry)(Disjunction),
'transitivity': λ.law(sʹ.transitivity)(Disjunction)
};
const m = require('fantasy-land/laws/monoid');
const s = require('fantasy-land/laws/semigroup');
const sʹ = require('fantasy-land/laws/setoid');
const {Additive} = require('../fantasy-monoids');
exports.monoid = {
'rightIdentity': λ.law(m.rightIdentity)(Additive),
'leftIdentity': λ.law(m.leftIdentity)(Additive)
};
exports.semigroup = {
'associativity': λ.law(s.associativity)(Additive)
};
exports.setoid = {
'reflexivity': λ.law(sʹ.reflexivity)(Additive),
'symmetry': λ.law(sʹ.symmetry)(Additive),
'transitivity': λ.law(sʹ.transitivity)(Additive)
};