From 49b133291777d5cd9023852cf8ad25b4c19ec7c4 Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Mon, 9 Oct 2023 21:10:15 -0700 Subject: [PATCH] feat: Add reflecTypes that allows multiple reflections at once --- package.json5 | 4 ++-- pnpm-lock.yaml | 22 ++++++++++++++-------- src/interfaces/type.ts | 5 +++++ src/numbers/arithmetic.ts | 11 ++++++----- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/package.json5 b/package.json5 index b00af7c..5e1b58b 100644 --- a/package.json5 +++ b/package.json5 @@ -23,12 +23,12 @@ url: 'https://code.studioinfinity.org/glen/typocomath.git', }, devDependencies: { - '@types/node': '20.8.0', + '@types/node': '20.8.4', 'cpy-cli': '5.0.0', 'del-cli': '5.1.0', mkdirp: '3.0.1', 'source-map': '0.7.4', - 'ts-macros': '2.5.0', + 'ts-macros': '2.6.0', 'ts-patch': '3.0.2', typescript: '5.1.6', }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b3f667b..6791304 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: devDependencies: '@types/node': - specifier: 20.8.0 - version: 20.8.0 + specifier: 20.8.4 + version: 20.8.4 cpy-cli: specifier: 5.0.0 version: 5.0.0 @@ -21,8 +21,8 @@ devDependencies: specifier: 0.7.4 version: 0.7.4 ts-macros: - specifier: 2.5.0 - version: 2.5.0(typescript@5.1.6) + specifier: 2.6.0 + version: 2.6.0(typescript@5.1.6) ts-patch: specifier: 3.0.2 version: 3.0.2 @@ -79,8 +79,10 @@ packages: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true - /@types/node@20.8.0: - resolution: {integrity: sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ==} + /@types/node@20.8.4: + resolution: {integrity: sha512-ZVPnqU58giiCjSxjVUESDtdPk4QR5WQhhINbc9UBrKLU68MX5BF6kbQzTrkwbolyr0X8ChBpXfavr5mZFKZQ5A==} + dependencies: + undici-types: 5.25.3 dev: true /@types/normalize-package-data@2.4.1: @@ -843,8 +845,8 @@ packages: engines: {node: '>=12'} dev: true - /ts-macros@2.5.0(typescript@5.1.6): - resolution: {integrity: sha512-Uha8rei70+YtQS7nJ1F9m4BVUUV78vky3hIeH6JaHo2cqrKFpA9VWKzkzt4CAQU7g1pheNKr0iOkBmCzrKy2jw==} + /ts-macros@2.6.0(typescript@5.1.6): + resolution: {integrity: sha512-X7c4rHPTpBYY+MJUkIDIQMbTPAcv1y1sylrnDMsTvcbImleT4Wlheg3wNbORwnX8Zvq2ldZnttNXcZ1a0VE2Kg==} hasBin: true peerDependencies: typescript: 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x @@ -876,6 +878,10 @@ packages: hasBin: true dev: true + /undici-types@5.25.3: + resolution: {integrity: sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==} + dev: true + /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} dependencies: diff --git a/src/interfaces/type.ts b/src/interfaces/type.ts index 7e697cc..e56d385 100644 --- a/src/interfaces/type.ts +++ b/src/interfaces/type.ts @@ -91,3 +91,8 @@ export function $reflect(name: string, expr: Impl) : Impl & { reflectedTyp export function $reflecType(expr: Impl) { expr.reflectedType = $$typeToString!(true, false, true); } + +export function $reflecTypes(tup: ImplTuple) { + +[[tup], (elt: T) => + elt.reflectedType = $$typeToString!(true, false, true)] +} diff --git a/src/numbers/arithmetic.ts b/src/numbers/arithmetic.ts index ef92bfe..ba75bfe 100644 --- a/src/numbers/arithmetic.ts +++ b/src/numbers/arithmetic.ts @@ -1,11 +1,11 @@ import type {configDependency} from '../core/Config.js' import type {Dependencies, Signature} from '../interfaces/type.js' -import { $reflecType } from '../interfaces/type.js' +import { $reflecType, $reflecTypes } from '../interfaces/type.js' -export const add: Signature<'add', number> = (a, b) => a + b +export const add /*: Signature<'add', number>*/ = (a, b) => a + b export const unaryMinus: Signature<'unaryMinus', number> = a => -a -export const conj: Signature<'conj', number> = a => a -export const subtract: Signature<'subtract', number> = (a, b) => a - b +export const conj /*: Signature<'conj', number>*/ = a => a +export const subtract /*: Signature<'subtract', number>*/ = (a, b) => a - b export const multiply: Signature<'multiply', number> = (a, b) => a * b export const absquare: Signature<'absquare', number> = a => a * a export const reciprocal: Signature<'reciprocal', number> = a => 1 / a @@ -25,5 +25,6 @@ export const sqrt = if (a >= 0) return Math.sqrt(a) return dep.complex(0, Math.sqrt(unaryMinus(a))) } - } + } $reflecType!(sqrt) +$reflecTypes!([add, conj, subtract])