Toward its goal, this commit also: * Adds a new section of logical functions, and defines `not`, `and`, `or` for all current types. * Extends `OneOf` choice/union type to allow argument types that are themselves `OneOf` types. * Adds a readable .toString() method for TypePatterns. * Defines negate (as a no-op) and isnan (as always true) for the Undefined type * Extends comparisons to the Undefined type (to handle comparing vectors of different lengths)
9 lines
360 B
JavaScript
9 lines
360 B
JavaScript
import {BooleanT} from './BooleanT.js'
|
|
import {Returns} from '#core/Type.js'
|
|
import {match} from '#core/TypePatterns.js'
|
|
|
|
export const not = match(BooleanT, Returns(BooleanT, p => !p))
|
|
export const and = match(
|
|
[BooleanT, BooleanT], Returns(BooleanT, (p, q) => p && q))
|
|
export const or = match(
|
|
[BooleanT, BooleanT], Returns(BooleanT, (p, q) => p || q))
|