Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test ('Semigroup', () => {
eq (Z.Semigroup.test (Left (Useless))) (false);
eq (Z.Semigroup.test (Left (0))) (false);
eq (Z.Semigroup.test (Left ([]))) (true);
eq (Z.Semigroup.test (Right (Useless))) (false);
eq (Z.Semigroup.test (Right (0))) (false);
eq (Z.Semigroup.test (Right ([]))) (true);
});
test ('Semigroup', () => {
eq (Z.Semigroup.test (Nothing)) (true);
eq (Z.Semigroup.test (Just (Useless))) (false);
eq (Z.Semigroup.test (Just (0))) (false);
eq (Z.Semigroup.test (Just ([]))) (true);
});
test ('Semigroup', () => {
eq (Z.Semigroup.test (Identity (Useless))) (false);
eq (Z.Semigroup.test (Identity (0))) (false);
eq (Z.Semigroup.test (Identity ([]))) (true);
});
const $Wrapper = $.UnaryType
('Wrapper')
('someurl')
(S.allPass ([S.is ($.Object), hasProp ('value')]))
(S.pipe ([S.prop ('value'), S.of (Array)]));
const def = create ({
$,
checkTypes: true,
env: $.env.concat ([
$Map ($.Unknown) ($.Unknown),
$Wrapper ($.Unknown),
]),
typeClasses: [
Z.Functor,
Z.Semigroup,
],
});
describe ('def', () => {
it ('should work with unary functions', () => {
const foo = def
('foo :: Number -> String')
(x => x.toString ());
assert.strictEqual (foo (42), '42');
assert.throws (() => foo (null), 'The value at position 1 is not a member of ‘Number’');
});
it ('should work with thunks', () => {
const foo = def
('foo :: () -> Number')
test ('Semigroup', () => {
eq (Z.Semigroup.test (Nothing)) (true);
eq (Z.Semigroup.test (Just (Useless))) (false);
eq (Z.Semigroup.test (Just (0))) (false);
eq (Z.Semigroup.test (Just ([]))) (true);
});
test ('Semigroup', () => {
eq (Z.Semigroup.test (Left (Useless))) (false);
eq (Z.Semigroup.test (Left (0))) (false);
eq (Z.Semigroup.test (Left ([]))) (true);
eq (Z.Semigroup.test (Right (Useless))) (false);
eq (Z.Semigroup.test (Right (0))) (false);
eq (Z.Semigroup.test (Right ([]))) (true);
});
test ('Semigroup', () => {
eq (Z.Semigroup.test (Identity (Useless))) (false);
eq (Z.Semigroup.test (Identity (0))) (false);
eq (Z.Semigroup.test (Identity ([]))) (true);
});
return this.merge(a, (left:any, right) => {
return (Z.Semigroup.test(left)) ? Z.concat(left, right) : left;
});
}
associativity: assert.forall3 (function(x, y, z) {
return Z.Semigroup.test (x) &&
Z.Semigroup.test (y) &&
Z.Semigroup.test (z) &&
equals (concat (concat (x) (y)) (z),
concat (x) (concat (y) (z)));
})
associativity: assert.forall3 (function(x, y, z) {
return Z.Semigroup.test (x) &&
Z.Semigroup.test (y) &&
Z.Semigroup.test (z) &&
equals (concat (concat (x) (y)) (z),
concat (x) (concat (y) (z)));
})