Skip to content

Replace nested type wrappers with a flat transforms array - #136

Merged
lorisleiva merged 1 commit into
mainfrom
flat-transforms
Aug 31, 2026
Merged

Replace nested type wrappers with a flat transforms array#136
lorisleiva merged 1 commit into
mainfrom
flat-transforms

Conversation

@lorisleiva

Copy link
Copy Markdown
Member

This PR implements #125: the nestedTypeNode mechanism is gone, transforms are data on the type they modify.

New transform category: fixedSizeTransformNode, sizePrefixTransformNode, preOffsetTransformNode, postOffsetTransformNode, sentinelTransformNode, hiddenPrefixTransformNode, hiddenSuffixTransformNode (each a former wrapper minus its inner type, docs and worked examples carried over), plus the transformNode union documenting the ordering rule: applied in array order, first is innermostfixedSizeTypeNode(sentinelTypeNode(X)) becomes X with transforms: [sentinel, fixedSize].

Every typeNode union member (17 standalone types + definedTypeLinkNode) declares a trailing transforms attribute via a shared transformsAttribute() helper, so links can now be transformed directly.

De-nesting: every nestedUnion('nestedTypeNode', X) reference becomes a plain node(X)accountNode.data, enum struct/tuple variant payloads, and the numeric slots on enumTypeNode, booleanTypeNode, amountTypeNode, solAmountTypeNode, dateTimeTypeNode, optionTypeNode, prefixedCountNode. defineNestedUnion stays in the meta-model (the 1.x line uses it) but nothing in this spec does; the docs root legend only mentions (recursive) pages when nested unions exist.

Counts: still 95 nodes (−7 wrappers, +7 transforms), 34 unions (+transformNode). Examples using wrappers (events, discriminators, maps, structs, tuples) rewritten to the transforms style; doc-strings sweep (stringTypeNode, offset strategies, "wrapped" → "inner"/"transformed").

Upgrade lens note (for upgradeV1ToV2): mechanical — unwrap each wrapper chain inside-out, appending to the base type's transforms; rename enum variant struct/tuple and other nested slots' contents in place (their attribute names are unchanged).

Closes #125 (manual close — default branch is 1.x). Part of #102.

The seven wrapper type nodes and the nestedTypeNode recursive alias are removed in favour of a new transform category: one transform node per former wrapper (same attributes minus the inner type) plus a transformNode union documenting the ordering rule — applied in array order, first innermost. Every typeNode union member, links included, declares a trailing transforms attribute via a shared transformsAttribute helper, and every nestedUnion reference becomes a plain node reference (accountNode.data, enum variant payloads, numeric prefix slots). A type's kind is now stable whether or not it is modified, examples and doc-strings are swept to the transforms style, and the docs root legend only mentions recursive pages when nested unions exist.
@lorisleiva
lorisleiva merged commit e6f9c63 into main Aug 31, 2026
3 checks passed
@lorisleiva
lorisleiva deleted the flat-transforms branch August 31, 2026 22:22
@lorisleiva lorisleiva linked an issue Sep 1, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2] Replace nested type wrappers with a flat transforms array

1 participant