fp-ts-std
Version:
The missing pseudo-standard library for fp-ts.
22 lines (21 loc) • 677 B
JavaScript
import * as O from "fp-ts/Option";
import { Ord, SemigroupAll, SemigroupAny } from "fp-ts/boolean";
import { curry2 } from "./Function";
import * as L from "./Lazy";
export const invert = x => !x;
export const and = curry2(SemigroupAll.concat);
export const or = curry2(SemigroupAny.concat);
export const xor = (x) => y => (x && !y) || (!x && y);
export const Bounded = {
...Ord,
top: true,
bottom: false,
};
export const Enum = {
...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),
};