How to use the sanctuary-type-classes.Semigroup function in sanctuary-type-classes

To help you get started, we’ve selected a few sanctuary-type-classes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sanctuary-js / sanctuary-either / test / index.js View on Github external
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);
  });
github sanctuary-js / sanctuary-maybe / test / index.js View on Github external
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);
  });
github sanctuary-js / sanctuary-identity / test / index.js View on Github external
test ('Semigroup', () => {
    eq (Z.Semigroup.test (Identity (Useless))) (false);
    eq (Z.Semigroup.test (Identity (0))) (false);
    eq (Z.Semigroup.test (Identity ([]))) (true);
  });
github xodio / hm-def / test / def.spec.js View on Github external
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')
github sanctuary-js / sanctuary-maybe / test / index.js View on Github external
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);
  });
github sanctuary-js / sanctuary-either / test / index.js View on Github external
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);
  });
github sanctuary-js / sanctuary-identity / test / index.js View on Github external
test ('Semigroup', () => {
    eq (Z.Semigroup.test (Identity (Useless))) (false);
    eq (Z.Semigroup.test (Identity (0))) (false);
    eq (Z.Semigroup.test (Identity ([]))) (true);
  });
github SodiumFRP / sodium-typescript / src / lib / sodium / Stream.ts View on Github external
return this.merge(a, (left:any, right) => {
        return (Z.Semigroup.test(left)) ? Z.concat(left, right) : left;
      });
    }
github fantasyland / fantasy-laws / src / Semigroup.js View on Github external
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)));
    })
github fantasyland / fantasy-laws / src / Semigroup.js View on Github external
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)));
    })