How to use the sanctuary-def.NullaryType 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 / internal / Sum.js View on Github external
const $ = require ('sanctuary-def');
const show = require ('sanctuary-show');
const Z = require ('sanctuary-type-classes');
const type = require ('sanctuary-type-identifiers');


//    Sum :: Number -> Sum
function Sum(value) {
  if (!(this instanceof Sum)) return new Sum (value);
  this.value = value;
}

Sum['@@type'] = 'sanctuary/Sum';

//    Type :: Type
Sum.Type = $.NullaryType
  (Sum['@@type'])
  ('')
  ([])
  (x => type (x) === Sum['@@type']);

Sum[FL.empty] = () => Sum (0);

Sum.prototype[FL.equals] = function(other) {
  return Z.equals (this.value, other.value);
};

Sum.prototype[FL.concat] = function(other) {
  return Sum (this.value + other.value);
};

Sum.prototype[FL.invert] = function() {
github pipeos-one / pipeline-meteor / imports / client / templates / main / main.js View on Github external
loop: false,
        slidesPerView: "auto",
        noSwiping: true,
        noSwipingClass: "no-swipe",

        // Navigation arrows
        navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
        }
    })

    console.log(SANCT);

    //    Integer :: Type
    const Integer = SANCT.NullaryType
      ('my-package/Integer')
      ('http://example.com/my-package#Integer')
      (x => typeof x === 'number' &&
            Math.floor (x) === x &&
            x >= Number.MIN_SAFE_INTEGER &&
            x <= Number.MAX_SAFE_INTEGER);

    window.def = HMD.create({
      checkTypes: true,
      env: SANCT.env.concat([Integer]),
    });

    // const sum = def(
    //   'sum :: Integer -> Integer -> Integer -> Integer',
    //   (a, b, c) => a + b + c
    // );
github plaid / async-problem / common / sanctuary.js View on Github external
'use strict';

const FutureTypes   = require ('fluture-sanctuary-types');
const S             = require ('sanctuary');
const $             = require ('sanctuary-def');


//    PromiseType :: Type
const PromiseType = $.NullaryType
  ('Promise')
  ('')
  ([])
  (x => x != null && x.constructor === Promise);

module.exports = S.create ({
  checkTypes: true,
  env: S.env.concat (FutureTypes.env.concat ([PromiseType])),
});
github xodio / hm-def / test / signature.spec.js View on Github external
it ('should resolve user types', () => {
    const Widget = $.NullaryType ('Widget') ('http://example.com/Widget') (S.K (true));
    const env = $.env.concat ([Widget]);
    const {types} = resolve ($) ([]) (env) ('foo :: Widget -> String');
    assert.deepEqual (types, [Widget, $.String]);
  });
github xodio / hm-def / test / signature.spec.js View on Github external
it ('should resolve namespaced user types', () => {
    const Widget = $.NullaryType ('x/y/z/Widget') ('http://example.com/Widget') (S.K (true));
    const env = $.env.concat ([Widget]);
    const {types} = resolve ($) ([]) (env) ('foo :: Widget -> String');
    assert.deepEqual (types, [Widget, $.String]);
  });
github Huemul / chimi / src / sanctuary.js View on Github external
const propIsString = prop => R.compose(isString, R.prop(prop))
const optionalPropIsString = prop =>
  R.ifElse(R.has(prop), propIsString(prop), R.T)

const checkProps = R.allPass([
  propIsString('module'),
  optionalPropIsString('name'),
  optionalPropIsString('type'),
])

const isDepObject = R.both(isObject, checkProps)

const isDep = R.either(isString, isDepObject)

const chimiDependency = NullaryType('chimi/Dependency', '#', isDep)

const S = create({
  checkTypes: true,
  env: env.concat([chimiDependency]),
})

module.exports = S