import { BasicFun, Fun } from "../../state"; export type BasicPredicate = BasicFun; export type Predicate = Fun & { not: () => Predicate; and: (other: Predicate) => Predicate; or: (other: Predicate) => Predicate; }; export const Predicate = Object.assign( (actual: BasicPredicate): Predicate => Object.assign(Fun(actual), { not: function (this: Predicate): Predicate { return Predicate((_) => !this(_)); }, and: function (this: Predicate, other: Predicate): Predicate { return Predicate((_) => this(_) && other(_)); }, or: function (this: Predicate, other: Predicate): Predicate { return Predicate((_) => this(_) || other(_)); }, }), { True: () => Predicate((_) => true), False: () => Predicate((_) => false), }, );