best practice for using with dataclasses?
majidaldo opened this issue · 2 comments
majidaldo commented
I'm a satisfied dataclasses user. My coding style is just dataclasses connected with methods.
from attr import frozen as dataclass # i refuse to call mutable 'data'classes as 'data'classes. they're just data structures if they're mutable.
@dataclass
class MyThing:
attrib: type
@classmethod
def from_source(cls, *p, **k):
...#procedural code
# fig out validation
@classmethod
def iterator(cls,): ...
def to_otherthing(self, ) -> OtherThing : ...
This pattern seems close to what is prescribed by returns containers. I'm confused as to whether I'm supposed to create my own container or just use returns containers. I like the 'ecosystem' around attrs specifically.
I'm familiar with how FP 'manifests' in 'regular' programming but I haven't done FP as a whole 'system'.
sobolevn commented
Sorry, I don't understand your question. Do you want to create your own container? If so, which one? What problem do you want to solve?
If you want to use existing ones, it does not matter how you define your data types.
majidaldo commented
tabling