How to use the sanctuary-def.Boolean function in sanctuary-def

To help you get started, we’ve selected a few sanctuary-def 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 / test / is.js View on Github external
test ('is', () => {

  eq (S.show (S.is)) ('is :: Type -> Any -> Boolean');

  eq (S.is ($.Boolean) (true)) (true);
  eq (S.is ($.Boolean) (false)) (true);
  eq (S.is ($.Boolean) (new Boolean (true))) (false);
  eq (S.is ($.Boolean) (new Boolean (false))) (false);

  eq (S.is ($.Array ($.Integer)) (null)) (false);
  eq (S.is ($.Array ($.Integer)) (undefined)) (false);
  eq (S.is ($.Array ($.Integer)) (['1', '2', '3'])) (false);
  eq (S.is ($.Array ($.Integer)) ([1, 2, 3.14])) (false);
  eq (S.is ($.Array ($.Integer)) ([1, 2, 3])) (true);
  eq (S.is ($.Array ($.Integer)) ([])) (true);

  eq (S.is ($.Maybe ($.Integer)) (S.Nothing)) (true);
  eq (S.is ($.Maybe ($.Integer)) (S.Just (0))) (true);
  eq (S.is ($.Maybe ($.Integer)) (S.Left (0))) (false);
  eq (S.is ($.Maybe ($.Integer)) (S.Right (0))) (false);
github sanctuary-js / sanctuary / test / is.js View on Github external
test ('is', () => {

  eq (S.show (S.is)) ('is :: Type -> Any -> Boolean');

  eq (S.is ($.Boolean) (true)) (true);
  eq (S.is ($.Boolean) (false)) (true);
  eq (S.is ($.Boolean) (new Boolean (true))) (false);
  eq (S.is ($.Boolean) (new Boolean (false))) (false);

  eq (S.is ($.Array ($.Integer)) (null)) (false);
  eq (S.is ($.Array ($.Integer)) (undefined)) (false);
  eq (S.is ($.Array ($.Integer)) (['1', '2', '3'])) (false);
  eq (S.is ($.Array ($.Integer)) ([1, 2, 3.14])) (false);
  eq (S.is ($.Array ($.Integer)) ([1, 2, 3])) (true);
  eq (S.is ($.Array ($.Integer)) ([])) (true);

  eq (S.is ($.Maybe ($.Integer)) (S.Nothing)) (true);
  eq (S.is ($.Maybe ($.Integer)) (S.Just (0))) (true);
  eq (S.is ($.Maybe ($.Integer)) (S.Left (0))) (false);
  eq (S.is ($.Maybe ($.Integer)) (S.Right (0))) (false);

  eq (S.is ($.Either ($.String) ($.Integer)) (S.Nothing)) (false);
github xodio / hm-def / src / index.js View on Github external
import $priv from 'sanctuary-def';
import * as Sig from './signature';

const def = $priv.create ({checkTypes: true, env: $priv.env});

const Parameters = $priv.RecordType ({
  $: $priv.Object,
  checkTypes: $priv.Boolean,
  env: $priv.Array ($priv.Type),
  typeClasses: $priv.Array ($priv.TypeClass),
});

export const create = def
  ('create')
  ({})
  ([
    Parameters,
    $priv.String,
    $priv.AnyFunction,
    $priv.AnyFunction,
  ])
  (({$, checkTypes, env, typeClasses}) => {
    const $def = $.create ({checkTypes, env});
    const resovleSig = Sig.resolve ($) (typeClasses) (env);