Expand description
CIP-100 canonical type normalization and name rendering.
CanonType is the single normalized form of a Cypher type: default
names (CIP-100 “Type name normalization”), CIP-100’s semantic
simplifications (flatten nested unions, drop redundant/subtype members,
combine NULL with NOT NULL types), and the canonical type order all
already applied. Two semantically equivalent types always normalize to
structurally equal CanonType trees.
This is the shared engine behind two features:
- CIP-90’s
valueType(), which renders a runtime value’s dynamic type (built bottom-up from the value’s own shape by the engine, seerelate-executor’svalue_type_name). - CIP-100’s own normalization of a parsed
TypeExpr(property type constraints, exposed viaSHOW CONSTRAINTS.propertyType).
Note: TypeExpr (CIP-86 grammar), the type predicate evaluator, and
this module’s type_expr_to_canon all live in the parser crate since
normalization is purely a function of the parsed type grammar; nothing
here depends on CypherValue.
Structs§
- Canon
Type - A fully CIP-100-normalized Cypher type.
Enums§
Functions§
- normalize_
union - Normalizes a set of already-normalized component types into their
single CIP-100 normalized form: flattens nested unions, removes
duplicate/subtype members, applies the “combine NULL and NOT NULL
types” encompassing rule (a union with at least one nullable member
makes every member nullable), and orders what remains. Returns the
single member directly if only one remains once simplified (CIP-100
“Simplify dynamic unions with one type”), or
NOTHINGfor an empty input. - parse_
canon_ type_ str - Reverse of
render_canonfor a property type constraint’s stored canonical string: reconstructs aTypeExpra caller can feed to a value-type matcher. Only understands the shaperender_canonactually produces for avalidate_property_type-accepted type (predefined names,LIST<...>, a trailingNOT NULL, and" | "-separated unions) – not general Cypher type syntax. Used to re-derive a runtime type matcher for a constraint loaded back from storage (CIP-85 enforcement), where only the rendered string persists. ReturnsNoneifsdoesn’t match that shape (should not happen for a string this module itself produced). - render_
canon - Renders a
CanonTypeto its CIP-100 canonical string: uppercase, single-space word separators, no space around<>,|surrounded by exactly one space on each side. - type_
expr_ to_ canon - Converts a parsed
TypeExpr(CIP-86 grammar) to its CIP-100 canonical form. - validate_
list_ element - Validates a
LIST<...>inner element type (CIP-85: “lists cannot have a union/list/nullable inner type”, NOT NULL is mandatory on the element). Errors are rendered againstlist_canon(the wholeLIST<...>type), matching Neo4j’s error shape.pub(not just used byvalidate_property_type) because CIP-178/181’s graph-type property types share this exact restriction while allowing top-levelNOT NULL(whichvalidate_property_typeitself forbids – that rule is specific to standalone property type constraints, not a node/edge type’s own declared properties). - validate_
property_ type - Validates a normalized type against Relate’s property type
constraint restrictions (CIP-85): no top-level
NOT NULL(on a scalar or on the list itself – Neo4j 2026.05 does not implementTYPE NOT NULLfor property type constraints), noNOTHING/NULL/ANY/NODE/RELATIONSHIP/PATH/MAP, and – inside aLIST<...>– no union, no nested list, and no nullable inner type (NOT NULL is mandatory there). - validate_
property_ type_ expr - The
<value type>expression form ofvalidate_property_type, for callers that still hold the parsed type:PROPERTY VALUEcanonicalizes into an open union of every storable scalar, so the canonical form alone cannot tell it apart from an explicitly written union – and Neo4j rejects it as a property type constraint while accepting the union (live corpus:Create*PropertyTypeConstraintCommands). One entry point for both call sites, so the expression-level rule cannot drift from the canonical one.