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