fp-ts-std
Version:
The missing pseudo-standard library for fp-ts.
27 lines (26 loc) • 917 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Enum = exports.Bounded = exports.xor = exports.or = exports.and = exports.invert = void 0;
const O = require("fp-ts/Option");
const boolean_1 = require("fp-ts/boolean");
const Function_1 = require("./Function");
const L = require("./Lazy");
const invert = x => !x;
exports.invert = invert;
exports.and = (0, Function_1.curry2)(boolean_1.SemigroupAll.concat);
exports.or = (0, Function_1.curry2)(boolean_1.SemigroupAny.concat);
const xor = (x) => y => (x && !y) || (!x && y);
exports.xor = xor;
exports.Bounded = {
...boolean_1.Ord,
top: true,
bottom: false,
};
exports.Enum = {
...exports.Bounded,
succ: x => (x ? O.none : O.some(true)),
pred: x => (x ? O.some(false) : O.none),
toEnum: n => (n === 1 ? O.some(true) : n === 0 ? O.some(false) : O.none),
fromEnum: Number,
cardinality: L.of(2),
};
;