Skip to content

Lens and Optics System for Immutable Data Manipulation #256

@stud1999

Description

@stud1999

Implement a comprehensive Lens/Optics system inspired by Haskell's lens library and F#'s Aether. This would provide composable getter/setter abstractions for deep nested immutable data structures without boilerplate.

Technical Details:

  • Implement Lens, Prism, Iso, and Traversal types
  • Support composition through pipe operators
  • Type-safe with full Pylance/Pyright support
  • Integration with existing Option/Result types for safe access
  • Support for focusing, updating, and transforming nested data
  • Provide van Laarhoven encoding compatible with Python's type system

Use Cases:

  • Complex nested dataclass/frozen class updates
  • Deep JSON/config manipulation without mutation
  • State management in functional applications
  • Type-safe path access with composition

Implementation Challenges:

  • Python's limited higher-kinded types support
  • Complex generic type inference
  • Performance optimization for deep nesting
  • Integration with Pattern Matching (PEP 634)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions