Commit Graph

32 Commits

Author SHA1 Message Date
Glen Whitney 6f44567306 refactor: Extend reflection to all implementations so far
And also enhances the reflected type parsing so that the types of all
  implementations so far will parse.
2023-10-17 14:54:10 -07:00
Glen Whitney d8199341e0 refactor: Settle on making all implementations (possibly vacuous) factories 2023-10-16 18:48:26 -07:00
Glen Whitney ebe7cf831e refactor: Explore final patterns for runtime typing with ts-macros
The idea is to have a single macro which lets you reflect multiple
  implementations. That's provided in this commit. However, there
  is a hitch with implementations that have no dependencies: the
  reflectedType property did not exist on the Signature type. However,
  if you add it, then the Signature type becomes opaque, so we would
  have to look up signatures; but that appears to be tricky, as there
  doesn't seem to be a way to reflect the full generic type of the
  Signatures interface.

  So this commit provides three example resolutions:
  (A) Export a type RTT and all no-dependency implementations have to
      intersect with RTT (see 'add' in number/arithmetic.ts)
  (B) Write no-dependency implementations as functions of no arguments
      (representing no dependencies passed in) returning the actual
      implementation (see 'subtract' in number/arithmetic.ts)
  (C) Make a special DSignature<> generic type (short for "Direct Signature"
      used only (and always) for implementations with no dependencies, and
      a matching $Dreflect!() macro for generating their type info.

  Of course, there may be other possibilities I haven't thought of. But we
  need to pick one. I don't think it matters _too_ much, since there only
  a small fraction of all implementations have no dependencies.
2023-10-15 19:58:38 -07:00
Glen Whitney 49b1332917 feat: Add reflecTypes that allows multiple reflections at once 2023-10-09 21:10:15 -07:00
Glen Whitney 457b9cdc91 refactor: Possible alternate syntax for reflection 2023-09-30 15:52:14 -07:00
Jos de Jong 20236355c1 feat: do not generate export via macro but keep the export in TS for better DX 2023-09-29 15:36:22 +02:00
Jos de Jong 632c82966b chore: upgrade to `ts-macros@5.2.0` instead of directly from git 2023-09-28 11:30:44 +02:00
Jos de Jong 2f7677c371 chore: output the reflected types enclosed in quotes for clarity 2023-09-21 21:09:04 +02:00
Jos de Jong 1ca0ac42d0 feate: implement a basic parser for the reflected types 2023-09-21 21:01:38 +02:00
Jos de Jong fd4ecd70ba chore: use exact version numbers 2023-09-21 15:04:18 +02:00
Jos de Jong 0ebaaf35ee feat: convert sqrt for numbers 2023-09-21 15:02:42 +02:00
Jos de Jong 20078d2c87 use ts-macros directly from Github until v2.4.2 is published on npm 2023-09-21 14:58:51 +02:00
Jos de Jong ce974e2a99 log the reflectedType of complex square root 2023-09-21 14:24:52 +02:00
Jos de Jong 4947a80cb4 chore: make `pnpm go` work cross platform 2023-09-21 14:11:10 +02:00
Glen Whitney 0e2a1e830a WIP: try to use ts-macros for more implementations 2023-09-18 10:14:11 -07:00
Glen Whitney dc6cf5165d issue: ts-macros appears to be generating temp variable clashes 2023-08-26 12:19:32 -07:00
Glen Whitney ae2303af7c chore: Update to ts-macros@2.4.0 2023-08-26 10:14:02 -07:00
Glen Whitney 9eff2bc265 feat: Demonstrate macros to encapsulate the type-reflection process 2023-08-25 19:19:01 -07:00
Glen Whitney af02f1cb29 feat: Simplify the reflected type of an implementation 2023-08-25 19:19:01 -07:00
Glen Whitney da5b2c3467 feat: Demonstrate a trick for further resolving the dep type at compiletime 2023-08-25 19:19:01 -07:00
Glen Whitney 770c302342 feat: Precisely reflect the type of an implementation at runtime (!!) 2023-08-25 19:18:54 -07:00
Glen Whitney 180e772dab fix: Add types first and distinguish them semantically. (#15)
Rather than via some format on the name of the identifier, this commit
  changes the construction of Dispatcher to assume that functions are
  implementations and other objects are type specifiers.

  Also installs all types first, before any implementations.
  Resolves #3.
  Resolves #12.

Reviewed-on: #15
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Co-committed-by: Glen Whitney <glen@studioinfinity.org>
2023-08-26 02:15:59 +00:00
Glen Whitney 327a9385ed fix: Use intersection of matching types in AssociatedTypes<> lookup (#14)
Resolves #11.
Reviewed-on: #14
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Co-committed-by: Glen Whitney <glen@studioinfinity.org>
2023-08-23 16:52:16 +00:00
Glen Whitney 76e144bc2a feat: add build script (#13)
This commit adds pnpm scripts for compiling and running the
  typocomath package, and a convenience script `pnpm go` that does
  both in succession. It also configure pnpm to use a shell
  emulator so that it should work on Windows as well. Finally,
  it changes the directory for object files from obj to build.
  Resolves #9.

Reviewed-on: #13
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Co-committed-by: Glen Whitney <glen@studioinfinity.org>
2023-08-23 03:20:10 +00:00
Glen Whitney f06943ba1a chore: Update to latest TypeScript and make sure instructions work 2023-08-18 10:36:11 -07:00
Glen Whitney cc1e66c054 Declare implementations and dependencies via standard interfaces for operations (#8)
Adds a new subdirectory `interfaces` where standard interfaces
  are defined. Additional interfaces for a given operation can
  be added with an `AliasOf` type operator. Provides type
  operators that give the return type, full function type, and
  the type of a dependency on, a given operator.

  Resolves #6.

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
Reviewed-on: #8
2023-01-22 01:34:57 +00:00
Glen Whitney 3fa216d1f4 refactor: Major simplification in providing implementation types (#2)
This PR is an effort to address #1. It removes all boilerplate
  from individual implementation files, and moves it into
  a small, fixed section in the single `all.ts` module for each
  type that collects up all of the implementations relating
  to that type.

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #2
2022-12-19 23:50:24 +00:00
Glen Whitney 29bcab1639 style: whitespace fixes 2022-12-19 17:14:26 -05:00
Glen Whitney ccc6153786 feat: TypeScript typings for Dispatcher implementations
A first pass at specifying some implementations in TypeScript
  that actually compiles. It doesn't do anything, as installing
  types and operation specifications are currently dummy operations,
  but they are all invoked.
2022-12-06 20:21:05 -05:00
Glen Whitney 2a9039ac67 experiment: Can't put code in declare sections :-) 2022-12-06 12:10:18 -05:00
Glen Whitney 78f3975d54 chore: pnpm init and add TypeScript 2022-12-02 09:15:25 -05:00
Glen Whitney 215a36a847 Initial commit 2022-12-02 14:04:53 +00:00