Skip to content

028 paramorphism folding#49

Merged
akollegger merged 5 commits intomainfrom
028-paramorphism-folding
Jan 6, 2026
Merged

028 paramorphism folding#49
akollegger merged 5 commits intomainfrom
028-paramorphism-folding

Conversation

@akollegger
Copy link
Copy Markdown
Contributor

This pull request introduces paramorphism as a first-class, structure-aware folding operation for patterns, along with comprehensive documentation, API exposure, and tests. Paramorphism enables folding over recursive data structures (like patterns) with access to the full structure at each step, supporting advanced aggregations that depend on depth, element count, or nesting level.

The most important changes are:

Paramorphism Core Implementation

  • Added the para function to Pattern.Core, enabling structure-aware folding over patterns. The folding function receives both the current pattern subtree and recursively computed results from children. Includes extensive documentation and usage examples.
  • Exposed para from the Pattern.Core module, making it available to library users.

Documentation and Reference

  • Added a comprehensive reference document docs/reference/features/paramorphism.md covering paramorphism's purpose, function signature, laws, properties, usage patterns, and examples in multiple languages.
  • Extended the user guide (docs/guide/06-advanced-morphisms.md) with an intuitive explanation, examples, and comparison of paramorphism with Foldable and Comonad.
  • Updated the porting guide (docs/reference/PORTING-GUIDE.md) to include paramorphism as a required feature, with a dedicated implementation section and language-specific examples (Rust, TypeScript, Python, Haskell). [1] [2]

Testing

  • Added para to the test imports in Pattern/CoreSpec.hs, preparing for or enabling direct testing of paramorphism.

@akollegger akollegger merged commit 3c0baed into main Jan 6, 2026
1 check passed
@akollegger akollegger deleted the 028-paramorphism-folding branch January 6, 2026 18:55
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.

1 participant