import {ReturnsAs} from './helpers.js' import {ResolutionError} from '#core/helpers.js' import {Passthru, match} from '#core/TypePatterns.js' import {boolnum} from '#number/helpers.js' // Most types are real. Have to make sure to redefine on all non-real types export const isReal = match(Passthru, boolnum(() => true)) export const isZero = match(Passthru, (math, [T]) => { if (!T) { // called with no arguments throw new ResolutionError('isZero() requires one argument') } const z = math.zero(T) const eq = math.equal.resolve([T, T]) return ReturnsAs(eq, x => eq(z, x)) })