Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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);
};
};
List[FL.empty] = () => Nil;
List[FL.of] = x => Cons (x) (Nil);
List[FL.zero] = List[FL.empty];
List.prototype[FL.equals] = function(other) {
return this.isNil ?
other.isNil :
other.isCons &&
Z.equals (other.head, this.head) &&
Z.equals (other.tail, this.tail);
};
List.prototype[FL.concat] = function(other) {
return this.isNil ?
other :
Cons (this.head) (Z.concat (this.tail, other));
};
List.prototype[FL.filter] = function(pred) {
return this.isNil ?
Nil :
var show = require ('sanctuary-show');
var Z = require ('..');
// Sum :: Number -> Sum
function Sum(value) {
if (!(this instanceof Sum)) return new Sum (value);
this.value = value;
}
Sum[FL.empty] = function() { return Sum (0); };
Sum.prototype['@@type'] = 'sanctuary-type-classes/Sum@1';
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() {
return Sum (-this.value);
};
Sum.prototype.inspect =
Sum.prototype['@@show'] = function() {
return 'Sum (' + show (this.value) + ')';
};
return function ComposeF(G) {
function ComposeFG(value) {
if (!(this instanceof ComposeFG)) return new ComposeFG (value);
this.value = value;
}
ComposeFG['@@type'] = 'sanctuary/Compose';
ComposeFG[FL.of] = function(x) {
return ComposeFG (of (F) (of (G) (x)));
};
ComposeFG.prototype[FL.equals] = function(other) {
return equals (this.value) (other.value);
};
ComposeFG.prototype[FL.map] = function(f) {
return ComposeFG (map (map (f)) (this.value));
};
ComposeFG.prototype[FL.ap] = function(other) {
return ComposeFG (ap (map (ap) (other.value)) (this.value));
};
// name :: TypeRep a -> String
function name(typeRep) {
return typeof typeRep['@@type'] === 'string' ?
typeRep['@@type'].replace (/^[^/]*[/]/, '') :
typeRep.name;
var show = require ('sanctuary-show');
var Z = require ('..');
// Identity :: a -> Identity a
function Identity(value) {
if (!(this instanceof Identity)) return new Identity (value);
this.value = value;
}
Identity['@@type'] = 'sanctuary-type-classes/Identity';
Identity[FL.of] = Identity;
Identity.prototype[FL.equals] = function(other) {
return Z.equals (this.value, other.value);
};
Identity.prototype[FL.lte] = function(other) {
return Z.lte (this.value, other.value);
};
Identity.prototype[FL.concat] = function(other) {
return Identity (Z.concat (this.value, other.value));
};
Identity.prototype[FL.map] = function(f) {
return Identity (f (this.value));
};
Identity.prototype[FL.ap] = function(other) {
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() {
return Sum (-this.value);
};
Sum.prototype.inspect =
Sum.prototype['@@show'] = function() {
return 'Sum (' + show (this.value) + ')';
};
module.exports = curry2 (function(F, G) {
function Compose(value) {
if (!(this instanceof Compose)) return new Compose (value);
this.value = value;
}
Compose['@@type'] = 'fantasy-laws/Compose';
Compose[FL.of] = function(x) {
return Compose (of (F) (of (G) (x)));
};
Compose.prototype[FL.equals] = function(other) {
return Z.equals (this.value, other.value);
};
Compose.prototype[FL.map] = function(f) {
return Compose (map (map (f)) (this.value));
};
Compose.prototype[FL.ap] = function(other) {
return Compose (ap (map (ap) (other.value)) (this.value));
};
// name :: TypeRep a -> String
function name(typeRep) {
return typeof typeRep['@@type'] === 'string' ?
typeRep['@@type'].replace (/^[^/]*[/]/, '') :
typeRep.name;
import FL from 'fantasy-land';
import Tuple from './Tuple';
// Tuple Applicative
Tuple[FL.equals] = Tuple.equals;
Tuple.prototype[FL.equals] = Tuple.prototype.equals;
// Tuple Functor
Tuple[FL.map] = Tuple.map;
Tuple.prototype[FL.map] = Tuple.prototype.map;
export default Tuple;
it('should return true if a and b are equal (reflexivity) (1)', function(done) {
LazyEither.Right('good')[FL.equals](LazyEither.Right('good'), res => {
expect(res).to.be.true
done()
})
})
function _Maybe(tag, value) {
this.isNothing = tag === 'Nothing';
this.isJust = tag === 'Just';
if (this.isJust) this.value = value;
if (this.isNothing || Z.Setoid.test (this.value)) {
this[FL.equals] = Maybe$prototype$equals;
}
if (this.isNothing || Z.Ord.test (this.value)) {
this[FL.lte] = Maybe$prototype$lte;
}
if (this.isNothing || Z.Semigroup.test (this.value)) {
this[FL.concat] = Maybe$prototype$concat;
}
}
this.value = value;
}
get() {
return this.value;
}
[fl.ap](...args) {
return applyTrait[fl.ap].call(this, ...args);
}
[fl.map](...args) {
return functorTrait[fl.map].call(this, ...args);
}
[fl.equals](...args) {
return setoidTrait[fl.equals].call(this, ...args);
}
[fl.concat](...args) {
return semigroupTrait[fl.concat].call(this, ...args);
}
}
aliases(Identity).forEach(([alias, fn]) => {
Identity[alias] = fn;
});
aliases(Identity.prototype).forEach(([alias, fn]) => {
Identity.prototype[alias] = fn;
});
export default Identity;