feat(PocomathInstance): Add use(deps, imp) function for defining signatures

This commit is contained in:
Glen Whitney 2022-07-22 19:49:10 -07:00
parent 4fdafc751e
commit 2ef0b5b263
3 changed files with 8 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import {use} from '../core/PocomathInstance.mjs'
export {Types} from './Types/bigint.mjs'
export const add = {
'...bigint': [[], addends => addends.reduce((x,y) => x+y, 0n)],
'...bigint': use([], addends => addends.reduce((x,y) => x+y, 0n))
}

View File

@ -1,3 +1,4 @@
import {use} from '../core/PocomathInstance.mjs'
export {Types} from './Types/bigint.mjs'
export const negate = {bigint: [[], b => -b ]}
export const negate = {bigint: use([], b => -b)}

View File

@ -1,6 +1,10 @@
/* Core of pocomath: create an instance */
import typed from 'typed-function'
export function use(dependencies, implementation) {
return [dependencies, implementation]
}
export default class PocomathInstance {
/* Disallowed names for ops; beware, this is slightly non-DRY
* in that if a new top-level PocomathInstance method is added, its name