Proof of concepts for a PocoMath-adjacent approach to a possible math.ts (TypeScript analogue of mathjs)
Go to file
Glen Whitney f58bae105d Merge pull request 'feat: Incremental building and simultaneous overloading of object values' (#5) from stepfive into main
Reviewed-on: #5
2022-09-26 05:39:44 +00:00
obj chore: enable node to run the output of tsc without modification 2022-09-07 10:10:41 -04:00
src feat: Incremental building and simultaneous overloading of object values 2022-09-26 01:36:25 -04:00
.gitignore chore: enable node to run the output of tsc without modification 2022-09-07 10:10:41 -04:00
LICENSE Initial commit 2022-09-04 02:53:08 +00:00
README.md feat: Incremental building and simultaneous overloading of object values 2022-09-26 01:36:25 -04:00
package.json5 feat(overload): Use typescript-rtti to select implementations (#4) 2022-09-25 20:02:01 +00:00
pnpm-lock.yaml feat(overload): Use typescript-rtti to select implementations (#4) 2022-09-25 20:02:01 +00:00
tsconfig.json feat(overload): Use typescript-rtti to select implementations (#4) 2022-09-25 20:02:01 +00:00

README.md

typomath

Proof of concepts for a PocoMath-adjacent approach to a possible math.ts (TypeScript analogue of mathjs)

Roadmap:

  1. Install over.ts and get an example of add with number and bigint implementations working with it. [DONE]
  2. Use the builder pattern to get add working with its implmentations defined incrementally before producing the final overload. [Didn't quite work the way we wnated, but maybe we can do an alternative later.]
  3. Make a version of over.ts, call it util/overload.ts, that takes an array of implementations without redundant type annotation. [DONE]
  4. Improve that version of overload with rtti to select the implementation without the implementations having to throw errors. [DONE]
  5. Use the builder pattern to get a single object with both an add and a negate method, with both defined incrementally, working. [DONE]
  6. Incorporate a subtract method that works on numbers and bigint by separate definitions but with dependencies on add and negate.
  7. Incorporate a subtract method that works with one generic implementation that works for both number and bigint with dependencies on add and negate.
  8. Attempt to eliminate redundant specification of implementation signatures.
  9. Incorporate multi-argument reducing implementation of add.
  10. Actually split into multiple source files to make sure that works.
  11. Add a template Complex type with add and subtract.
  12. Define a sqrt method that depends on a literal constant non-mutable config object that has to be set before loading sqrt, but with two different imports that use different settings for the config.
  13. Add a NumInt type to the existing methods. For reference in the case of positive numbers: https://stackoverflow.com/questions/71670965/how-do-i-assert-a-number-type-is-positive. One can make a similar template for integers, esp. using ${bigint} in a template literal. But as the comments point out, this doesn't work for computed arguments, only literals. (I think there was a package or repository or other library of lots of such examples, but now I can't find it :-( but anyhow...). So I am not really sure how a type that can't really be precisely represented in TypeScript is going to work out in this approach... Maybe there is a way to automatically combine branded types with type guards. Check out newtype-ts, it has a type library with a bunch of branded types.

If we get that far, then math.ts is probably feasible.