Metakit / API

@doeixd/metakit

MetaKit — an Env-indexed calculus of inspectable expressions and single-step transitions over Effect Schema.

Built on a closed set of 50 primitive operators (Node.CoreOpId): Bool, Eq, Null, Ord, Num, Str and Arr, with derived helpers (min, max, abs, clamp, between, isNotNull, implies) that need no tier implementation of their own, and one node kind, Rows, that asks a question of each element of a list (Arr.any, Arr.sum, …).

Namespaces

addWritesTwo adds commute where num.add is commutative and associative, over the integers it is associative over.
ArrLists: their length (arr.count, arr.isEmpty), what a write makes of one (arr.append, and arr.include and arr.exclude over a set held as a sorted list of…
BoolBoolean primitive operators (bool.and, bool.or, bool.not), three-valued the way SQL's are: false AND null is false, true AND null is null. A refused operand…
combineWritesTwo combines commute where both name one operation claiming commutative and total associative.
EqEquality and set-membership primitive operators: eq.is and eq.in, and SQL's = and in (eq.equals, eq.among); isNot is not(is(…)).
ExprInspectable, pure, terminating expressions indexed by a typed environment Env (Expr<Env, A>).
foldProperties
foldsEvery fold by its id: for a reader that rebuilds a node from its id alone (the codec).
NodeThe seven kinds of node every MetaKit expression is made of, and the closed set of 50 primitive operators (CoreOpId).
NullNullability primitives (null.isNull, null.coalesce) and derived helper (Null.isNotNull).
NumNumeric arithmetic primitives (num.add, num.sub, num.mul, num.neg) and derived helpers (min, max, abs, clamp) built over If + Ord.
OrdOrdering primitives (ord.lt, ord.lte, ord.gt, ord.gte) and derived range helper (Ord.between). Null-strict: a comparison with null is null. NaN has no…
PathTyped, serializable paths into an environment (Path<Env, A>).
SetsSet operations over scalar sets (held as arrays of finite numbers or NUL-free strings): union, intersect, difference (core primitives) plus derived helpers…
setWritesThe rows of set and add, exported apart: a page that asks only of these two (foldkit-remote's replay) keeps them and drops the rest of the table.
StrString primitives (str.len, str.startsWith, str.contains, str.lowerAscii, str.trim, the code-point orders str.lt, str.lte, str.gt, str.gte) and derived…
TimeCalendar-day time operations (time.*): addDays, addMonths (clamped to month-end), daysBetween, startOfMonth, and half-open overlaps.
TransitionGuarded, single-step state transitions (Transition<State, Input, Emit, Supplied>).
VerdictA reader's answer to "does it hold", for a reader that does not run the term. A predicate holds only where it evaluates to true.
writeProperties

Functions

foldPropertiesOfThe properties of a Rows fold, deriving a reduce fold's row from its operation under options (reduceProperties).
reducePropertiesDerive a reduce fold's properties from its custom operation's claims. Its identity is the fold's definition (the answer over no element) and is always read.…

Values

Interfaces

ExpressionPure, terminating expression reading paths from Env and producing A. Env is contravariant (phantom) so an expression over { row } widens into { row,…
FoldPropertiesWhat a fold keeps, as it is read off the elements' answers.
OpPropertiesThe closed set of seven properties, each an optional field, and two rewrite rules partial evaluation alone reads (reflexive, involution).
TransitionDefA guarded, single-step transition over State, Input and the Supplied values. InputServices bounds the services decoding or encoding its input Schema needs:…
WriteProperties

Types

CommuteConditionWhen two writes to one path give one state in either order:
DirectionPer argument: a larger value never gives a smaller answer (up), or never a larger one (down).
DomainThe values a property holds over: every value evaluation can meet, or the safe integers (with null and a refusal). Addition of doubles rounds, so grouping…
EnvOfMap { k: Schema } to { readonly [K]: Schema['Type'] }.
IdempotentConditionWhen a write of one way, run twice in a row with the same values, leaves what it left once:
NoSuppliedA transition that takes no supplied input.
PathAccessorRecursive typed accessor for an environment value A: every plain object property (including TypeScript interfaces) becomes a nested PathAccessor<Env, A[K]>,…
SchemaOfConstraint for a generic helper that both composes a Schema (Schema.Struct, Schema.Array, Expr.refine) and decodes it synchronously (Schema.decodeUnknownSync).
SideWhich argument a value stands in: the first, the second, or either.
WayOfWritingHow a transition changes one path.