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.
Why it's good:
While
dataclasseswithfrozen=Trueare a good start, more robust immutable data structures can further enforce the "pure" aspect of the core.Thoughts:
pyrsistentorattrs(with frozen instances) for their state objects passed into theRuleset. This reinforces that theRulesetshould not be modifying these objects in place.self.state = self.state.set(field=new_value)), rather than directly mutating the internal dictionary.