feat: Return type annotations #53

Merged
glen merged 15 commits from return_types into main 2022-08-30 19:36:44 +00:00

15 Commits

Author SHA1 Message Date
Glen Whitney d83f2a7f23 feat: Instantiate instances of template instantiation need for self-reference
Formerly, when a self-reference like `self(Tuple<number>)` was encountered,
  but the `Tuple<number>` instance of a `Tuple<T>` implementation for this
  operation had not yet been instantiated, the reference would be fulfilled
  with a call to the catchall implementation for `Tuple`. Now the
  necessary instance is instantiated on the spot and referred to instead.

  This change is used to complete return-type specification for all of the
  Tuple functions.
2022-08-30 15:15:23 -04:00
Glen Whitney be9794fd4c feat(ops): Provide return types in all of the operation-centric examples 2022-08-29 21:30:32 -04:00
Glen Whitney 1ee6da4294 feat(number): Provide return types for all operations 2022-08-29 21:18:59 -04:00
Glen Whitney 3957ae8adf feat: Add return types for all generic operations 2022-08-29 19:42:48 -04:00
Glen Whitney 23b3ef4fdd feat(Complex): Define return types of all operations 2022-08-29 11:10:34 -04:00
Glen Whitney de42c22ab4 refactor: Convert resolution to two-tier system
Typed-function's sort order/matching algorithm was interfering with
  template resolution. This commit solves the difficulty by moving the
  "catchall" implementations that implement generation of new template
  instances into a separate "fallback" typed-function universe, so that
  Pocomath can control exactly when that is searched.

  Removes a couple of the matching anomalies already noted in the tests.

  Also extends return types to somewhat more functions.
2022-08-29 09:30:07 -04:00
Glen Whitney a2f76a55b8 feat(return types): Add more return types for complex functions
These changes greatly increased the need for precision in generating
  implementations for signatures of operations whenever possible. So this
  commit also includes a refactor that basically caches all of the
  conversions of Pocomath implementations to typed-function implementatios so
  that they are more often externally available (i.e., not disrupted so much
  after invalidation).
2022-08-26 23:54:32 -04:00
Glen Whitney bc434c7163 feat(bigint): Specify return types for all methods 2022-08-24 20:59:30 -04:00
Glen Whitney 0950d7d585 feat(PocomathInstance): Specify return types of all core methods 2022-08-24 19:34:33 -04:00
Glen Whitney 775bb9ddb7 feat(returnTypeOf): Support template and upper bound types
Also changed the notation for an upper bound template to the more
  readable 'T:number' (instead of 'T (= number', which was supposed to
  look like the non-strict subset relation).
2022-08-24 13:37:32 -04:00
Glen Whitney f7bb3697ed feat(PocomathInstance): Add bounded template parameters
This feature helps specify the return type of implementations where
  the return type depends on the exact subtype that the implementation
  was called with, such as negate.
2022-08-22 12:38:23 -04:00
Glen Whitney dc6921e768 feat(PocomathInstance): Add subtypesOf and isSubtypeOf methods
Note this involves refeactoring the internal subtype tracker to keep
  subtypes in a list sorted in topological order.
2022-08-12 09:10:53 -07:00
Glen Whitney 340dbd436e feat(PocomathInstance): Add .returnTypeOf method 2022-08-11 23:51:47 -07:00
Glen Whitney 95f6ccc5a0 refactor: Put return types as properties on implementations 2022-08-11 08:13:10 -07:00
Glen Whitney 4b28f8eac0 refactor: Add a stub for supplying return type information
With this commit, there's a rudimentary function that attaches return-type
  information, so it can be supplied, and PocomathInstance then proceeds
  to check for it everywhere necessary (and supply it in all the internal
  operations it builds). But so far in all of those place where it's checked
  for, it's just ignored.

  I think the next step will be just to put the return type info as a property
  on the function itself. That should actually ease all of the code.
2022-08-10 12:00:06 -07:00