Skip to content

Explicit Immutable State Objects (beyond dataclasses) #10

@zinthose

Description

@zinthose

Why it's good:

While dataclasses with frozen=True are a good start, more robust immutable data structures can further enforce the "pure" aspect of the core.

Thoughts:

  • Show how users can leverage libraries like pyrsistent or attrs (with frozen instances) for their state objects passed into the Ruleset. This reinforces that the Ruleset should not be modifying these objects in place.
  • The Shell could have methods that facilitate creating new versions of its state object with updated values (e.g., self.state = self.state.set(field=new_value)), rather than directly mutating the internal dictionary.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions