Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
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
// );
// eval("const sum = def('sum :: Integer -> Integer -> Integer -> Integer',(a, b, c) => a + b + c);")
$("head").append("");
//sum(x, y, z)
console.log('----', sum(5)(8)(14))
});
import Sanctuary from 'sanctuary';
import $ from 'sanctuary-def';
import Z from 'sanctuary-type-classes';
import Future from 'fluture';
import FutureTypes from 'fluture-sanctuary-types';
const S = Sanctuary.create ({
checkTypes: process.env.NODE_ENV !== 'production',
env: Sanctuary.env.concat (FutureTypes.env)
});
const def = $.create ({
checkTypes: process.env.NODE_ENV !== 'production',
env: $.env.concat (FutureTypes.env)
});
$.a = $.TypeVariable ('a');
$.b = $.TypeVariable ('b');
$.Either = S.EitherType;
$.Maybe = S.MaybeType;
$.Future = FutureTypes.FutureType;
// Extensions
S.chainRej = S.curry2 ((fn, future) => future.chainRej (fn));
S.replace = S.curry3((key, replacement, str) => str.replace (key, replacement));
S.lift4 = S.curry4 ((fn, a1, a2, a3, a4) => Z.ap (Z.ap (Z.ap (Z.map (fn, a1), a2), a3), a4));
S.eitherToFuture = S.either (Future.reject) (Future.of);
S.invoke = fnName => arg => obj => obj[fnName] (arg);
export {
('Map')
('someurl')
(S.is ($.Object))
(S.keys)
(S.values);
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');
it ('should be extracted', () => {
const {name} = resolve ($) ([]) ($.env) ('foo :: Number -> Number');
assert.strictEqual (name, 'foo');
});
});
it ('should resolve multiple contraints on same variable', () => {
const tcs = [Z.Monoid, Z.Setoid];
const {constraints} = resolve ($) (tcs) ($.env) ('foo :: (Monoid a, Setoid a) => a -> b');
assert.deepEqual (constraints, {a: [Z.Monoid, Z.Setoid]});
});
});
const $ = require('sanctuary-def')
const a = $.TypeVariable('a')
const b = $.TypeVariable('b')
const $IO = $.UnaryType(
'future-io/IO',
(x) => x && x['@@type'] === 'future-io/IO',
() => []
)
const $Task = $.UnaryType(
'Task',
(x) => x && typeof x.fork === 'function',
() => []
)
const env = $.env.concat([
$IO,
$Task
])
const def = $.create({ checkTypes: true, env })
module.exports = Object.assign({ def, a, b, $IO, $Task }, $)