Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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() {
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
// );
'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])),
});
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]);
});
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]);
});
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