14 lines
436 B
JavaScript
14 lines
436 B
JavaScript
|
import {ReturnsAs} from './helpers.js'
|
||
|
import {onType, ResolutionError} from '#core/helpers.js'
|
||
|
import {Returns} from '#core/Type.js'
|
||
|
import {Any} from "#core/TypePatterns.js"
|
||
|
|
||
|
export const isZero = (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))
|
||
|
}
|