Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
List.prototype.constructor = List;
function _List(tag, head, tail) {
this.isCons = tag === 'Cons';
this.isNil = tag === 'Nil';
if (this.isCons) {
this.head = head;
this.tail = tail;
}
}
List['@@type'] = 'sanctuary/List';
// Type :: Type -> Type
List.Type = $.UnaryType
(List['@@type'])
('')
([])
(x => type (x) === List['@@type'])
(list => list);
// Nil :: List a
const Nil = List.Nil = new _List ('Nil');
// Cons :: a -> List a -> List a
const Cons = List.Cons = function Cons(head) {
eq (arguments.length) (Cons.length);
return function Cons$1(tail) {
eq (arguments.length) (Cons$1.length);
return new _List ('Cons', head, tail);
};
const UnaryType = name => typeIdent =>
$.UnaryType (typeIdent)
('')
([])
(x => type (x) === typeIdent)
(v => [v.value])
($.Unknown);
it ('should resolve maybes', () => {
const Maybe = $.UnaryType
('my-package/Maybe')
('http://example.com/my-package#Maybe')
(S.K (true))
(S.K ([]));
const env = $.env.concat ([
Maybe ($.Unknown),
]);
const {types} = resolve ($) ([]) (env) ('foo :: Maybe String -> String');
assertTypePairs (S.zip (types) ([Maybe ($.String), $.String]));
});
import {unchecked as S} from 'sanctuary';
import $ from 'sanctuary-def';
import Z from 'sanctuary-type-classes';
import {assert} from 'chai';
import {create} from '../src/index';
const hasProp = p => x => x[p] !== undefined;
const $Map = $.BinaryType
('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,
],
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 }, $)
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 }, $)