Expand description
Pattern type definition
This module provides the core Pattern<V> type, a recursive, nested structure
(s-expression-like) that is generic over value type V.
§Construction Functions
Pattern::point- Creates an atomic pattern from a value (special case, matches gram-hs API)Pattern::pattern- Creates a pattern with elements (primary constructor, matches gram-hs API)Pattern::from_list- Creates a pattern from a list of values
§Accessor Methods
Pattern::value- Returns a reference to the pattern’s valuePattern::elements- Returns a slice of the pattern’s elements
§Inspection Utilities
Pattern::length- Returns the number of direct elementsPattern::size- Returns the total number of nodesPattern::depth- Returns the maximum nesting depthPattern::is_atomic- Checks if a pattern is atomicPattern::values- Extracts all values as a flat list (pre-order)
§Query Functions
Pattern::any_value- Checks if at least one value satisfies a predicate (short-circuits)Pattern::all_values- Checks if all values satisfy a predicate (short-circuits)Pattern::filter- Extracts subpatterns that satisfy a pattern predicatePattern::find_first- Finds the first subpattern that satisfies a pattern predicate (short-circuits)Pattern::matches- Checks if two patterns have identical structurePattern::contains- Checks if a pattern contains another as a subpattern
§Combination Operations
Pattern::combine- Combines two patterns associatively (value combination + element concatenation)
Structs§
- Pattern
- A recursive, nested structure (s-expression-like) that is generic over value type
V. - Structure
Analysis - Results from structure analysis utilities.
- Validation
Error - Error type for pattern validation failures.
- Validation
Rules - Configurable validation rules for pattern structure.