refactor: require match to merge any function (#23)
All checks were successful
/ test (push) Successful in 16s
All checks were successful
/ test (push) Successful in 16s
Resolves #12. Reviewed-on: #23 Co-authored-by: Glen Whitney <glen@studioinfinity.org> Co-committed-by: Glen Whitney <glen@studioinfinity.org>
This commit is contained in:
parent
236f46c0c0
commit
0ff00ff8cb
4 changed files with 14 additions and 8 deletions
|
@ -1,13 +1,13 @@
|
|||
import {ReturnsAs} from './helpers.js'
|
||||
import {ResolutionError} from '#core/helpers.js'
|
||||
import {ResolutionError, match} from '#core/helpers.js'
|
||||
import {Returns} from '#core/Type.js'
|
||||
import {Any} from "#core/TypePatterns.js"
|
||||
import {Passthru} from "#core/TypePatterns.js"
|
||||
|
||||
export const isZero = (math, [T]) => {
|
||||
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))
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue