How to use the sanctuary-type-classes.Functor 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 ('Functor', () => {
    eq (Z.Functor.test (Left (Useless))) (true);
    eq (Z.Functor.test (Right (Useless))) (true);
  });
github sanctuary-js / sanctuary-maybe / test / index.js View on Github external
test ('Functor', () => {
    eq (Z.Functor.test (Nothing)) (true);
    eq (Z.Functor.test (Just (Useless))) (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
github sanctuary-js / sanctuary-identity / test / index.js View on Github external
test ('Functor', () => {
    eq (Z.Functor.test (Identity (Useless))) (true);
  });
github sanctuary-js / sanctuary-either / test / index.js View on Github external
test ('Functor', () => {
    eq (Z.Functor.test (Left (Useless))) (true);
    eq (Z.Functor.test (Right (Useless))) (true);
  });
github xodio / hm-def / test / signature.spec.js View on Github external
it ('should resolve constraints', () => {
    const a = $.TypeVariable ('a');
    const b = $.TypeVariable ('b');
    const f = $.UnaryTypeVariable ('f');
    const tcs = [Z.Functor];
    const {types} = resolve ($) (tcs) ($.env) ('foo :: Functor f => (a -> b) -> f a -> f b');
    assertTypePairs (S.zip (types) ([$.Function ([a, b]), f (a), f (b)]));
  });
});
github sanctuary-js / sanctuary-maybe / test / index.js View on Github external
test ('Functor', () => {
    eq (Z.Functor.test (Nothing)) (true);
    eq (Z.Functor.test (Just (Useless))) (true);
  });
github fluture-js / Fluture / src / dispatchers / map.js View on Github external
function map$mapper(mapper, m){
  if(!Z.Functor.test(m)) throwInvalidArgument('Future.map', 1, 'be a Functor', m);
  return Z.map(mapper, m);
}
github fantasyland / fantasy-laws / src / Functor.js View on Github external
composition: assert.forall3 (function(u, f, g) {
      return Z.Functor.test (u) &&
             equals (map (compose (f) (g)) (u),
                     compose (map (f)) (map (g)) (u));
    })
github fantasyland / fantasy-laws / src / Functor.js View on Github external
identity: assert.forall1 (function(u) {
      return Z.Functor.test (u) &&
             equals (map (identity) (u),
                     u);
    }),