feat: config and approximate equality
All checks were successful
/ test (pull_request) Successful in 17s

Establishes a global config object for a TypeDispatcher instance, so far
  with just properties representing comparison tolerances. Begins a
  "relational" group of functions with basic approximate equality, and
  an initial primitive ordering comparison. Ensures that methods that
  depend on properties of `config` will be properly updated when those
  properties change.
This commit is contained in:
Glen Whitney 2025-04-15 01:17:27 -07:00
parent 27fa4b0193
commit d3f2bc09b7
19 changed files with 496 additions and 175 deletions

41
src/core/README.md Normal file
View file

@ -0,0 +1,41 @@
## Nanomath core
The organization here is to keep the core engine as compact and as agnostic
as to what sort of functions and types there might be in a TypeDispatcher as
possible. This division will keep it plausible to break out just the core
as a TypeDispatcher package that could be used independently for any collection
of overloaded functions on a universe of types. So we want to place as few
assumptions/preconditions as to what functions and/or types there will be.
## Core Types
As of this writing, the only two types required to be in a TypeDispatcher are
Undefined (the type inhabited only by `undefined`) and TypeOfTypes (the type
inhabited exactly by Type objects).
## Core methods
Similarly, as of this writing the only methods that must be in a TypeDispatcher
are:
Type
: the class (constructor) for Type objects, called via `new Type(...)`.
Note that merely constructing a Type does not regeister it within any
TypeDispatcher; it must be `.merge()`d into the TypeDispatcher.
typeOf
: determines the type of any value
merge
: adds values and methods to the TypeDispatcher
resolve
: finds values and methods in the TypeDispatcher, by key and types list
Any (other) functions an instance wants to have acting on the core Types
should be defined elsewhere and merged into the instance.
In nanomath as a whole, rather than within its core, we also assume that
the NumberT type of regular JavaScript numbers is always present (i.e., no
need to check if it is in the instance), and we put all functions that we
want to define on the core Types in the coretypes directory.