Commit Graph

7 Commits

Author SHA1 Message Date
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 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 ce974e2a99 log the reflectedType of complex square root 2023-09-21 14:24:52 +02:00
Glen Whitney 0e2a1e830a WIP: try to use ts-macros for more implementations 2023-09-18 10:14: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